-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrebuild.go
64 lines (55 loc) · 1.48 KB
/
rebuild.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
package main
import (
"fmt"
"os"
)
type RebuildCommand struct {
BuildCommand
Ports []string `short:"p" long:"port" description:"Ports to expose (similar to docker -p)."`
Volumes []string `long:"volume" description:"Volume to mount (similar to docker -v)."`
ForceBuild bool `long:"force-build" description:"Force building of new user image."`
Args struct {
Name string `description:"Name of environment."`
} `positional-args:"yes" required:"yes"`
}
func (ccommand *RebuildCommand) toCreateOpts(sc SystemClient) CreateOpts {
return CreateOpts{
Name: ccommand.Args.Name,
Ports: ccommand.Ports,
Volumes: ccommand.Volumes,
ForceBuild: ccommand.ForceBuild || ccommand.ForcePull,
Build: BuildOpts{
Image: ImageOpts{
Type: ccommand.Type,
Version: ccommand.Version,
Image: ccommand.Image,
},
TimeZone: ccommand.TimeZone,
ForcePull: ccommand.ForcePull,
Username: sc.Username(),
UID: sc.UID(),
GID: sc.GID(),
},
}
}
var rebuildCommand RebuildCommand
func (x *RebuildCommand) Execute(args []string) error {
dc, err := NewDockerClient(globalOptions.toConnectOpts())
if err != nil {
return err
}
sc, err := NewSystemClient()
if err != nil {
return err
}
return RebuildEnvironment(dc, sc, rebuildCommand.toCreateOpts(sc), os.Stdout)
}
func init() {
_, err := parser.AddCommand("rebuild",
"Rebuild an environment.",
"",
&rebuildCommand)
if err != nil {
fmt.Println(err)
}
}