github.com/marinho/drone@v0.2.1-0.20140504195434-d3ba962e89a7/pkg/plugin/deploy/cloudfoundry.go (about) 1 package deploy 2 3 import ( 4 "fmt" 5 "github.com/drone/drone/pkg/build/buildfile" 6 ) 7 8 type CloudFoundry struct { 9 Target string `yaml:"target,omitempty"` 10 Username string `yaml:"username,omitempty"` 11 Password string `yaml:"password,omitempty"` 12 Org string `yaml:"org,omitempty"` 13 Space string `yaml:"space,omitempty"` 14 15 App string `yaml:"app,omitempty"` 16 } 17 18 func (cf *CloudFoundry) Write(f *buildfile.Buildfile) { 19 downloadCmd := "curl -sLO http://go-cli.s3-website-us-east-1.amazonaws.com/releases/latest/cf-cli_amd64.deb" 20 installCmd := "dpkg -i cf-cli_amd64.deb 1> /dev/null 2> /dev/null" 21 22 // download and install the cf tool 23 f.WriteCmdSilent(fmt.Sprintf("[ -f /usr/bin/sudo ] && sudo %s || %s", downloadCmd, downloadCmd)) 24 f.WriteCmdSilent(fmt.Sprintf("[ -f /usr/bin/sudo ] && sudo %s || %s", installCmd, installCmd)) 25 26 // login 27 loginCmd := "cf login -a %s -u %s -p %s" 28 29 organization := cf.Org 30 if organization != "" { 31 loginCmd += fmt.Sprintf(" -o %s", organization) 32 } 33 34 space := cf.Space 35 if space != "" { 36 loginCmd += fmt.Sprintf(" -s %s", space) 37 } 38 39 f.WriteCmdSilent(fmt.Sprintf(loginCmd, cf.Target, cf.Username, cf.Password)) 40 41 // push app 42 pushCmd := "cf push %s" 43 f.WriteCmd(fmt.Sprintf(pushCmd, cf.App)) 44 }