/
builds.go
99 lines (76 loc) · 2.21 KB
/
builds.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package parser
import (
"github.com/deis/deis/client/cmd"
docopt "github.com/docopt/docopt-go"
)
// Builds routes build commands to their specific function.
func Builds(argv []string) error {
usage := `
Valid commands for builds:
builds:list list build history for an application
builds:create imports an image and deploys as a new release
Use 'deis help [command]' to learn more.
`
switch argv[0] {
case "builds:list":
return buildsList(argv)
case "builds:create":
return buildsCreate(argv)
default:
if printHelp(argv, usage) {
return nil
}
if argv[0] == "builds" {
argv[0] = "builds:list"
return buildsList(argv)
}
PrintUsage()
return nil
}
}
func buildsList(argv []string) error {
usage := `
Lists build history for an application.
Usage: deis builds:list [options]
Options:
-a --app=<app>
the uniquely identifiable name for the application.
-l --limit=<num>
the maximum number of results to display, defaults to config setting
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
results, err := responseLimit(safeGetValue(args, "--limit"))
if err != nil {
return err
}
return cmd.BuildsList(safeGetValue(args, "--app"), results)
}
func buildsCreate(argv []string) error {
usage := `
Creates a new build of an application. Imports an <image> and deploys it to Deis
as a new release. If a Procfile is present in the current directory, it will be used
as the default process types for this application.
Usage: deis builds:create <image> [options]
Arguments:
<image>
A fully-qualified docker image, either from Docker Hub (e.g. deis/example-go:latest)
or from an in-house registry (e.g. myregistry.example.com:5000/example-go:latest).
This image must include the tag.
Options:
-a --app=<app>
The uniquely identifiable name for the application.
-p --procfile=<procfile>
A YAML string used to supply a Procfile to the application.
`
args, err := docopt.Parse(usage, argv, true, "", false, true)
if err != nil {
return err
}
app := safeGetValue(args, "--app")
image := safeGetValue(args, "<image>")
procfile := safeGetValue(args, "--procfile")
return cmd.BuildsCreate(app, image, procfile)
}