added --insecure-registry flag
This commit is contained in:
parent
b95a703ab3
commit
be274cf2e9
24
main.go
24
main.go
@ -14,6 +14,7 @@ import (
|
|||||||
type Docker struct {
|
type Docker struct {
|
||||||
Storage string `json:"storage_driver"`
|
Storage string `json:"storage_driver"`
|
||||||
Registry string `json:"registry"`
|
Registry string `json:"registry"`
|
||||||
|
Insecure bool `json:"insecure"`
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
Email string `json:"email"`
|
Email string `json:"email"`
|
||||||
@ -54,7 +55,13 @@ func main() {
|
|||||||
cmd.Stderr = ioutil.Discard
|
cmd.Stderr = ioutil.Discard
|
||||||
cmd.Run()
|
cmd.Run()
|
||||||
|
|
||||||
cmd = exec.Command("docker", "-d", "-s", vargs.Storage)
|
args := []string{"-d", "-s", vargs.Storage}
|
||||||
|
|
||||||
|
if vargs.Insecure && len(vargs.Registry) != 0 {
|
||||||
|
args = append(args, "--insecure-registry", vargs.Registry)
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = exec.Command("docker", args...)
|
||||||
cmd.Stdout = ioutil.Discard
|
cmd.Stdout = ioutil.Discard
|
||||||
cmd.Stderr = ioutil.Discard
|
cmd.Stderr = ioutil.Discard
|
||||||
trace(cmd)
|
trace(cmd)
|
||||||
@ -73,17 +80,13 @@ func main() {
|
|||||||
vargs.File = "."
|
vargs.File = "."
|
||||||
}
|
}
|
||||||
// Set the Tag value
|
// Set the Tag value
|
||||||
switch vargs.Tag {
|
if len(vargs.Tag) == 0 {
|
||||||
case "$DRONE_BRANCH":
|
|
||||||
vargs.Tag = build.Commit.Branch
|
|
||||||
case "$DRONE_COMMIT":
|
|
||||||
vargs.Tag = build.Commit.Sha
|
|
||||||
case "":
|
|
||||||
vargs.Tag = "latest"
|
vargs.Tag = "latest"
|
||||||
}
|
}
|
||||||
vargs.Repo = fmt.Sprintf("%s:%s", vargs.Repo, vargs.Tag)
|
vargs.Repo = fmt.Sprintf("%s:%s", vargs.Repo, vargs.Tag)
|
||||||
|
|
||||||
// Login to Docker
|
// Login to Docker
|
||||||
|
if len(vargs.Username) != 0 {
|
||||||
cmd := exec.Command("docker", "login", "-u", vargs.Username, "-p", vargs.Password, "-e", vargs.Email, vargs.Registry)
|
cmd := exec.Command("docker", "login", "-u", vargs.Username, "-p", vargs.Password, "-e", vargs.Email, vargs.Registry)
|
||||||
cmd.Dir = workspace.Path
|
cmd.Dir = workspace.Path
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
@ -93,9 +96,12 @@ func main() {
|
|||||||
stop()
|
stop()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Printf("A username was not specified. Assuming anoynmous publishing.\n")
|
||||||
|
}
|
||||||
|
|
||||||
// Docker environment info
|
// Docker environment info
|
||||||
cmd = exec.Command("docker", "version")
|
cmd := exec.Command("docker", "version")
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
trace(cmd)
|
trace(cmd)
|
||||||
@ -112,7 +118,7 @@ func main() {
|
|||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
trace(cmd)
|
trace(cmd)
|
||||||
err = cmd.Run()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stop()
|
stop()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
|
Loading…
Reference in New Issue
Block a user