1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-18 08:26:45 +02:00
woodpecker/pkg/plugin/deploy/cloudfoundry.go

45 lines
1.3 KiB
Go
Raw Normal View History

2014-02-07 13:10:01 +03:00
package deploy
import (
2014-03-29 23:09:16 +03:00
"fmt"
"github.com/drone/drone/pkg/build/buildfile"
2014-02-07 13:10:01 +03:00
)
type CloudFoundry struct {
2014-03-29 23:09:16 +03: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 13:10:01 +03:00
}
2014-03-29 23:09:16 +03:00
func (cf *CloudFoundry) Write(f *buildfile.Buildfile) {
downloadCmd := "curl -sLO http://go-cli.s3-website-us-east-1.amazonaws.com/releases/latest/cf-cli_amd64.deb"
installCmd := "dpkg -i cf-cli_amd64.deb 1> /dev/null 2> /dev/null"
// download and install the cf tool
f.WriteCmdSilent(fmt.Sprintf("[ -f /usr/bin/sudo ] && sudo %s || %s", downloadCmd, downloadCmd))
f.WriteCmdSilent(fmt.Sprintf("[ -f /usr/bin/sudo ] && sudo %s || %s", installCmd, installCmd))
2014-03-29 23:09:16 +03:00
// login
2014-04-20 17:35:50 +03:00
loginCmd := "cf login -a %s -u %s -p %s"
2014-03-29 23:09:16 +03:00
organization := cf.Org
2014-04-20 17:35:50 +03:00
if organization != "" {
loginCmd += fmt.Sprintf(" -o %s", organization)
2014-03-29 23:09:16 +03:00
}
space := cf.Space
2014-04-20 17:35:50 +03:00
if space != "" {
loginCmd += fmt.Sprintf(" -s %s", space)
2014-03-29 23:09:16 +03:00
}
2014-04-20 17:35:50 +03:00
f.WriteCmdSilent(fmt.Sprintf(loginCmd, cf.Target, cf.Username, cf.Password))
2014-02-07 13:10:01 +03:00
2014-03-29 23:09:16 +03:00
// push app
pushCmd := "cf push %s"
f.WriteCmd(fmt.Sprintf(pushCmd, cf.App))
2014-02-07 13:10:01 +03:00
}