-
Notifications
You must be signed in to change notification settings - Fork 160
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
Add Organization Module Sharing Resource #425
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.
Code review only- I haven't tested this yet -- overall very nice
) | ||
|
||
func TestAccTFEOrganizationModuleSharing_basic(t *testing.T) { | ||
skipIfFreeOnly(t) |
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.
Should these be skipped for Terraform Cloud as well?
|
||
d.SetId(producer) | ||
|
||
return resourceTFEOrganizationModuleSharingUpdate(d, meta) |
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.
Something may be amiss- is this entire function body supposed to be this line? Otherwise it looks like we are updating 2x
}, | ||
|
||
"consumer_ids": { | ||
Type: schema.TypeMap, |
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.
Throughout the provider, org name is synonymous with id (both tfe_organization id/name attributes reflect the name and we don't expose the external id anywhere)
I think it would be less confusing to remove this attribute altogether.
d.SetId("") | ||
return nil | ||
} | ||
return fmt.Errorf("Error reading organization %s mondule consumer list: %w", d.Id(), err) |
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.
spelling
return fmt.Errorf("Error reading organization %s mondule consumer list: %w", d.Id(), err) | |
return fmt.Errorf("Error reading organization %s module consumer list: %w", d.Id(), err) |
if err == tfe.ErrResourceNotFound { | ||
return nil | ||
} | ||
return fmt.Errorf("error deleting organization %s: %w", d.Id(), err) |
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.
this error looks scary you might want to say that we're having trouble deleting the organization module sharing
This resource represents the ability to manage relationships between organizations and their registries. It allows you to specify what consumers (organizations) have access to a given organization's registry. This resource defines two arguments and one computed attribute: * organization -> the organization to enable module sharing * module_consumers -> the organizations that will consume the organization's registry * consumer_ids -> a computed attribute that stores a map of org name => external org id
f7d700e
to
efc9291
Compare
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.
Nice, it seems to work well! We'll have to consider how to mitigate resource drift when we add global_module_sharing to tfe_organization because when you turn it on, it clears the module sharing relationships. When you create module sharing relationships, it turns off global sharing
Description
Hey Terraformers!
This PR introduces a new resource:
tfe_organization_module_sharing
which allows site admins to manage how module registries are shared across organizations. This is an admin only resource and thus can only be used in TFE. The resource has 3 total attributes, two of which are arguments and one is a computed attribute:Arguments:
organization
- (Required) Name of the organization.module_consumers
- (Required) Names of the organizations to consume the module registry.(Computed) Attributes:
consumer_ids
- A map of organization names and their opaque, immutable IDs, which look likeorg-<RANDOM STRING>
.Testing plan
Run acceptance tests:
TESTARGS="-run TestAccTFEOrganizationModuleSharing" make testacc
Smoke test:
~/tfe_provider-dev.tfrc
which I use when testing against the local provider binary:terraform.state
file for any provider disobedience!module_consumers
to an empty array (this will stop sharing an org's module registry) OR the expected way and delete the resource block in your configuration.External links