mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-26 20:01:02 +00:00
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{
|
||||
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