Skip to content

Assign and remove project resources without unnecessary churn (Fixes: #585).#586

Merged
andrewsomething merged 5 commits intomainfrom
asb/issues/585
Feb 18, 2021
Merged

Assign and remove project resources without unnecessary churn (Fixes: #585).#586
andrewsomething merged 5 commits intomainfrom
asb/issues/585

Conversation

@andrewsomething
Copy link
Copy Markdown
Member

The current implementation moves all resources in the old config to the default project and then adds the resources in the new config to the Terraform-managed project. This creates a lot of unnecessary churn.

// The API requires project resources to be reassigned to another project if the association needs to be deleted.
// a diff of the resource could be implemented instead of removing all, (bulk) and adding the back again.

This PR adds a helper function to compares two *schema.Sets, producing lists of which should be added and which should be removed. Resources that were in both the old and new configs will no longer be touched.

Fixes: #585

@andrewsomething andrewsomething changed the title Asb/issues/585 Assign and remove project resources without unnecessary churn (Fixes: #585). Feb 17, 2021
Copy link
Copy Markdown
Member

@bentranter bentranter left a comment

Choose a reason for hiding this comment

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

Looks great!

@andrewsomething andrewsomething merged commit ba0c6ef into main Feb 18, 2021
@andrewsomething andrewsomething deleted the asb/issues/585 branch February 18, 2021 16:51
andrewsomething added a commit that referenced this pull request Apr 26, 2021
…585). (#586)

* Add function for comparing *schema.Sets

* projects: Only add or remove resources that have changed.

* datasource_digitalocean_projects accepance test should not run in parallel.

* Check error; protect against empty requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Weird behaviour (remove all+add all) when changing resources in digitalocean_project

2 participants