-
Notifications
You must be signed in to change notification settings - Fork 523
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
fix: fix google_container_cluster duplicating node pools when applied #1463
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
The `google_container_cluster` resource pulls all existing node pools into its `node_pool` attribute when deployed. This duplicates the default pool and any node pools defined in `google_container_node_pool` resources. To fix this we: 1. Only add the default node pool subresource if it doesn't already exist in the `node_pool` array. If it does exist in that array, we add it as part of that. 2. Check for node pools defined in other resources, and only add them as subresources if they are not.
f29a762
to
ba6b975
Compare
func contains(a []string, x string) bool { | ||
for _, n := range a { | ||
if x == n { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you guys update the Golang version to 1.18, there's this awesomely helpful package to employ such features: https://github.com/samber/lo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Go 1.18 is out! 🎉 https://twitter.com/golang/status/1503787326060875782
The
google_container_cluster
resource pulls all existing node pools into itsnode_pool
attribute when deployed. This duplicates the default pool and any node pools defined ingoogle_container_node_pool
resources. To fix this we:node_pool
array. If it does exist in that array, we add it as part of that.