Automatically detect ENV variables
This commit is contained in:
parent
01ca940add
commit
5b07ef5ffe
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{
|
cli.StringFlag{
|
||||||
Name: "docker-host",
|
Name: "docker-host",
|
||||||
Value: "",
|
Value: getHost(),
|
||||||
Usage: "docker daemon address",
|
Usage: "docker daemon address",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "docker-cert",
|
Name: "docker-cert",
|
||||||
Value: "",
|
Value: getCert(),
|
||||||
Usage: "docker daemon tls certificate",
|
Usage: "docker daemon tls certificate",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "docker-key",
|
Name: "docker-key",
|
||||||
Value: "",
|
Value: getKey(),
|
||||||
Usage: "docker daemon tls key",
|
Usage: "docker daemon tls key",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -204,3 +204,23 @@ func run(path, identity, dockerhost, dockercert, dockerkey string, publish, depl
|
||||||
|
|
||||||
return builder.BuildState.ExitCode, nil
|
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