Skip to content

Commit

Permalink
rename domain flag to --domain
Browse files Browse the repository at this point in the history
[#135540463]
  • Loading branch information
Kevin Kelani committed Jan 13, 2017
1 parent af8fb98 commit 6ef6129
Show file tree
Hide file tree
Showing 15 changed files with 101 additions and 101 deletions.
10 changes: 5 additions & 5 deletions bbl/gcp_load_balancers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,14 @@ var _ = Describe("load balancers", func() {
Expect(err).NotTo(HaveOccurred())
})

It("creates and attaches a cf lb type and dns when -d is provided", func() {
It("creates and attaches a cf lb type and ns when domain is provided", func() {
args := []string{
"--state-dir", tempDirectory,
"create-lbs",
"--type", "cf",
"--cert", certPath,
"--key", keyPath,
"-d", "cf.example.com",
"--domain", "cf.example.com",
}

executeCommand(args, 0)
Expand All @@ -185,10 +185,10 @@ var _ = Describe("load balancers", func() {
Expect(state.LB.Type).To(Equal("cf"))
Expect(state.LB.Cert).To(Equal("cert-contents"))
Expect(state.LB.Key).To(Equal("key-contents"))
Expect(state.LB.SystemDomain).To(Equal("cf.example.com"))
Expect(state.LB.Domain).To(Equal("cf.example.com"))
})

It("creates and attaches only a cf lb type when -d is not provided", func() {
It("creates and attaches only a cf lb type when domain is not provided", func() {
args := []string{
"--state-dir", tempDirectory,
"create-lbs",
Expand All @@ -206,7 +206,7 @@ var _ = Describe("load balancers", func() {
Expect(state.LB.Type).To(Equal("cf"))
Expect(state.LB.Cert).To(Equal("cert-contents"))
Expect(state.LB.Key).To(Equal("key-contents"))
Expect(state.LB.SystemDomain).To(Equal(""))
Expect(state.LB.Domain).To(Equal(""))
})
})

Expand Down
6 changes: 3 additions & 3 deletions commands/create_lbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type lbConfig struct {
certPath string
keyPath string
chainPath string
systemDomain string
domain string
skipIfExists bool
}

Expand Down Expand Up @@ -54,7 +54,7 @@ func (c CreateLBs) Execute(args []string, state storage.State) error {
LBType: config.lbType,
CertPath: config.certPath,
KeyPath: config.keyPath,
SystemDomain: config.systemDomain,
Domain: config.domain,
SkipIfExists: config.skipIfExists,
}, state); err != nil {
return err
Expand Down Expand Up @@ -82,7 +82,7 @@ func (CreateLBs) parseFlags(subcommandFlags []string) (lbConfig, error) {
lbFlags.String(&config.certPath, "cert", "")
lbFlags.String(&config.keyPath, "key", "")
lbFlags.String(&config.chainPath, "chain", "")
lbFlags.String(&config.systemDomain, "d", "")
lbFlags.String(&config.domain, "domain", "")
lbFlags.Bool(&config.skipIfExists, "skip-if-exists", "", false)

if err := lbFlags.Parse(subcommandFlags); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions commands/create_lbs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var _ = Describe("create-lbs", func() {
"--type", "cf",
"--cert", "my-cert",
"--key", "my-key",
"-d", "some-system-domain",
"--domain", "some-domain",
"--skip-if-exists",
}, storage.State{
IAAS: "gcp",
Expand All @@ -57,7 +57,7 @@ var _ = Describe("create-lbs", func() {
LBType: "cf",
CertPath: "my-cert",
KeyPath: "my-key",
SystemDomain: "some-system-domain",
Domain: "some-domain",
SkipIfExists: true,
}))
})
Expand Down
8 changes: 4 additions & 4 deletions commands/gcp_create_lbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type GCPCreateLBsConfig struct {
LBType string
CertPath string
KeyPath string
SystemDomain string
Domain string
SkipIfExists bool
}

Expand Down Expand Up @@ -69,7 +69,7 @@ func (c GCPCreateLBs) Execute(config GCPCreateLBsConfig, state storage.State) er
case "cf":
terraformCFLBBackendService := generateBackendServiceTerraform(len(zones))
instanceGroups := generateInstanceGroups(zones)
if config.SystemDomain != "" {
if config.Domain != "" {
lbTemplate = strings.Join([]string{terraformCFLBTemplate, instanceGroups, terraformCFLBBackendService, terraformCFDNSTemplate}, "\n")
} else {
lbTemplate = strings.Join([]string{terraformCFLBTemplate, instanceGroups, terraformCFLBBackendService}, "\n")
Expand All @@ -88,7 +88,7 @@ func (c GCPCreateLBs) Execute(config GCPCreateLBsConfig, state storage.State) er

templateWithLB := strings.Join([]string{terraformVarsTemplate, terraformBOSHDirectorTemplate, lbTemplate}, "\n")
tfState, err := c.terraformExecutor.Apply(state.GCP.ServiceAccountKey, state.EnvID, state.GCP.ProjectID, state.GCP.Zone,
state.GCP.Region, string(cert), string(key), config.SystemDomain, templateWithLB, state.TFState)
state.GCP.Region, string(cert), string(key), config.Domain, templateWithLB, state.TFState)
switch err.(type) {
case terraform.TerraformApplyError:
taError := err.(terraform.TerraformApplyError)
Expand Down Expand Up @@ -181,7 +181,7 @@ func (c GCPCreateLBs) Execute(config GCPCreateLBsConfig, state storage.State) er
if config.LBType == "cf" {
state.LB.Cert = string(cert)
state.LB.Key = string(key)
state.LB.SystemDomain = config.SystemDomain
state.LB.Domain = config.Domain
}

if err := c.stateStore.Set(state); err != nil {
Expand Down
12 changes: 6 additions & 6 deletions commands/gcp_create_lbs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,10 @@ var _ = Describe("GCPCreateLBs", func() {
zones.GetCall.Returns.Zones = []string{"some-zone", "some-other-zone"}

err := command.Execute(commands.GCPCreateLBsConfig{
LBType: "cf",
CertPath: certPath,
KeyPath: keyPath,
SystemDomain: "some-system-domain",
LBType: "cf",
CertPath: certPath,
KeyPath: keyPath,
Domain: "some-domain",
}, storage.State{
IAAS: "gcp",
EnvID: "some-env-id",
Expand All @@ -668,7 +668,7 @@ var _ = Describe("GCPCreateLBs", func() {
Expect(terraformExecutor.ApplyCall.Receives.Region).To(Equal("some-region"))
Expect(terraformExecutor.ApplyCall.Receives.Cert).To(Equal(certificate))
Expect(terraformExecutor.ApplyCall.Receives.Key).To(Equal(key))
Expect(terraformExecutor.ApplyCall.Receives.SystemDomain).To(Equal("some-system-domain"))
Expect(terraformExecutor.ApplyCall.Receives.Domain).To(Equal("some-domain"))
Expect(terraformExecutor.ApplyCall.Receives.Template).To(Equal(strings.Join([]string{expectedCFTemplate, dnsTemplate}, "\n")))

Expect(terraformExecutor.ApplyCall.Receives.TFState).To(Equal("some-prev-tf-state"))
Expand Down Expand Up @@ -703,7 +703,7 @@ var _ = Describe("GCPCreateLBs", func() {
Expect(terraformExecutor.ApplyCall.Receives.Region).To(Equal("some-region"))
Expect(terraformExecutor.ApplyCall.Receives.Cert).To(Equal(certificate))
Expect(terraformExecutor.ApplyCall.Receives.Key).To(Equal(key))
Expect(terraformExecutor.ApplyCall.Receives.SystemDomain).To(Equal(""))
Expect(terraformExecutor.ApplyCall.Receives.Domain).To(Equal(""))
Expect(terraformExecutor.ApplyCall.Receives.Template).To(Equal(expectedCFTemplate))
Expect(terraformExecutor.ApplyCall.Receives.TFState).To(Equal("some-prev-tf-state"))
})
Expand Down
4 changes: 2 additions & 2 deletions commands/gcp_up.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type gcpProvider interface {
}

type terraformExecutor interface {
Apply(credentials, envID, projectID, zone, region, certPath, keyPath, systemDomain, template, tfState string) (string, error)
Apply(credentials, envID, projectID, zone, region, certPath, keyPath, domain, template, tfState string) (string, error)
Destroy(serviceAccountKey, envID, projectID, zone, region, template, tfState string) (string, error)
}

Expand Down Expand Up @@ -141,7 +141,7 @@ func (u GCPUp) Execute(upConfig GCPUpConfig, state storage.State) error {
}

tfState, err := u.terraformExecutor.Apply(state.GCP.ServiceAccountKey,
state.EnvID, state.GCP.ProjectID, state.GCP.Zone, state.GCP.Region, state.LB.Cert, state.LB.Key, state.LB.SystemDomain,
state.EnvID, state.GCP.ProjectID, state.GCP.Zone, state.GCP.Region, state.LB.Cert, state.LB.Key, state.LB.Domain,
template, state.TFState,
)
switch err.(type) {
Expand Down
12 changes: 6 additions & 6 deletions commands/gcp_up_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,10 @@ var _ = Describe("gcp up", func() {
Region: "some-region",
}, storage.State{
LB: storage.LB{
Type: "cf",
Cert: "some-cert",
Key: "some-key",
SystemDomain: "some-system-domain",
Type: "cf",
Cert: "some-cert",
Key: "some-key",
Domain: "some-domain",
},
})
Expect(err).NotTo(HaveOccurred())
Expand All @@ -630,7 +630,7 @@ var _ = Describe("gcp up", func() {
Expect(terraformExecutor.ApplyCall.Receives.Template).To(Equal(expectedCFTemplate))
Expect(terraformExecutor.ApplyCall.Receives.Cert).To(Equal("some-cert"))
Expect(terraformExecutor.ApplyCall.Receives.Key).To(Equal("some-key"))
Expect(terraformExecutor.ApplyCall.Receives.SystemDomain).To(Equal("some-system-domain"))
Expect(terraformExecutor.ApplyCall.Receives.Domain).To(Equal("some-domain"))
})

It("applies the correct concourse template and args for concourse lb type", func() {
Expand All @@ -650,7 +650,7 @@ var _ = Describe("gcp up", func() {
Expect(terraformExecutor.ApplyCall.Receives.Template).To(Equal(expectedConcourseTemplate))
Expect(terraformExecutor.ApplyCall.Receives.Cert).To(Equal(""))
Expect(terraformExecutor.ApplyCall.Receives.Key).To(Equal(""))
Expect(terraformExecutor.ApplyCall.Receives.SystemDomain).To(Equal(""))
Expect(terraformExecutor.ApplyCall.Receives.Domain).To(Equal(""))
})
})

Expand Down
4 changes: 2 additions & 2 deletions commands/gcp_update_lbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func NewGCPUpdateLBs(gcpCreateLBs gcpCreateLBs) GCPUpdateLBs {
}

func (g GCPUpdateLBs) Execute(config GCPCreateLBsConfig, state storage.State) error {
if config.SystemDomain == "" {
config.SystemDomain = state.LB.SystemDomain
if config.Domain == "" {
config.Domain = state.LB.Domain
}

return g.gcpCreateLBs.Execute(config, state)
Expand Down
40 changes: 20 additions & 20 deletions commands/gcp_update_lbs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,52 @@ var _ = Describe("GCP Update LBs", func() {
state = storage.State{
IAAS: "gcp",
LB: storage.LB{
Type: "cf",
Cert: "some-cert",
Key: "some-key",
SystemDomain: "some-system-domain",
Type: "cf",
Cert: "some-cert",
Key: "some-key",
Domain: "some-domain",
},
}
})

Describe("Execute", func() {
It("calls out to GCP Create LBs", func() {
config := commands.GCPCreateLBsConfig{
CertPath: "some-cert-path",
KeyPath: "some-key-path",
LBType: "cf",
SystemDomain: "some-domain",
CertPath: "some-cert-path",
KeyPath: "some-key-path",
LBType: "cf",
Domain: "some-domain",
}
err := command.Execute(config, state)

Expect(err).NotTo(HaveOccurred())
Expect(gcpCreateLBs.ExecuteCall.CallCount).To(Equal(1))
Expect(gcpCreateLBs.ExecuteCall.Receives.Config).To(Equal(commands.GCPCreateLBsConfig{
CertPath: "some-cert-path",
KeyPath: "some-key-path",
LBType: "cf",
SystemDomain: "some-domain",
CertPath: "some-cert-path",
KeyPath: "some-key-path",
LBType: "cf",
Domain: "some-domain",
}))
Expect(gcpCreateLBs.ExecuteCall.Receives.State).To(Equal(state))
})

Context("when config does not contain system domain", func() {
It("passes system domain from the state", func() {
config := commands.GCPCreateLBsConfig{
CertPath: "some-cert-path",
KeyPath: "some-key-path",
LBType: "cf",
SystemDomain: "",
CertPath: "some-cert-path",
KeyPath: "some-key-path",
LBType: "cf",
Domain: "",
}
err := command.Execute(config, state)

Expect(err).NotTo(HaveOccurred())
Expect(gcpCreateLBs.ExecuteCall.CallCount).To(Equal(1))
Expect(gcpCreateLBs.ExecuteCall.Receives.Config).To(Equal(commands.GCPCreateLBsConfig{
CertPath: "some-cert-path",
KeyPath: "some-key-path",
LBType: "cf",
SystemDomain: "some-system-domain",
CertPath: "some-cert-path",
KeyPath: "some-key-path",
LBType: "cf",
Domain: "some-domain",
}))
Expect(gcpCreateLBs.ExecuteCall.Receives.State).To(Equal(state))
})
Expand Down
12 changes: 6 additions & 6 deletions commands/update_lbs.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type updateLBConfig struct {
certPath string
keyPath string
chainPath string
systemDomain string
domain string
skipIfMissing bool
}

Expand Down Expand Up @@ -72,10 +72,10 @@ func (c UpdateLBs) Execute(subcommandFlags []string, state storage.State) error
switch state.IAAS {
case "gcp":
if err := c.gcpUpdateLBs.Execute(GCPCreateLBsConfig{
LBType: state.LB.Type,
CertPath: config.certPath,
KeyPath: config.keyPath,
SystemDomain: config.systemDomain,
LBType: state.LB.Type,
CertPath: config.certPath,
KeyPath: config.keyPath,
Domain: config.domain,
}, state); err != nil {
return err
}
Expand All @@ -99,7 +99,7 @@ func (UpdateLBs) parseFlags(subcommandFlags []string) (updateLBConfig, error) {
lbFlags.String(&config.certPath, "cert", "")
lbFlags.String(&config.keyPath, "key", "")
lbFlags.String(&config.chainPath, "chain", "")
lbFlags.String(&config.systemDomain, "d", "")
lbFlags.String(&config.domain, "domain", "")
lbFlags.Bool(&config.skipIfMissing, "skip-if-missing", "", false)

err := lbFlags.Parse(subcommandFlags)
Expand Down
10 changes: 5 additions & 5 deletions commands/update_lbs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ var _ = Describe("Update LBs", func() {
err := command.Execute([]string{
"--cert", "my-cert",
"--key", "my-key",
"-d", "some-system-domain",
"--domain", "some-domain",
}, storage.State{
IAAS: "gcp",
LB: storage.LB{
Expand All @@ -75,10 +75,10 @@ var _ = Describe("Update LBs", func() {
})
Expect(err).NotTo(HaveOccurred())
Expect(gcpUpdateLBs.ExecuteCall.Receives.Config).To(Equal(commands.GCPCreateLBsConfig{
LBType: "cf",
CertPath: "my-cert",
KeyPath: "my-key",
SystemDomain: "some-system-domain",
LBType: "cf",
CertPath: "my-cert",
KeyPath: "my-key",
Domain: "some-domain",
}))
})

Expand Down
24 changes: 12 additions & 12 deletions fakes/terraform_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ type TerraformExecutor struct {
ApplyCall struct {
CallCount int
Receives struct {
Credentials string
EnvID string
ProjectID string
Zone string
Region string
Cert string
Key string
SystemDomain string
Template string
TFState string
Credentials string
EnvID string
ProjectID string
Zone string
Region string
Cert string
Key string
Domain string
Template string
TFState string
}
Returns struct {
TFState string
Expand All @@ -38,7 +38,7 @@ type TerraformExecutor struct {
}
}

func (t *TerraformExecutor) Apply(credentials, envID, projectID, zone, region, cert, key, systemDomain, template, tfState string) (string, error) {
func (t *TerraformExecutor) Apply(credentials, envID, projectID, zone, region, cert, key, domain, template, tfState string) (string, error) {
t.ApplyCall.CallCount++
t.ApplyCall.Receives.Credentials = credentials
t.ApplyCall.Receives.EnvID = envID
Expand All @@ -47,7 +47,7 @@ func (t *TerraformExecutor) Apply(credentials, envID, projectID, zone, region, c
t.ApplyCall.Receives.Region = region
t.ApplyCall.Receives.Cert = cert
t.ApplyCall.Receives.Key = key
t.ApplyCall.Receives.SystemDomain = systemDomain
t.ApplyCall.Receives.Domain = domain
t.ApplyCall.Receives.Template = template
t.ApplyCall.Receives.TFState = tfState
return t.ApplyCall.Returns.TFState, t.ApplyCall.Returns.Error
Expand Down
Loading

0 comments on commit 6ef6129

Please sign in to comment.