-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommands.go
More file actions
64 lines (52 loc) · 1.3 KB
/
Copy pathcommands.go
File metadata and controls
64 lines (52 loc) · 1.3 KB
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"
"path/filepath"
"github.com/LEW21/siren/imagectl"
)
var Commands = []imagectl.Command{CmdBuild, CmdPull}
var CmdBuild = imagectl.Command{nil, "build", []string{"DIR_PATH"}, []string{"TAG"}, "Build an image from a Sirenfile", cmdBuild}
func cmdBuild(args []string) int {
path := args[0]
tag := ""
if len(args) >= 2 {
tag = args[1]
}
path, err := filepath.Abs(path)
if err != nil {
panic(err)
}
ictl, err := imagectl.New()
if err != nil {
panic(err)
}
_, tag, ok := Build(ictl, path, tag, os.Stderr)
if !ok {
return 1
}
fmt.Println()
fmt.Println("Image created.")
fmt.Println("Use 'siren create instance_name " + tag + "' to create a new, writable machine image using this image as a base.")
return 0
}
var CmdPull = imagectl.Command{nil, "pull", []string{"URI"}, []string{"TAG"}, "Pull and build an image from a git repostory", cmdPull}
func cmdPull(args []string) int {
uri := args[0]
tag := ""
if len(args) >= 2 {
tag = args[1]
}
ictl, err := imagectl.New()
if err != nil {
panic(err)
}
_, tag, ok := Pull(ictl, uri, tag, os.Stderr)
if !ok {
return 1
}
fmt.Println()
fmt.Println("Image created.")
fmt.Println("Use 'siren create instance_name " + tag + "' to create a new, writable machine image using this image as a base.")
return 0
}