Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove HA zones for azure lite plan #1697

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions internal/broker/plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,9 @@ func AzureLiteSchema(machineTypesDisplay, regionsDisplay map[string]string, mach

if enableAdditionalWorkerNodePools {
properties.AdditionalWorkerNodePools.Items.Properties.HAZones = nil
properties.AdditionalWorkerNodePools.Items.ControlsOrder = removeString(properties.AdditionalWorkerNodePools.Items.ControlsOrder, "haZones")
properties.AdditionalWorkerNodePools.Items.Required = removeString(properties.AdditionalWorkerNodePools.Items.Required, "haZones")

properties.AdditionalWorkerNodePools.Items.Properties.AutoScalerMin.Default = 2
properties.AdditionalWorkerNodePools.Items.Properties.AutoScalerMax.Default = 10
properties.AdditionalWorkerNodePools.Items.Properties.AutoScalerMax.Maximum = 40
Expand Down Expand Up @@ -676,3 +679,13 @@ func filter(items *[]interface{}, included map[string]interface{}) interface{} {

return output
}

func removeString(slice []string, str string) []string {
result := []string{}
for _, v := range slice {
if v != str {
result = append(result, v)
}
}
return result
}
22 changes: 22 additions & 0 deletions internal/broker/plans_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,25 @@ func readJsonFile(t *testing.T, file string) string {

return string(jsonFile)
}

func TestRemoveString(t *testing.T) {
tests := []struct {
name string
input []string
remove string
expected []string
}{
{"Remove existing element", []string{"alpha", "beta", "gamma"}, "beta", []string{"alpha", "gamma"}},
{"Remove non-existing element", []string{"alpha", "beta", "gamma"}, "delta", []string{"alpha", "beta", "gamma"}},
{"Remove from empty slice", []string{}, "alpha", []string{}},
{"Remove all occurrences", []string{"alpha", "alpha", "beta"}, "alpha", []string{"beta"}},
{"Remove only element", []string{"alpha"}, "alpha", []string{}},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := removeString(tt.input, tt.remove)
assert.Equal(t, tt.expected, result)
})
}
}
Loading