mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-24 01:10:31 +00:00
make space and organization optional
This commit is contained in:
parent
a0fce08fc3
commit
25f167b34a
2 changed files with 64 additions and 43 deletions
|
@ -17,19 +17,19 @@ type CloudFoundry struct {
|
||||||
|
|
||||||
func (cf *CloudFoundry) Write(f *buildfile.Buildfile) {
|
func (cf *CloudFoundry) Write(f *buildfile.Buildfile) {
|
||||||
// login
|
// login
|
||||||
loginCmd := "cf login -a %s -u %s -p %s -o %s -s %s"
|
loginCmd := "cf login -a %s -u %s -p %s"
|
||||||
|
|
||||||
organization := cf.Org
|
organization := cf.Org
|
||||||
if organization == "" {
|
if organization != "" {
|
||||||
organization = cf.Username
|
loginCmd += fmt.Sprintf(" -o %s", organization)
|
||||||
}
|
}
|
||||||
|
|
||||||
space := cf.Space
|
space := cf.Space
|
||||||
if space == "" {
|
if space != "" {
|
||||||
space = "dev"
|
loginCmd += fmt.Sprintf(" -s %s", space)
|
||||||
}
|
}
|
||||||
|
|
||||||
f.WriteCmdSilent(fmt.Sprintf(loginCmd, cf.Target, cf.Username, cf.Password, organization, space))
|
f.WriteCmdSilent(fmt.Sprintf(loginCmd, cf.Target, cf.Username, cf.Password))
|
||||||
|
|
||||||
// push app
|
// push app
|
||||||
pushCmd := "cf push %s"
|
pushCmd := "cf push %s"
|
||||||
|
|
|
@ -31,6 +31,16 @@ deploy:
|
||||||
org: custom-org
|
org: custom-org
|
||||||
`
|
`
|
||||||
|
|
||||||
|
var sampleYmlWithSpace = `
|
||||||
|
deploy:
|
||||||
|
cloudfoundry:
|
||||||
|
target: https://api.example.com
|
||||||
|
username: foo
|
||||||
|
password: bar
|
||||||
|
org: custom-org
|
||||||
|
space: dev
|
||||||
|
`
|
||||||
|
|
||||||
var sampleYmlWithAppName = `
|
var sampleYmlWithAppName = `
|
||||||
deploy:
|
deploy:
|
||||||
cloudfoundry:
|
cloudfoundry:
|
||||||
|
@ -57,8 +67,8 @@ func TestCloudFoundryDeployment(t *testing.T) {
|
||||||
t.Fatalf("Can't unmarshal deploy script: %s", err)
|
t.Fatalf("Can't unmarshal deploy script: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(bscr, "cf login -a https://api.example.com -u foo -p bar -o foo -s dev") {
|
if !strings.Contains(bscr, "cf login -a https://api.example.com -u foo -p bar") {
|
||||||
t.Error("Expect login script to contains default space")
|
t.Error("Expect login script to contains username and password")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.Contains(bscr, "cf push") {
|
if !strings.Contains(bscr, "cf push") {
|
||||||
|
@ -77,6 +87,17 @@ func TestCloudFoundryDeploymentWithOrg(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCloudFoundryDeploymentWithSpace(t *testing.T) {
|
||||||
|
bscr, err := setUpWithCF(sampleYmlWithSpace)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Can't unmarshal deploy script: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(bscr, "cf login -a https://api.example.com -u foo -p bar -o custom-org -s dev") {
|
||||||
|
t.Error("Expect login script to contains space")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCloudFoundryDeploymentWithApp(t *testing.T) {
|
func TestCloudFoundryDeploymentWithApp(t *testing.T) {
|
||||||
bscr, err := setUpWithCF(sampleYmlWithAppName)
|
bscr, err := setUpWithCF(sampleYmlWithAppName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue