Skip to content

Commit

Permalink
[TF-9605] Add the tags attribute to VCSRepo
Browse files Browse the repository at this point in the history
This is required to prevent terraform always from always asserting new state changes when toggling between a branch and tag based publishing for RegistryModules
  • Loading branch information
hashimoon committed Oct 13, 2023
1 parent 95916b7 commit aaab547
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# UNRELEASED

## Features
* Add the tags attribute to VCSRepo to be used with registry modules by @hashimoon [#793](https://github.com/hashicorp/go-tfe/pull/793)

# v.1.36.0

## Features
Expand Down
9 changes: 8 additions & 1 deletion registry_module_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ func TestRegistryModuleUpdateWithVCSConnection(t *testing.T) {
}, options)
require.NoError(t, err)
assert.Equal(t, rm.PublishingMechanism, PublishingMechanismBranch)
assert.Equal(t, Bool(false), rm.VCSRepo.Tags)
assert.Equal(t, String(githubBranch), rm.VCSRepo.Branch)

options = RegistryModuleUpdateOptions{
VCSRepo: &RegistryModuleVCSRepoUpdateOptions{
Expand All @@ -396,6 +398,8 @@ func TestRegistryModuleUpdateWithVCSConnection(t *testing.T) {
require.NoError(t, err)

assert.Equal(t, rm.PublishingMechanism, PublishingMechanismTag)
assert.Equal(t, Bool(true), rm.VCSRepo.Tags)
assert.Equal(t, String(""), rm.VCSRepo.Branch)

options = RegistryModuleUpdateOptions{
VCSRepo: &RegistryModuleVCSRepoUpdateOptions{
Expand All @@ -411,6 +415,8 @@ func TestRegistryModuleUpdateWithVCSConnection(t *testing.T) {
}, options)
require.NoError(t, err)
assert.Equal(t, rm.PublishingMechanism, PublishingMechanismBranch)
assert.Equal(t, Bool(false), rm.VCSRepo.Tags)
assert.Equal(t, String(githubBranch), rm.VCSRepo.Branch)
})
}

Expand Down Expand Up @@ -860,8 +866,8 @@ func TestRegistryModulesCreateBranchBasedWithVCSConnection(t *testing.T) {
assert.Equal(t, registryModuleName, rm.Name)
assert.Equal(t, registryModuleProvider, rm.Provider)
assert.Equal(t, githubBranch, rm.VCSRepo.Branch)
assert.Equal(t, Bool(false), rm.VCSRepo.Tags)
})

t.Run("with invalid options", func(t *testing.T) {
options := RegistryModuleCreateWithVCSConnectionOptions{
VCSRepo: &RegistryModuleVCSRepoOptions{
Expand Down Expand Up @@ -920,6 +926,7 @@ func TestRegistryModulesCreateBranchBasedWithVCSConnectionWithTesting(t *testing
assert.Equal(t, registryModuleName, rm.Name)
assert.Equal(t, registryModuleProvider, rm.Provider)
assert.Equal(t, githubBranch, rm.VCSRepo.Branch)
assert.Equal(t, false, rm.VCSRepo.Tags)

t.Run("tests are enabled", func(t *testing.T) {
assert.NotEmpty(t, rm.TestConfig)
Expand Down
1 change: 1 addition & 0 deletions workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ type VCSRepo struct {
GHAInstallationID string `jsonapi:"attr,github-app-installation-id"`
RepositoryHTTPURL string `jsonapi:"attr,repository-http-url"`
ServiceProvider string `jsonapi:"attr,service-provider"`
Tags bool `jsonapi:"attr,tags"`
TagsRegex string `jsonapi:"attr,tags-regex"`
WebhookURL string `jsonapi:"attr,webhook-url"`
}
Expand Down

0 comments on commit aaab547

Please sign in to comment.