Skip to content

Commit

Permalink
[TF-7737] Use a VCS Repo object when updating the branch and tags for…
Browse files Browse the repository at this point in the history
… RegistryModules
  • Loading branch information
hashimoon committed Oct 5, 2023
1 parent bfc640a commit bd4b955
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
18 changes: 11 additions & 7 deletions registry_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,7 @@ type RegistryModuleUpdateOptions struct {
// **Note: This field is still in BETA and subject to change.**
TestConfig *RegistryModuleTestConfigOptions `jsonapi:"attr,test-config,omitempty"`

// The Branch and Tag fields are used to determine
// the PublishingMechanism for a RegistryModule that has a VCS a connection.
// When a value for Branch is provided, the Tags field is removed on the server
// When a value for Tags is provided, the Branch field is removed on the server
// **Note: This field is still in BETA and subject to change.**
Branch string `jsonapi:"attr,branch,omitempty"`
Tags string `jsonapi:"attr,tags,omitempty"`
VCSRepo *RegistryModuleVCSRepoUpdateOptions `jsonapi:"attr-vcs-repo,omitempty"`
}

type RegistryModuleTestConfigOptions struct {
Expand All @@ -297,6 +291,16 @@ type RegistryModuleVCSRepoOptions struct {
Branch *string `json:"branch,omitempty"`
}

type RegistryModuleVCSRepoUpdateOptions struct {
// The Branch and Tag fields are used to determine
// the PublishingMechanism for a RegistryModule that has a VCS a connection.
// When a value for Branch is provided, the Tags field is removed on the server
// When a value for Tags is provided, the Branch field is removed on the server
// **Note: This field is still in BETA and subject to change.**
Branch *string `json:"branch,omitempty"`
Tags *string `json:"tags,omitempty"`
}

// List all the registory modules within an organization.
func (r *registryModules) List(ctx context.Context, organization string, options *RegistryModuleListOptions) (*RegistryModuleList, error) {
if !validStringID(&organization) {
Expand Down
12 changes: 9 additions & 3 deletions registry_module_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,9 @@ func TestRegistryModuleUpdateWithVCSConnection(t *testing.T) {
assert.Equal(t, "git_tag", rm.PublishingMechanism)

options := RegistryModuleUpdateOptions{
Branch: githubBranch,
VCSRepo: &RegistryModuleVCSRepoUpdateOptions{
Branch: String(githubBranch),
},
}
rm, err := client.RegistryModules.Update(ctx, RegistryModuleID{
Organization: orgTest.Name,
Expand All @@ -380,7 +382,9 @@ func TestRegistryModuleUpdateWithVCSConnection(t *testing.T) {
assert.Equal(t, "branch", rm.PublishingMechanism)

options = RegistryModuleUpdateOptions{
Tags: "1.0.0",
VCSRepo: &RegistryModuleVCSRepoUpdateOptions{
Tags: String("1.0.0"),
},
}
rm, err = client.RegistryModules.Update(ctx, RegistryModuleID{
Organization: orgTest.Name,
Expand All @@ -394,7 +398,9 @@ func TestRegistryModuleUpdateWithVCSConnection(t *testing.T) {
assert.Equal(t, "git_tag", rm.PublishingMechanism)

options = RegistryModuleUpdateOptions{
Branch: githubBranch,
VCSRepo: &RegistryModuleVCSRepoUpdateOptions{
Branch: String(githubBranch),
},
}
rm, err = client.RegistryModules.Update(ctx, RegistryModuleID{
Organization: orgTest.Name,
Expand Down

0 comments on commit bd4b955

Please sign in to comment.