Merge pull request #765 from Bugagazavr/detect_envs
Automatically detect ENV variables
This commit is contained in:
commit
4693b1f526
1 changed files with 23 additions and 3 deletions
26
cli/build.go
26
cli/build.go
|
@ -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",
|
||||
},
|
||||
},
|
||||
|
@ -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 ""
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue