Add UserTokensEnabled field for Organizations#1225
Conversation
bf749f0 to
62ba5e8
Compare
62ba5e8 to
7eb9144
Compare
|
09dc30b to
e7cf4aa
Compare
| RemainingTestableCount int `jsonapi:"attr,remaining-testable-count"` | ||
| SpeculativePlanManagementEnabled bool `jsonapi:"attr,speculative-plan-management-enabled"` | ||
| EnforceHYOK bool `jsonapi:"attr,enforce-hyok"` | ||
| UserTokensEnabled *bool `jsonapi:"attr,user-tokens-enabled"` |
There was a problem hiding this comment.
Why do we use a bool pointer type? false and nil are both logically equivalent, correct?
There was a problem hiding this comment.
Good question: it is because this setting defaults to true. Making this a bool pointer allows us to distinguish between "this is unspecified on the organization" (ie, because it is an older version of TFE) and "this is explicitly false" (ie, because this is an up-to-date TFE and the user has disabled the setting)
That is important because in the provider when we read an organization from an old TFE version, we dont want the the value to appear as false. That could lead to the provider always showing drift for the org and/or be misleading since the behaviour of the old org is that user tokens are enabled.
There was a problem hiding this comment.
A similar example would be like OrganizationScoped for agent pools
| org, err := ownerClient.Organizations.Update(ctx, orgTest.Name, options) | ||
| require.NoError(t, err) | ||
| assert.False(t, *org.UserTokensEnabled, "user tokens disabled") | ||
|
|
There was a problem hiding this comment.
Consider including assertions that validate the change had the intended effect, i.e. try and look up some resources and expect an error here. (& the inverse when the setting is off)
There was a problem hiding this comment.
thanks for the suggestion, I have added some more assertions!
ctrombley
left a comment
There was a problem hiding this comment.
Thanks @JarrettSpiker !
|
Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes. |
Description
Adds
UserTokensEnabledforOrganizations.This new HCP Terraform setting defaults to true. When disabled by an organization owner, user tokens will no longer be permitted to access the organization's resources through the API.
Testing plan
External links
Output from tests
Including output from tests may require access to a TFE instance. Ignore this section if you have no environment to test against.
Rollback Plan
If we need to revert this change before a go-tfe release, we will.
Changes to Security Controls
no