pass docker cert and key as byte arrays or file paths

This commit is contained in:
Brad Rydzewski 2014-10-21 01:17:12 -07:00
parent 8436bd0270
commit 8c51215e55

View file

@ -41,6 +41,21 @@ func NewBuildCommand() cli.Command {
Name: "publish", Name: "publish",
Usage: "runs drone build with publishing enabled", Usage: "runs drone build with publishing enabled",
}, },
cli.StringFlag{
Name: "docker-host",
Value: "",
Usage: "docker daemon address",
},
cli.StringFlag{
Name: "docker-cert",
Value: "",
Usage: "docker daemon tls certificate",
},
cli.StringFlag{
Name: "docker-key",
Value: "",
Usage: "docker daemon tls key",
},
}, },
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
buildCommandFunc(c) buildCommandFunc(c)
@ -56,6 +71,10 @@ func buildCommandFunc(c *cli.Context) {
var publish = c.Bool("publish") var publish = c.Bool("publish")
var path string var path string
var dockerhost = c.String("docker-host")
var dockercert = c.String("docker-cert")
var dockerkey = c.String("docker-key")
// the path is provided as an optional argument that // the path is provided as an optional argument that
// will otherwise default to $PWD/.drone.yml // will otherwise default to $PWD/.drone.yml
if len(c.Args()) > 0 { if len(c.Args()) > 0 {
@ -80,12 +99,17 @@ func buildCommandFunc(c *cli.Context) {
log.SetPriority(log.LOG_DEBUG) //LOG_NOTICE log.SetPriority(log.LOG_DEBUG) //LOG_NOTICE
docker.Logging = false docker.Logging = false
var exit, _ = run(path, identity, publish, deploy, privileged) var exit, _ = run(path, identity, dockerhost, dockercert, dockerkey, publish, deploy, privileged)
os.Exit(exit) os.Exit(exit)
} }
func run(path, identity string, publish, deploy, privileged bool) (int, error) { // TODO this has gotten a bit out of hand. refactor input params
dockerClient := docker.New() func run(path, identity, dockerhost, dockercert, dockerkey string, publish, deploy, privileged bool) (int, error) {
dockerClient, err := docker.NewHostCertFile(dockerhost, dockercert, dockerkey)
if err != nil {
log.Err(err.Error())
return EXIT_STATUS, err
}
// parse the private environment variables // parse the private environment variables
envs := getParamMap("DRONE_ENV_") envs := getParamMap("DRONE_ENV_")