harness-drone/pkg/plugin/deploy/cloudfoundry.go

38 lines
866 B
Go
Raw Normal View History

2014-02-07 10:10:01 +00:00
package deploy
import (
2014-03-29 20:09:16 +00:00
"fmt"
"github.com/drone/drone/pkg/build/buildfile"
2014-02-07 10:10:01 +00:00
)
type CloudFoundry struct {
2014-03-29 20:09:16 +00:00
Target string `yaml:"target,omitempty"`
Username string `yaml:"username,omitempty"`
Password string `yaml:"password,omitempty"`
Org string `yaml:"org,omitempty"`
Space string `yaml:"space,omitempty"`
App string `yaml:"app,omitempty"`
2014-02-07 10:10:01 +00:00
}
2014-03-29 20:09:16 +00:00
func (cf *CloudFoundry) Write(f *buildfile.Buildfile) {
// login
loginCmd := "cf login -a %s -u %s -p %s -o %s -s %s"
organization := cf.Org
if organization == "" {
organization = cf.Username
}
space := cf.Space
if space == "" {
space = "dev"
}
f.WriteCmdSilent(fmt.Sprintf(loginCmd, cf.Target, cf.Username, cf.Password, organization, space))
2014-02-07 10:10:01 +00:00
2014-03-29 20:09:16 +00:00
// push app
pushCmd := "cf push %s"
f.WriteCmd(fmt.Sprintf(pushCmd, cf.App))
2014-02-07 10:10:01 +00:00
}