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 support for both public and private module creation without VCS #460
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.
Overall code looks 🔥 Some things down below ⬇️
Provider: String("provider"), | ||
assertRegistryModuleAttributes := func(t *testing.T, registryModule *RegistryModule) { | ||
t.Run("permissions are properly decoded", func(t *testing.T) { | ||
assert.True(t, registryModule.Permissions.CanDelete) |
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.
You'll want to require Permissions
to not be nil
, otherwise this will panic if Permissions
was not decoded properly.
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.
I'm wondering if my changes in #458 will be overwritten somehow.
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, I will fix the conflicts once you merge the changes.
}) | ||
|
||
t.Run("relationships are properly decoded", func(t *testing.T) { | ||
assert.Equal(t, orgTest.Name, registryModule.Organization.Name) |
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.
Same here for Organization
registry_module.go
Outdated
@@ -436,6 +443,22 @@ func (o RegistryModuleCreateOptions) valid() error { | |||
if !validStringID(o.Provider) { | |||
return ErrInvalidProvider | |||
} | |||
|
|||
// RegistryName is optional, only validate if specified | |||
if validString((*string)(&o.RegistryName)) { |
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.
[For discussion] We can potentially simplify this logic:
We don't need to check if RegistryName
is a valid string as there are only two possible values we would care about:
switch(&o.RegistryName) {
case PublicRegistry:
if !validString(&o.Namespace) {
// return error
}
case PrivateRegistry:
if validString(&o.Namespace) {
// return other error
}
// for all other strings or nil:
default:
return ErrInvalidRegistryName
}
bf74088
to
59db300
Compare
2cfb379
to
a8e68ec
Compare
357e7af
to
9b83a37
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.
woop
9b83a37
to
599ef7c
Compare
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
Currently, private registry modules are created with an option containing:
Name
andProvider
.This PR adds the ability to create both
public/private
registry modules without VCS with options containing:Name
,Provider
,RegistryName
andNamespace
.The existing behaviour of creating a
private module
by specifying just theName and Provider
still works.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.