From 58f67d02624e7e9aff40bd592c19aff41edcc95d Mon Sep 17 00:00:00 2001 From: David Laing Date: Thu, 27 Aug 2020 14:46:52 +0100 Subject: [PATCH] associateExistingCollectionGUIDs ignores non-configurable properties --- CHANGELOG.md | 6 +++ ...ducts_property_collection_guid_assigner.go | 4 ++ ...operty_collection_guid_assigner_test.go.go | 38 +++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58b89a77f..82464e3b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,12 @@ can be found in [Pivotal Documentation](docs.pivotal.io/platform-automation). This ensures that commands are not kept in `bash` history. The environment variable `OM_PASSWORD` will overwrite the password value in `env.yml`. +## 6.1.3 + +### Bug Fixes +- `configure-product` will no longer assign a new guid for unnamed collections + - that haven't changed but contain non-configurable properties + ## 6.1.2 ### Bug Fixes diff --git a/api/staged_products_property_collection_guid_assigner.go b/api/staged_products_property_collection_guid_assigner.go index 3c76c2653..617e30f36 100644 --- a/api/staged_products_property_collection_guid_assigner.go +++ b/api/staged_products_property_collection_guid_assigner.go @@ -115,6 +115,10 @@ func (item responsePropertyCollectionItem) getFieldValuesExceptGUID() map[interf if key == "guid" { continue } + isNotConfigurable := !valueObj.(map[interface{}]interface{})["configurable"].(bool) + if isNotConfigurable { + continue + } extractedValues[key] = valueObj.(map[interface{}]interface{})["value"] } diff --git a/api/staged_products_property_collection_guid_assigner_test.go.go b/api/staged_products_property_collection_guid_assigner_test.go.go index c60e61eb0..433270826 100644 --- a/api/staged_products_property_collection_guid_assigner_test.go.go +++ b/api/staged_products_property_collection_guid_assigner_test.go.go @@ -302,5 +302,43 @@ var _ = Describe("ResponsePropertyCollection", func() { Expect(ok).To(BeTrue()) Expect(guid).To(Equal("28bab1d3-4a4b-48d5-8dac-two")) }) + It("ignores non-configurable properties when finding items that are equivalent", func() { + existingCollection, err := parseResponsePropertyCollection(unmarshalJSONLikeApiGetStagedProductProperties(`[ + { + "guid": { + "type": "uuid", + "configurable": false, + "credential": false, + "value": "28bab1d3-4a4b-with-non-configurable-properties", + "optional": false + }, + "non_configurable_property": { + "type": "string", + "configurable": false, + "credential": false, + "value": "this property can't be configured", + "optional": false + }, + "configurable_property": { + "type": "string", + "configurable": true, + "credential": false, + "value": "this property can be configured", + "optional": false + } + } + ]`)) + Expect(err).To(BeNil()) + updatedCollection, err := parseUpdatedPropertyCollection(unmarshalJSON(`{ "value":[ + { + "configurable_property": "this property can be configured" + } + ]}`)) + Expect(err).To(BeNil()) + + guid, ok := existingCollection.findGUIDForEquivalentlItem(updatedCollection[0]) + Expect(ok).To(BeTrue()) + Expect(guid).To(Equal("28bab1d3-4a4b-with-non-configurable-properties")) + }) }) })