Skip to content

Commit 9d49212

Browse files
authored
Support initial_version for creating branch based modules (#1363)
1 parent 036e812 commit 9d49212

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ ENHANCEMENTS:
44
* `r/tfe_oauth_client`: Add Bitbucket Data Center support with the `bitbucket_data_center` option for `service_provider` by @zainq11 [#1303](https://github.com/hashicorp/terraform-provider-tfe/pull/1304)
55
* `r/tfe_workspace`: Add an `auto_destroy_at` attribute for scheduling an auto-destroy run in the future, by @notchairmk [1354](https://github.com/hashicorp/terraform-provider-tfe/pull/1354)
66
* `d/tfe_workspace`: Add an `auto_destroy_at` attribute for reading a scheduled auto-destroy, by @notchairmk [1354](https://github.com/hashicorp/terraform-provider-tfe/pull/1354)
7+
* `r/tfe_registry_module`: Add `initial_version` support for Branch Based Modules by @aaabdelgany [#1363](https://github.com/hashicorp/terraform-provider-tfe/pull/1363)
78

89
## v0.55.0
910

internal/provider/resource_tfe_registry_module.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ func resourceTFERegistryModule() *schema.Resource {
134134
},
135135
},
136136
},
137+
"initial_version": {
138+
Type: schema.TypeString,
139+
Optional: true,
140+
},
137141
},
138142
}
139143
}
@@ -167,13 +171,17 @@ func resourceTFERegistryModuleCreateWithVCS(v interface{}, meta interface{}, d *
167171

168172
tags, tagsOk := vcsRepo["tags"].(bool)
169173
branch, branchOk := vcsRepo["branch"].(string)
174+
initialVersion, initialVersionOk := d.GetOk("initial_version")
170175

171176
if tagsOk && tags && branchOk && branch != "" {
172177
return nil, fmt.Errorf("tags must be set to false when a branch is provided")
173178
}
174179

175180
if branchOk && branch != "" {
176181
options.VCSRepo.Branch = tfe.String(branch)
182+
if initialVersionOk && initialVersion.(string) != "" {
183+
options.InitialVersion = tfe.String(initialVersion.(string))
184+
}
177185
}
178186

179187
if vcsRepo["oauth_token_id"] != nil && vcsRepo["oauth_token_id"].(string) != "" {

internal/provider/resource_tfe_registry_module_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ func TestAccTFERegistryModuleImport_vcsPrivateRMRecommendedFormat(t *testing.T)
403403
}
404404

405405
func TestAccTFERegistryModuleImport_vcsPublishingMechanismBranchToTagsToBranch(t *testing.T) {
406-
skipUnlessBeta(t)
407406
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
408407

409408
resource.Test(t, resource.TestCase{
@@ -463,7 +462,6 @@ func TestAccTFERegistryModuleImport_vcsPublishingMechanismBranchToTagsToBranch(t
463462
}
464463

465464
func TestAccTFERegistryModuleImport_vcsPublishingMechanismBranchToTagsToBranchWithTests(t *testing.T) {
466-
skipUnlessBeta(t)
467465
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
468466

469467
resource.Test(t, resource.TestCase{
@@ -505,7 +503,6 @@ func TestAccTFERegistryModuleImport_vcsPublishingMechanismBranchToTagsToBranchWi
505503
}
506504

507505
func TestAccTFERegistryModuleImport_vcsPublishingMechanismTagsToBranchToTags(t *testing.T) {
508-
skipUnlessBeta(t)
509506
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
510507

511508
resource.Test(t, resource.TestCase{
@@ -556,7 +553,6 @@ func TestAccTFERegistryModuleImport_vcsPublishingMechanismTagsToBranchToTags(t *
556553
}
557554

558555
func TestAccTFERegistryModule_invalidTestConfigOnCreate(t *testing.T) {
559-
skipUnlessBeta(t)
560556
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
561557

562558
resource.Test(t, resource.TestCase{
@@ -575,7 +571,6 @@ func TestAccTFERegistryModule_invalidTestConfigOnCreate(t *testing.T) {
575571
}
576572

577573
func TestAccTFERegistryModule_invalidTestConfigOnUpdate(t *testing.T) {
578-
skipUnlessBeta(t)
579574
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
580575

581576
resource.Test(t, resource.TestCase{
@@ -603,7 +598,6 @@ func TestAccTFERegistryModule_invalidTestConfigOnUpdate(t *testing.T) {
603598
}
604599

605600
func TestAccTFERegistryModule_branchAndInvalidTagsOnCreate(t *testing.T) {
606-
skipUnlessBeta(t)
607601
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
608602

609603
resource.Test(t, resource.TestCase{
@@ -622,7 +616,6 @@ func TestAccTFERegistryModule_branchAndInvalidTagsOnCreate(t *testing.T) {
622616
}
623617

624618
func TestAccTFERegistryModule_branchAndTagsEnabledOnCreate(t *testing.T) {
625-
skipUnlessBeta(t)
626619
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
627620

628621
resource.Test(t, resource.TestCase{
@@ -641,7 +634,6 @@ func TestAccTFERegistryModule_branchAndTagsEnabledOnCreate(t *testing.T) {
641634
}
642635

643636
func TestAccTFERegistryModule_branchAndTagsEnabledOnUpdate(t *testing.T) {
644-
skipUnlessBeta(t)
645637
rInt := rand.New(rand.NewSource(time.Now().UnixNano())).Int()
646638

647639
resource.Test(t, resource.TestCase{
@@ -1027,6 +1019,8 @@ resource "tfe_registry_module" "foobar" {
10271019
tags = false
10281020
}
10291021
1022+
initial_version = "1.0.0"
1023+
10301024
test_config {
10311025
tests_enabled = false
10321026
}
@@ -1061,6 +1055,8 @@ resource "tfe_registry_module" "foobar" {
10611055
tags = false
10621056
}
10631057
1058+
initial_version = "1.0.0"
1059+
10641060
test_config {
10651061
}
10661062
}`,
@@ -1094,6 +1090,8 @@ resource "tfe_registry_module" "foobar" {
10941090
tags = false
10951091
}
10961092
1093+
initial_version = "1.0.0"
1094+
10971095
test_config {
10981096
tests_enabled = true
10991097
}
@@ -1129,6 +1127,8 @@ resource "tfe_registry_module" "foobar" {
11291127
tags = false
11301128
}
11311129
1130+
initial_version = "1.0.0"
1131+
11321132
test_config {
11331133
}
11341134
}`,
@@ -1163,6 +1163,8 @@ resource "tfe_registry_module" "foobar" {
11631163
tags = true
11641164
}
11651165
1166+
initial_version = "1.0.0"
1167+
11661168
test_config {
11671169
tests_enabled = true
11681170
}

website/docs/r/registry_module.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ The following arguments are supported:
154154
* `organization` - (Optional) The name of the organization associated with the registry module. It must be set if `module_provider` is used, or if `vcs_repo` is used via a GitHub App.
155155
* `namespace` - (Optional) The namespace of a public registry module. It can be used if `module_provider` is set and `registry_name` is public.
156156
* `registry_name` - (Optional) Whether the registry module is private or public. It can be used if `module_provider` is set.
157+
* `initial_version` - (Optional) This specifies the initial version for a branch based module. It can be used if `vcs_repo.branch` is set. If it is omitted, the initial modules version will default to `0.0.0`.
157158

158159
The `test_config` block supports
159160
* `tests_enabled` - (Optional) Specifies whether tests run for the registry module. Tests are only supported for branch-based publishing.

0 commit comments

Comments
 (0)