diff --git a/cfCmdGenerator/cfCmdGenerator.go b/cfCmdGenerator/cfCmdGenerator.go index 1836d30..1bac3b7 100644 --- a/cfCmdGenerator/cfCmdGenerator.go +++ b/cfCmdGenerator/cfCmdGenerator.go @@ -18,6 +18,8 @@ type CfCmdGenerator interface { SetQuota(org, quota string) cmdStartWaiter.CmdStartWaiter CreateOrg(org string) cmdStartWaiter.CmdStartWaiter CreateSpace(org, space string) cmdStartWaiter.CmdStartWaiter + EnableOrgIsolation(org, isolationSegment string) cmdStartWaiter.CmdStartWaiter + SetOrgDefaultIsolationSegment(org, isolationSegment string) cmdStartWaiter.CmdStartWaiter Target(org, space string) cmdStartWaiter.CmdStartWaiter Push(name, path string, instances int, noRoute bool) cmdStartWaiter.CmdStartWaiter Delete(name string) cmdStartWaiter.CmdStartWaiter @@ -98,6 +100,21 @@ func (c *cfCmdGenerator) CreateOrg(org string) cmdStartWaiter.CmdStartWaiter { ) } +func (c *cfCmdGenerator) EnableOrgIsolation(org, isolationSegment string) cmdStartWaiter.CmdStartWaiter { + return c.setCfHome( + exec.Command( + "cf", "enable-org-isolation", org, isolationSegment, + ), + ) +} +func (c *cfCmdGenerator) SetOrgDefaultIsolationSegment(org, isolationSegment string) cmdStartWaiter.CmdStartWaiter { + return c.setCfHome( + exec.Command( + "cf", "set-org-default-isolation-segment", org, isolationSegment, + ), + ) +} + func (c *cfCmdGenerator) CreateSpace(org string, space string) cmdStartWaiter.CmdStartWaiter { return c.setCfHome( exec.Command( diff --git a/cfCmdGenerator/cfCmdGenerator_test.go b/cfCmdGenerator/cfCmdGenerator_test.go index 9f41713..17a83ba 100644 --- a/cfCmdGenerator/cfCmdGenerator_test.go +++ b/cfCmdGenerator/cfCmdGenerator_test.go @@ -211,6 +211,22 @@ var _ = Describe("CfCmdGenerator", func() { expectCommandToBeEquivalent(cmd, expectedCmd, cfHomeEnvVar) }) }) + + Describe("EnableOrgIsolation", func() { + It("Generates the correct command", func() { + expectedCmd := exec.Command("cf", "enable-org-isolation", "someOrg", "someIsoSeg") + cmd := generator.EnableOrgIsolation("someOrg", "someIsoSeg") + expectCommandToBeEquivalent(cmd, expectedCmd, cfHomeEnvVar) + }) + }) + + Describe("SetOrgDefaultIsolationSegment", func() { + It("Generates the correct command", func() { + expectedCmd := exec.Command("cf", "set-org-default-isolation-segment", "someOrg", "someIsoSeg") + cmd := generator.SetOrgDefaultIsolationSegment("someOrg", "someIsoSeg") + expectCommandToBeEquivalent(cmd, expectedCmd, cfHomeEnvVar) + }) + }) }) func expectCommandToBeEquivalent(cmd cmdStartWaiter.CmdStartWaiter, expectedCmd *exec.Cmd, envIncludes ...string) { diff --git a/cfWorkflow/cfWorkflow.go b/cfWorkflow/cfWorkflow.go index 356c86f..aa4eb55 100644 --- a/cfWorkflow/cfWorkflow.go +++ b/cfWorkflow/cfWorkflow.go @@ -81,8 +81,16 @@ func (c *cfWorkflow) Setup(ccg cfCmdGenerator.CfCmdGenerator) []cmdStartWaiter.C ccg.Api(c.cf.API), ccg.Auth(c.cf.AdminUser, c.cf.AdminPassword), ccg.CreateOrg(c.org), - ccg.CreateSpace(c.org, c.space), } + + if c.cf.IsolationSegment != "" { + ret = append(ret, + ccg.EnableOrgIsolation(c.org, c.cf.IsolationSegment), + ccg.SetOrgDefaultIsolationSegment(c.org, c.cf.IsolationSegment), + ) + } + ret = append(ret, ccg.CreateSpace(c.org, c.space)) + if c.quota != "" { ret = append(ret, ccg.CreateQuota(c.quota), ccg.SetQuota(c.org, c.quota)) } diff --git a/cfWorkflow/cfWorkflow_test.go b/cfWorkflow/cfWorkflow_test.go index a107b2d..2ea124e 100644 --- a/cfWorkflow/cfWorkflow_test.go +++ b/cfWorkflow/cfWorkflow_test.go @@ -180,6 +180,25 @@ var _ = Describe("CfWorkflow", func() { )) }) }) + When("Isolation Segments are provided", func() { + BeforeEach(func() { cfc.IsolationSegment = "someIsoSeg" }) + It("returns a series of commands including setting up the isolation segment for the org/space", func() { + cmds := cw.Setup(ccg) + + Expect(cmds).To(Equal( + []cmdStartWaiter.CmdStartWaiter{ + ccg.Api("jigglypuff.cf-app.com"), + ccg.Auth("pika", "chu"), + ccg.CreateOrg("someOrg"), + ccg.EnableOrgIsolation("someOrg", "someIsoSeg"), + ccg.SetOrgDefaultIsolationSegment("someOrg", "someIsoSeg"), + ccg.CreateSpace("someOrg", "someSpace"), + ccg.CreateQuota("someQuota"), + ccg.SetQuota("someOrg", "someQuota"), + }, + )) + }) + }) }) Describe("TearDown", func() { diff --git a/config/config.go b/config/config.go index dcd95e7..bcdaa49 100644 --- a/config/config.go +++ b/config/config.go @@ -19,10 +19,11 @@ type Command struct { } type Cf struct { - API string `json:"api"` - AppDomain string `json:"app_domain"` - AdminUser string `json:"admin_user"` - AdminPassword string `json:"admin_password"` + API string `json:"api"` + AppDomain string `json:"app_domain"` + AdminUser string `json:"admin_user"` + AdminPassword string `json:"admin_password"` + IsolationSegment string `json:"isolation_segment"` TCPDomain string `json:"tcp_domain"` TCPPort int `json:"tcp_port"`