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

Handle collections containing secrets when finding existing property GUIDs #505

Merged

Conversation

mrdavidlaing
Copy link

Addresses one of the known issues for collection GUID assignment addressed in #207:

@cf-gitbot
Copy link
Member

We have created an issue in Pivotal Tracker to manage this. Unfortunately, the Pivotal Tracker project is private so you may be unable to view the contents of the story.

The labels on this github issue will be updated when the story is started.

@@ -137,12 +156,20 @@ func (existingCollection responsePropertyCollection) findGUIDForEquivalentlItem(
return "", false
}

func associateExistingCollectionGUIDs(updatedProperty interface{}, existingProperty ResponseProperty) error {
updatedCollection, err := parseUpdatedPropertyCollection(updatedProperty)
type associateExistingCollectionGUIDsInput struct {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the changes are a result of this refactoring, implemented to make passing the properties needed to enable func parseResponsePropertyCollection() to make a Api.GetDeployedProductCredential() call to fetch the existing secret values

Comment on lines +96 to +113
for collectionItemKey, collectionItemObj := range itemMap {
collectionItemObjAsMap := collectionItemObj.(map[interface{}]interface{})
isCredential := collectionItemObjAsMap["credential"].(bool)
if !isCredential {
continue
}

credentialName := fmt.Sprintf("%s[%d].%s", input.PropertyName, index, collectionItemKey)
apiOutput, err := input.APIService.GetDeployedProductCredential(GetDeployedProductCredentialInput{
DeployedGUID: input.ProductGUID,
CredentialReference: credentialName,
})
if err != nil {
return nil, err
}

collectionItemObjAsMap["value"] = apiOutput.Credential.Value
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the new logic is here

Copy link
Author

@mrdavidlaing mrdavidlaing Aug 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetching the credential values like this increases the HTTP requests made by

om configure-product  --config example-product.config.yml

from 40 to 60

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it going to be 60 requests every time, or just for collection objects?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not too worried about the time addition

@kcboyle
Copy link
Contributor

kcboyle commented Aug 27, 2020

It looks like there's a merge conflict in api/staged_products_property_collection_guid_assigner_test.go.go (and it also has the .go extension twice, which seems weird). Other than that, LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants