-
Notifications
You must be signed in to change notification settings - Fork 5
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
Only manage team memberships if they were defined before in the config #162
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #162 +/- ##
==========================================
- Coverage 44.85% 44.85% -0.01%
==========================================
Files 70 70
Lines 5642 5643 +1
==========================================
Hits 2531 2531
- Misses 3109 3110 +1
Partials 2 2 ☔ View full report in Codecov by Sentry. |
4a801e8
to
d87de6b
Compare
// in their config, and they cannot use terraform to manage | ||
// teams because of it without either adding the members into | ||
// the config or unassigning all the members (unwanted) | ||
if members, ok := d.GetOk("member"); members != nil || ok { |
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.
Do we need the members != nil ||
part of this check?
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.
Yes, because if that part is not present it won't detect when member
is defined for the first time in a configuration.
The first result will not necessarilly be nil if the value doesn't exist. The second result should be checked to determine this information.
https://pkg.go.dev/github.com/hashicorp/terraform/helper/schema#ResourceData.GetOk
Warning: I think we have a regression with this bug.Tophatting by compiling the latest Create the team
Add a manager and a contributor on webDon't change the terraform config at all, just hit
|
Issues
Some customers are defining Teams in terraform, but are not defining team memberships in their configurations (*.tf files) using
member {}
blocks. They are unable to run this provider because doing so results in all members being unassigned since they are not defined in terraform.One option for them is to export their members into their terraform config using the CLI.
The other option is for the terraform provider to only touch Team Memberships if they are defined or were previously defined at any point before in the configuration.
Related, export members from web into terraform using CLI: OpsLevel/cli#206
Related, ability to use
member {}
blocks in terraform: #144Changelog
changie
entryTophatting
Create a new team without any managed members, make sure terraform doesn't try to unassign members on updates
Create the team
On the website, add 2 contributors and 1 manager.
Run the plan. Expected is to see no changes, since no
member {}
is defined in the config.Try again by running an update, but without managing team memberships.
This shows that you can manage a team that has no
member {}
blocks without the provider trying to unassign everyone.Add a single
member {}
block. This should cause terraform to reconcile team memberships, removing the 3 current members with Doug since it is now managing members too.Remove the last member.
Now from here, we are in the state where the configuration has no members, and the object itself has no members. BUT,
GetOk()
returnstrue
if something was ever set in the configuration. So I expect that it will try to reconcile team memberships if I add some in the website.