diff --git a/pkg/controller/servicecatalog/provisionedproduct/setup_test.go b/pkg/controller/servicecatalog/provisionedproduct/setup_test.go index 5597a67115..6e7aaaf629 100644 --- a/pkg/controller/servicecatalog/provisionedproduct/setup_test.go +++ b/pkg/controller/servicecatalog/provisionedproduct/setup_test.go @@ -105,6 +105,7 @@ func TestIsUpToDate(t *testing.T) { provisioningArtifactName := provisioningArtifactName productID := productID newProductID := newProductID + type want struct { result bool err error @@ -474,6 +475,54 @@ func TestIsUpToDate(t *testing.T) { err: nil, }, }, + "ParametersSequenceAreChanged": { + args: args{ + provisionedProduct: provisionedProduct([]provisionedProductModifier{ + withSpec(v1alpha1.ProvisionedProductParameters{ + ProvisioningArtifactID: aws.String(provisioningArtifactID), + ProvisioningParameters: []*v1alpha1.ProvisioningParameter{ + {Key: aws.String("Parameter1"), Value: aws.String("foo")}, + {Key: aws.String("Parameter2"), Value: aws.String("bar")}, + }, + }), + }...), + describeProvisionedProductOutput: describeProvisionedProduct([]describeProvisionedProductOutputModifier{ + withDetails(svcsdk.ProvisionedProductDetail{ + Id: aws.String("pp-fake"), + ProvisioningArtifactId: aws.String(provisioningArtifactID), + }), + }...), + customClient: &fake.MockCustomServiceCatalogClient{ + MockGetCloudformationStackParameters: func(provisionedProductOutputs []*svcsdk.RecordOutput) ([]cfsdkv2types.Parameter, error) { + return []cfsdkv2types.Parameter{ + {ParameterKey: aws.String("Parameter2"), ParameterValue: aws.String("bar")}, + {ParameterKey: aws.String("Parameter1"), ParameterValue: aws.String("foo")}, + }, + nil + }, + MockGetProvisionedProductOutputs: func(getPPInput *svcsdk.GetProvisionedProductOutputsInput) (*svcsdk.GetProvisionedProductOutputsOutput, error) { + return &svcsdk.GetProvisionedProductOutputsOutput{}, nil + }, + MockDescribeProduct: func(dpInput *svcsdk.DescribeProductInput) (*svcsdk.DescribeProductOutput, error) { + return &svcsdk.DescribeProductOutput{ + ProductViewSummary: &svcsdk.ProductViewSummary{ + ProductId: dpInput.Id, + Name: aws.String("fake product"), + }, + ProvisioningArtifacts: []*svcsdk.ProvisioningArtifact{ + { + Id: aws.String(provisioningArtifactID), + }, + }, + }, nil + }, + }, + }, + want: want{ + result: false, + err: nil, + }, + }, } for name, tc := range cases { t.Run(name, func(t *testing.T) { diff --git a/pkg/controller/servicecatalog/provisionedproduct/utils.go b/pkg/controller/servicecatalog/provisionedproduct/utils.go index af6c90fc70..48754172e6 100644 --- a/pkg/controller/servicecatalog/provisionedproduct/utils.go +++ b/pkg/controller/servicecatalog/provisionedproduct/utils.go @@ -21,15 +21,9 @@ func provisioningParamsAreChanged(cfStackParams []cfsdkv2types.Parameter, curren return true } - cfStackKeyValue := make(map[string]string) - for _, v := range cfStackParams { - cfStackKeyValue[*v.ParameterKey] = pointer.StringDeref(v.ParameterValue, "") - } - - for _, v := range currentParams { - if cfv, ok := cfStackKeyValue[*v.Key]; ok && pointer.StringEqual(&cfv, v.Value) { - continue - } else { + for i, v := range cfStackParams { + if pointer.StringDeref(currentParams[i].Key, "") != pointer.StringDeref(v.ParameterKey, "") || + pointer.StringDeref(currentParams[i].Value, "") != pointer.StringDeref(v.ParameterValue, "") { return true } }