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 27, 2014
1 parent 01ca940 commit 5b07ef5
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 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,23 @@ func run(path, identity, dockerhost, dockercert, dockerkey string, publish, depl

return builder.BuildState.ExitCode, nil
}

func getHost() string {
return os.Getenv("DOCKER_HOST")
}

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 5b07ef5

Please sign in to comment.