From 8c51215e55b45ee76cf863428ae709be25f15227 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Tue, 21 Oct 2014 01:17:12 -0700 Subject: [PATCH] pass docker cert and key as byte arrays or file paths --- cli/build.go | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/cli/build.go b/cli/build.go index e50be1aa..0c5a3e1b 100644 --- a/cli/build.go +++ b/cli/build.go @@ -41,6 +41,21 @@ func NewBuildCommand() cli.Command { Name: "publish", 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) { buildCommandFunc(c) @@ -56,6 +71,10 @@ func buildCommandFunc(c *cli.Context) { var publish = c.Bool("publish") 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 // will otherwise default to $PWD/.drone.yml if len(c.Args()) > 0 { @@ -80,12 +99,17 @@ func buildCommandFunc(c *cli.Context) { log.SetPriority(log.LOG_DEBUG) //LOG_NOTICE 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) } -func run(path, identity string, publish, deploy, privileged bool) (int, error) { - dockerClient := docker.New() +// TODO this has gotten a bit out of hand. refactor input params +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 envs := getParamMap("DRONE_ENV_")