Skip to content

Commit

Permalink
Merge pull request #73 from sighupio/hotfix/typo
Browse files Browse the repository at this point in the history
Typo in struct for GKE provider
  • Loading branch information
ralgozino authored May 31, 2022
2 parents 2c44909 + e4183fe commit 3ae4d78
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion internal/cluster/configuration/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type GKE struct {
ControlPlaneCIDR string `yaml:"controlPlaneCIDR"`
AdditionalFirewallRules bool `yaml:"additionalFirewallRules"`
AdditionalClusterFirewallRules bool `yaml:"additionalClusterFirewallRules"`
DisalbeDefaultSNAT bool `yaml:"disalbeDefaultSNAT"`
DisableDefaultSNAT bool `yaml:"disableDefaultSNAT"`

SubNetworks []string `yaml:"subnetworks"`
DMZCIDRRange DMZCIDRRange `yaml:"dmzCIDRRange"`
Expand Down
35 changes: 26 additions & 9 deletions internal/cluster/provisioners/gke/provisioner.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func (e *GKE) UpdateMessage() string {
if err != nil {
log.Error("Can not get `operator_ssh_user` value")
}
return fmt.Sprintf(`[GKE] Fury
return fmt.Sprintf(
`[GKE] Fury
All the cluster components are up to date.
GKE Kubernetes cluster ready.
Expand All @@ -71,7 +72,8 @@ Then access by running:
$ ssh %v@node-name-reported-by-kubectl-get-nodes
`, clusterEndpoint, clusterOperatorName, clusterOperatorName, clusterOperatorName)
`, clusterEndpoint, clusterOperatorName, clusterOperatorName, clusterOperatorName,
)
}

// DestroyMessage return a custom provisioner message the user will see once the cluster is destroyed
Expand Down Expand Up @@ -184,7 +186,9 @@ func (e GKE) createVarFile() (err error) {
fwRuleTags = string(tags)
}

buffer.WriteString(fmt.Sprintf(`{
buffer.WriteString(
fmt.Sprintf(
`{
name = "%v"
direction = "%v"
cidr_block = "%v"
Expand All @@ -193,7 +197,8 @@ func (e GKE) createVarFile() (err error) {
tags = %v
},
`, fwRule.Name, fwRule.Direction, fwRule.CIDRBlock, fwRule.Protocol, fwRule.Ports, fwRuleTags,
))
),
)
}
buffer.WriteString("]\n")
} else {
Expand All @@ -209,13 +214,16 @@ func (e GKE) createVarFile() (err error) {
buffer.WriteString(fmt.Sprintf("gke_master_ipv4_cidr_block = \"%v\"\n", spec.ControlPlaneCIDR))
buffer.WriteString(fmt.Sprintf("gke_add_additional_firewall_rules = %v\n", spec.AdditionalFirewallRules))
buffer.WriteString(fmt.Sprintf("gke_add_cluster_firewall_rules = %v\n", spec.AdditionalClusterFirewallRules))
buffer.WriteString(fmt.Sprintf("gke_disable_default_snat = %v\n", spec.DisalbeDefaultSNAT))
buffer.WriteString(fmt.Sprintf("gke_disable_default_snat = %v\n", spec.DisableDefaultSNAT))

err = ioutil.WriteFile(fmt.Sprintf("%v/gke.tfvars", e.terraform.WorkingDir()), buffer.Bytes(), 0600)
if err != nil {
return err
}
err = e.terraform.FormatWrite(context.Background(), tfexec.Dir(fmt.Sprintf("%v/gke.tfvars", e.terraform.WorkingDir())))
err = e.terraform.FormatWrite(
context.Background(),
tfexec.Dir(fmt.Sprintf("%v/gke.tfvars", e.terraform.WorkingDir())),
)
if err != nil {
return err
}
Expand Down Expand Up @@ -265,7 +273,10 @@ func (e GKE) Plan() (err error) {
return err
}
var changes bool
changes, err = e.terraform.Plan(context.Background(), tfexec.VarFile(fmt.Sprintf("%v/gke.tfvars", e.terraform.WorkingDir())))
changes, err = e.terraform.Plan(
context.Background(),
tfexec.VarFile(fmt.Sprintf("%v/gke.tfvars", e.terraform.WorkingDir())),
)
if err != nil {
log.Fatalf("[DRYRUN] Something went wrong while updating gke. %v", err)
return err
Expand All @@ -291,7 +302,10 @@ func (e GKE) Update() (string, error) {
if err != nil {
return "", err
}
err = e.terraform.Apply(context.Background(), tfexec.VarFile(fmt.Sprintf("%v/gke.tfvars", e.terraform.WorkingDir())))
err = e.terraform.Apply(
context.Background(),
tfexec.VarFile(fmt.Sprintf("%v/gke.tfvars", e.terraform.WorkingDir())),
)
if err != nil {
log.Fatalf("Something went wrong while updating gke. %v", err)
return "", err
Expand All @@ -308,7 +322,10 @@ func (e GKE) Destroy() (err error) {
if err != nil {
return err
}
err = e.terraform.Destroy(context.Background(), tfexec.VarFile(fmt.Sprintf("%v/gke.tfvars", e.terraform.WorkingDir())))
err = e.terraform.Destroy(
context.Background(),
tfexec.VarFile(fmt.Sprintf("%v/gke.tfvars", e.terraform.WorkingDir())),
)
if err != nil {
log.Fatalf("Something went wrong while destroying GKE cluster project. %v", err)
return err
Expand Down
2 changes: 1 addition & 1 deletion internal/configuration/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func clusterParser(config *Configuration) (err error) {
ControlPlaneCIDR: "10.0.0.0/28",
AdditionalFirewallRules: true,
AdditionalClusterFirewallRules: false,
DisalbeDefaultSNAT: false,
DisableDefaultSNAT: false,
}
err = yaml.Unmarshal(specBytes, &gkeSpec)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion internal/configuration/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func clusterTemplate(config *Configuration) error {
ControlPlaneCIDR: "10.0.0.0/28 # OPTIONAL. DEFAULT VALUE. The IP range in CIDR notation to use for the hosted master network",
AdditionalFirewallRules: true,
AdditionalClusterFirewallRules: false,
DisalbeDefaultSNAT: false,
DisableDefaultSNAT: false,
SubNetworks: []string{
"subnet-id0 # Identificator of the subnets. Index 0: Cluster Subnet",
"subnet-id1 # Identificator of the subnets. Index 1: Pod Subnet",
Expand Down

0 comments on commit 3ae4d78

Please sign in to comment.