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

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

Merged
merged 5 commits into from
Feb 18, 2021

Conversation

andrewsomething
Copy link
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
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