mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Per language HOWTO's on writing functions (#208)
* fnctl: improve UX for howto's * doc: go function howto * fnctl: show the progress of build calls * doc: php function howto * doc: fix Go HOWTO * doc: Node Functions HOWTO * doc: Python Functions HOWTO * doc: improve README files * doc: ccirello -> USERNAME * docs: fix Python example Used an idiomatic method (isatty) to decide whether stdin must be read or not. * doc: fix go example * fnctl: fix docker push output
This commit is contained in:
committed by
Seif Lotfy سيف لطفي
parent
c8e4a9b82b
commit
5b3971060b
@@ -215,9 +215,10 @@ func (c commoncmd) localbuild(path string, steps []string) error {
|
||||
for _, cmd := range steps {
|
||||
exe := exec.Command("/bin/sh", "-c", cmd)
|
||||
exe.Dir = filepath.Dir(path)
|
||||
out, err := exe.CombinedOutput()
|
||||
fmt.Fprintf(c.verbwriter, "- %s:\n%s\n", cmd, out)
|
||||
if err != nil {
|
||||
exe.Stderr = c.verbwriter
|
||||
exe.Stdout = c.verbwriter
|
||||
fmt.Fprintf(c.verbwriter, "- %s:\n", cmd)
|
||||
if err := exe.Run(); err != nil {
|
||||
return fmt.Errorf("error running command %v (%v)", cmd, err)
|
||||
}
|
||||
}
|
||||
@@ -226,9 +227,10 @@ func (c commoncmd) localbuild(path string, steps []string) error {
|
||||
}
|
||||
|
||||
func (c commoncmd) dockerbuild(path, image string) error {
|
||||
out, err := exec.Command("docker", "build", "-t", image, filepath.Dir(path)).CombinedOutput()
|
||||
fmt.Fprintf(c.verbwriter, "%s\n", out)
|
||||
if err != nil {
|
||||
cmd := exec.Command("docker", "build", "-t", image, filepath.Dir(path))
|
||||
cmd.Stderr = c.verbwriter
|
||||
cmd.Stdout = c.verbwriter
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("error running docker build: %v", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ func main() {
|
||||
lambda(),
|
||||
publish(),
|
||||
routes(),
|
||||
run(),
|
||||
}
|
||||
app.Run(os.Args)
|
||||
}
|
||||
|
||||
@@ -84,12 +84,12 @@ func (p *publishcmd) publish(path string) error {
|
||||
}
|
||||
|
||||
func (p publishcmd) dockerpush(image string) error {
|
||||
out, err := exec.Command("docker", "push", image).CombinedOutput()
|
||||
fmt.Fprintf(p.verbwriter, "%s\n", out)
|
||||
if err != nil {
|
||||
cmd := exec.Command("docker", "push", image)
|
||||
cmd.Stderr = p.verbwriter
|
||||
cmd.Stdout = p.verbwriter
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("error running docker push: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
18
fnctl/run.go
Normal file
18
fnctl/run.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/iron-io/functions_go"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func run() cli.Command {
|
||||
r := routesCmd{RoutesApi: functions.NewRoutesApi()}
|
||||
|
||||
return cli.Command{
|
||||
Name: "run",
|
||||
Usage: "run function",
|
||||
ArgsUsage: "fnclt run appName /path",
|
||||
Flags: append(confFlags(&r.Configuration), []cli.Flag{}...),
|
||||
Action: r.run,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user