-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.go
59 lines (51 loc) · 998 Bytes
/
build.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"os"
"github.com/urfave/cli"
)
func build() cli.Command {
cmd := buildcmd{}
flags := append([]cli.Flag{}, cmd.flags()...)
return cli.Command{
Name: "build",
Usage: "build function version",
Flags: flags,
Action: cmd.build,
}
}
type buildcmd struct {
verbose bool
noCache bool
}
func (b *buildcmd) flags() []cli.Flag {
return []cli.Flag{
cli.BoolFlag{
Name: "v",
Usage: "verbose mode",
Destination: &b.verbose,
},
cli.BoolFlag{
Name: "no-cache",
Usage: "Don't use docker cache",
Destination: &b.noCache,
},
}
}
// build will take the found valid function and build it
func (b *buildcmd) build(c *cli.Context) error {
path, err := os.Getwd()
if err != nil {
return err
}
fn, err := findFuncfile(path)
if err != nil {
return err
}
ff, err := buildfunc(fn, b.noCache)
if err != nil {
return err
}
fmt.Printf("Function %v built successfully.\n", ff.ImageName())
return nil
}