Skip to content

Commit

Permalink
Automatically detect ENV variables
Browse files Browse the repository at this point in the history
  • Loading branch information
kzaitsev committed Dec 20, 2014
1 parent 01ca940 commit 7deb991
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions cli/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ func NewBuildCommand() cli.Command {
},
cli.StringFlag{
Name: "docker-host",
Value: "",
Value: getHost(),
Usage: "docker daemon address",
},
cli.StringFlag{
Name: "docker-cert",
Value: "",
Value: getCert(),
Usage: "docker daemon tls certificate",
},
cli.StringFlag{
Name: "docker-key",
Value: "",
Value: getKey(),
Usage: "docker daemon tls key",
},
},
Expand Down Expand Up @@ -204,3 +204,27 @@ func run(path, identity, dockerhost, dockercert, dockerkey string, publish, depl

return builder.BuildState.ExitCode, nil
}

func getHost() string {
if os.Getenv("DOCKER_HOST") != "" {
return os.Getenv("DOCKER_HOST")
} else {
return ""
}
}

func getCert() string {
if os.Getenv("DOCKER_CERT_PATH") != "" && os.Getenv("DOCKER_TLS_VERIFY") == "1" {
return filepath.Join(os.Getenv("DOCKER_CERT_PATH"), "cert.pem")
} else {
return ""
}
}

func getKey() string {
if os.Getenv("DOCKER_CERT_PATH") != "" && os.Getenv("DOCKER_TLS_VERIFY") == "1" {
return filepath.Join(os.Getenv("DOCKER_CERT_PATH"), "key.pem")
} else {
return ""
}
}

0 comments on commit 7deb991

Please sign in to comment.