ability to pass --deploy and --publish flags to drone build

This commit is contained in:
Brad Rydzewski 2014-10-12 14:07:28 -07:00
parent 643f811f05
commit afc3030087

View file

@ -34,6 +34,16 @@ func NewBuildCommand() cli.Command {
Value: "false", Value: "false",
Usage: "runs drone build in a privileged container", Usage: "runs drone build in a privileged container",
}, },
cli.StringFlag{
Name: "deploy",
Value: "false",
Usage: "runs drone build with deployments enabled",
},
cli.StringFlag{
Name: "publish",
Value: "false",
Usage: "runs drone build with publishing enabled",
},
}, },
Action: func(c *cli.Context) { Action: func(c *cli.Context) {
buildCommandFunc(c) buildCommandFunc(c)
@ -45,6 +55,8 @@ func NewBuildCommand() cli.Command {
func buildCommandFunc(c *cli.Context) { func buildCommandFunc(c *cli.Context) {
var privileged = c.Bool("p") var privileged = c.Bool("p")
var identity = c.String("i") var identity = c.String("i")
var deploy = c.Bool("deploy")
var publish = c.Bool("publish")
var path string var path string
// the path is provided as an optional argument that // the path is provided as an optional argument that
@ -71,11 +83,11 @@ 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, privileged) var exit, _ = run(path, identity, publish, deploy, privileged)
os.Exit(exit) os.Exit(exit)
} }
func run(path, identity string, privileged bool) (int, error) { func run(path, identity string, publish, deploy, privileged bool) (int, error) {
dockerClient := docker.New() dockerClient := docker.New()
// parse the private environment variables // parse the private environment variables
@ -93,10 +105,12 @@ func run(path, identity string, privileged bool) (int, error) {
s.Env = append(s.Env, key+"="+val) s.Env = append(s.Env, key+"="+val)
} }
// remove deploy & publish sections if deploy == false {
// for now, until I fix bug
s.Publish = nil s.Publish = nil
}
if publish == false {
s.Deploy = nil s.Deploy = nil
}
// get the repository root directory // get the repository root directory
dir := filepath.Dir(path) dir := filepath.Dir(path)
@ -144,7 +158,6 @@ func run(path, identity string, privileged bool) (int, error) {
builder.Repo = &code builder.Repo = &code
builder.Key = key builder.Key = key
builder.Stdout = os.Stdout builder.Stdout = os.Stdout
// TODO ADD THIS BACK
builder.Timeout = 300 * time.Minute builder.Timeout = 300 * time.Minute
builder.Privileged = privileged builder.Privileged = privileged