Skip to content

Commit

Permalink
Add ShowMaxZones parameter to deployment-template API. (#462)
Browse files Browse the repository at this point in the history
With this parameter set, the `max_zones` field in the ICs is filled.
  • Loading branch information
gigerdo authored Apr 10, 2024
1 parent 44b0587 commit 28f79d1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .changelog/1.17.0/462.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
category: enhancement
title: Add `show_max_zones` parameter for deployment-templates API.
description: |
This parameter adds the `max_zones` field to each instance-configuration. (Left empty by default).
4 changes: 3 additions & 1 deletion pkg/api/deploymentapi/deptemplateapi/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type GetParams struct {
StackVersion string

HideInstanceConfigurations bool
ShowMaxZones bool
}

// Validate ensures the parameters are usable by Get.
Expand Down Expand Up @@ -89,7 +90,8 @@ func getParams(params GetParams) *deployment_templates.GetDeploymentTemplateV2Pa
var apiParams = deployment_templates.NewGetDeploymentTemplateV2Params().
WithShowInstanceConfigurations(ec.Bool(!params.HideInstanceConfigurations)).
WithRegion(params.Region).
WithTemplateID(params.TemplateID)
WithTemplateID(params.TemplateID).
WithShowMaxZones(ec.Bool(params.ShowMaxZones))

if params.StackVersion != "" {
apiParams.SetStackVersion(&params.StackVersion)
Expand Down
8 changes: 6 additions & 2 deletions pkg/api/deploymentapi/deptemplateapi/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ func TestGet(t *testing.T) {
{
name: "succeeds",
args: args{params: GetParams{
Region: "us-east-1",
TemplateID: "default",
Region: "us-east-1",
TemplateID: "default",
ShowMaxZones: true,
API: api.NewMock(mock.New200ResponseAssertion(
&mock.RequestAssertion{
Header: api.DefaultReadMockHeaders,
Expand All @@ -84,6 +85,7 @@ func TestGet(t *testing.T) {
Query: url.Values{
"region": []string{"us-east-1"},
"show_instance_configurations": []string{"true"},
"show_max_zones": []string{"true"},
},
},
mock.NewByteBody(getRawResp),
Expand All @@ -107,6 +109,7 @@ func TestGet(t *testing.T) {
"region": []string{"us-east-1"},
"show_instance_configurations": []string{"true"},
"stack_version": []string{"6.8.0"},
"show_max_zones": []string{"false"},
},
},
mock.NewByteBody(getRawResp),
Expand All @@ -128,6 +131,7 @@ func TestGet(t *testing.T) {
Query: url.Values{
"region": []string{"us-east-1"},
"show_instance_configurations": []string{"true"},
"show_max_zones": []string{"false"},
},
},
mock.SampleInternalError().Response.Body,
Expand Down
4 changes: 3 additions & 1 deletion pkg/api/deploymentapi/deptemplateapi/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type ListParams struct {

ShowHidden bool
HideInstanceConfigurations bool
ShowMaxZones bool
}

// Validate ensures the parameters are usable by List.
Expand Down Expand Up @@ -90,7 +91,8 @@ func listParams(params ListParams) *deployment_templates.GetDeploymentTemplatesV
var apiParams = deployment_templates.NewGetDeploymentTemplatesV2Params().
WithShowInstanceConfigurations(ec.Bool(!params.HideInstanceConfigurations)).
WithShowHidden(&params.ShowHidden).
WithRegion(params.Region)
WithRegion(params.Region).
WithShowMaxZones(ec.Bool(params.ShowMaxZones))

if params.MetadataFilter != "" {
apiParams.SetMetadata(&params.MetadataFilter)
Expand Down
7 changes: 6 additions & 1 deletion pkg/api/deploymentapi/deptemplateapi/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ func TestList(t *testing.T) {
{
name: "succeeds",
args: args{params: ListParams{
Region: "us-east-1",
Region: "us-east-1",
ShowMaxZones: true,
API: api.NewMock(mock.New200ResponseAssertion(
&mock.RequestAssertion{
Header: api.DefaultReadMockHeaders,
Expand All @@ -83,6 +84,7 @@ func TestList(t *testing.T) {
"region": []string{"us-east-1"},
"show_instance_configurations": []string{"true"},
"show_hidden": []string{"false"},
"show_max_zones": []string{"true"},
},
},
mock.NewByteBody(listRawResp),
Expand All @@ -106,6 +108,7 @@ func TestList(t *testing.T) {
"region": []string{"us-east-1"},
"show_instance_configurations": []string{"true"},
"show_hidden": []string{"false"},
"show_max_zones": []string{"false"},
},
},
mock.NewByteBody(listRawResp),
Expand All @@ -131,6 +134,7 @@ func TestList(t *testing.T) {
"show_instance_configurations": []string{"true"},
"show_hidden": []string{"false"},
"stack_version": []string{"6.2.1"},
"show_max_zones": []string{"false"},
},
},
mock.NewByteBody(listRawResp),
Expand All @@ -152,6 +156,7 @@ func TestList(t *testing.T) {
"region": []string{"us-east-1"},
"show_instance_configurations": []string{"true"},
"show_hidden": []string{"false"},
"show_max_zones": []string{"false"},
},
},
mock.SampleInternalError().Response.Body,
Expand Down

0 comments on commit 28f79d1

Please sign in to comment.