forked from hashicorp/otto
/
build.go
70 lines (55 loc) · 1.28 KB
/
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
60
61
62
63
64
65
66
67
68
69
70
package command
import (
"fmt"
"strings"
)
// BuildCommand is the command that builds a deployable artifact
// for this version of the app.
type BuildCommand struct {
Meta
}
func (c *BuildCommand) Run(args []string) int {
fs := c.FlagSet("build", FlagSetNone)
fs.Usage = func() { c.Ui.Error(c.Help()) }
if err := fs.Parse(args); err != nil {
return 1
}
// Show usage if build command was passed any arguments.
if len(args) != 0 {
fs.Usage()
return 1
}
// Load the appfile
app, err := c.Appfile()
if err != nil {
c.Ui.Error(err.Error())
return 1
}
// Get a core
core, err := c.Core(app)
if err != nil {
c.Ui.Error(fmt.Sprintf(
"Error loading core: %s", err))
return 1
}
// Build the artifact
if err := core.Build(); err != nil {
c.Ui.Error(fmt.Sprintf(
"Error building app: %s", err))
return 1
}
return 0
}
func (c *BuildCommand) Synopsis() string {
return "Build the deployable artifact for the app"
}
func (c *BuildCommand) Help() string {
helpText := `
Usage: otto build [options]
Builds the deployable artifact for the app on the target
infrastructure specified during compilation of the Appfile.
This will build and inventory the artifact that is deployable
for the app represented by this Appfile.
`
return strings.TrimSpace(helpText)
}