-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathhubtag.go
More file actions
42 lines (35 loc) · 851 Bytes
/
hubtag.go
File metadata and controls
42 lines (35 loc) · 851 Bytes
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
package main
import (
"fmt"
"os"
"github.com/progrium/go-shell"
"github.com/spf13/cobra"
)
func init() {
Glu.AddCommand(hubtagCmd)
}
var hubtagCmd = &cobra.Command{
Use: "hubtag <dockerhub-repo> <tag> [git-tag] [dockerfile-path]",
Short: "Creates an automated build tag for a Docker Hub repo",
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 2 {
cmd.Usage()
os.Exit(1)
}
dockerhubRepo := args[0]
tagName := args[1]
tagSource := args[1]
if len(args) >= 3 {
tagSource = args[2]
}
dockerfileLocation := "/"
if len(args) >= 4 {
dockerfileLocation = args[3]
}
defer shell.ErrExit()
shell.Trace = true
shell.Tee = os.Stdout
sh("go get -u github.com/progrium/dockerhub-tag")
sh(fmt.Sprintf("dockerhub-tag set %s %s %s %s", dockerhubRepo, tagName, tagSource, dockerfileLocation))
},
}