mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
@@ -157,7 +157,7 @@ during functions execution.
|
|||||||
the image. These calls are executed before `fnctl` calls `docker build` and
|
the image. These calls are executed before `fnctl` calls `docker build` and
|
||||||
`docker push`.
|
`docker push`.
|
||||||
|
|
||||||
## Build and Bump
|
## Build, Bump, Push
|
||||||
|
|
||||||
When dealing with a lot of functions you might find yourself making lots of
|
When dealing with a lot of functions you might find yourself making lots of
|
||||||
individual calls. `fnctl` offers two command to help you with that: `build` and
|
individual calls. `fnctl` offers two command to help you with that: `build` and
|
||||||
@@ -184,6 +184,9 @@ path result
|
|||||||
their version according to [semver](http://semver.org/) rules. In their absence,
|
their version according to [semver](http://semver.org/) rules. In their absence,
|
||||||
it will skip.
|
it will skip.
|
||||||
|
|
||||||
|
`fnctl push` will scan all IronFunctions and push their images to Docker Hub,
|
||||||
|
and update their routes accordingly.
|
||||||
|
|
||||||
## Application level configuration
|
## Application level configuration
|
||||||
|
|
||||||
When creating an application, you can configure it to tweak its behavior and its
|
When creating an application, you can configure it to tweak its behavior and its
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ func main() {
|
|||||||
call(),
|
call(),
|
||||||
lambda(),
|
lambda(),
|
||||||
publish(),
|
publish(),
|
||||||
|
push(),
|
||||||
routes(),
|
routes(),
|
||||||
run(),
|
run(),
|
||||||
}
|
}
|
||||||
|
|||||||
65
fnctl/push.go
Normal file
65
fnctl/push.go
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
functions "github.com/iron-io/functions_go"
|
||||||
|
"github.com/urfave/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
func push() cli.Command {
|
||||||
|
cmd := pushcmd{
|
||||||
|
publishcmd: &publishcmd{
|
||||||
|
commoncmd: &commoncmd{},
|
||||||
|
RoutesApi: functions.NewRoutesApi(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
var flags []cli.Flag
|
||||||
|
flags = append(flags, cmd.commoncmd.flags()...)
|
||||||
|
flags = append(flags, confFlags(&cmd.Configuration)...)
|
||||||
|
return cli.Command{
|
||||||
|
Name: "push",
|
||||||
|
Usage: "scan local directory for functions and push them.",
|
||||||
|
Flags: flags,
|
||||||
|
Action: cmd.scan,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type pushcmd struct {
|
||||||
|
*publishcmd
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *pushcmd) scan(c *cli.Context) error {
|
||||||
|
p.commoncmd.scan(p.walker)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *pushcmd) walker(path string, info os.FileInfo, err error, w io.Writer) error {
|
||||||
|
walker(path, info, err, w, p.push)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// push will take the found function and check for the presence of a
|
||||||
|
// Dockerfile, and run a three step process: parse functions file,
|
||||||
|
// push the container, and finally it will update function's route. Optionally,
|
||||||
|
// the route can be overriden inside the functions file.
|
||||||
|
func (p *pushcmd) push(path string) error {
|
||||||
|
fmt.Fprintln(p.verbwriter, "pushing", path)
|
||||||
|
|
||||||
|
funcfile, err := parsefuncfile(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := p.dockerpush(funcfile.Image); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := p.route(path, funcfile); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user