Skip to content

Commit c278019

Browse files
Merge pull request #1003 from hashicorp/list-registry-module-filter
Add inclusion of no-code module when listing modules
2 parents 30b05ea + dbaf3b2 commit c278019

File tree

4 files changed

+38
-3
lines changed

4 files changed

+38
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Enhancements
44

55
* Add support for listing effective tag bindings for a workspace or project by @brandonc
6+
* Add support for listing no-code modules by @paladin-devops [#1003](https://github.com/hashicorp/go-tfe/pull/1003)
67

78
# v1.69.0
89

docs/TESTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ $ TFE_TOKEN=xyz TFE_HOSTNAME=tfe.local ENABLE_TFE=1 go test ./... -timeout=30m
111111

112112
### Running tests for HCP Terraform features that require paid plans (HashiCorp Employees)
113113

114-
You can use the test helper `upgradeOrganizationSubscription()` to upgrade your test organization to a Business Plan, giving the organization access to all features in HCP Terraform. This method requires `TFE_TOKEN` to be a user token with administrator access in the target test environment. Furthermore, you **can not** have enterprise features enabled (`ENABLE_TFE=1`) in order to use this method since the API call fails against Terraform Enterprise test environments.
114+
You can use the test helper `newSubscriptionUpdater()` to upgrade your test organization to a Business Plan, giving the organization access to all features in HCP Terraform. This method requires `TFE_TOKEN` to be a user token with administrator access in the target test environment. Furthermore, you **can not** have enterprise features enabled (`ENABLE_TFE=1`) in order to use this method since the API call fails against Terraform Enterprise test environments.

registry_module.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var _ RegistryModules = (*registryModules)(nil)
2222
//
2323
// TFE API docs: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/private-registry/modules
2424
type RegistryModules interface {
25-
// List all the registory modules within an organization
25+
// List all the registry modules within an organization
2626
List(ctx context.Context, organization string, options *RegistryModuleListOptions) (*RegistryModuleList, error)
2727

2828
// ListCommits List the commits for the registry module
@@ -157,6 +157,8 @@ type RegistryModule struct {
157157

158158
// Relations
159159
Organization *Organization `jsonapi:"relation,organization"`
160+
161+
RegistryNoCodeModule []*RegistryNoCodeModule `jsonapi:"relation,no-code-modules"`
160162
}
161163

162164
// Commit represents a commit
@@ -202,8 +204,15 @@ type RegistryModuleVersionStatuses struct {
202204
// RegistryModuleListOptions represents the options for listing registry modules.
203205
type RegistryModuleListOptions struct {
204206
ListOptions
207+
208+
// Include is a list of relations to include.
209+
Include []RegistryModuleListIncludeOpt `url:"include,omitempty"`
205210
}
206211

212+
type RegistryModuleListIncludeOpt string
213+
214+
const IncludeNoCodeModules RegistryModuleListIncludeOpt = "no-code-modules"
215+
207216
// RegistryModuleCreateOptions is used when creating a registry module without a VCS repo
208217
type RegistryModuleCreateOptions struct {
209218
// Type is a public field utilized by JSON:API to
@@ -311,7 +320,7 @@ type RegistryModuleVCSRepoUpdateOptions struct {
311320
Tags *bool `json:"tags,omitempty"`
312321
}
313322

314-
// List all the registory modules within an organization.
323+
// List all the registry modules within an organization.
315324
func (r *registryModules) List(ctx context.Context, organization string, options *RegistryModuleListOptions) (*RegistryModuleList, error) {
316325
if !validStringID(&organization) {
317326
return nil, ErrInvalidOrg

registry_module_integration_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,31 @@ func TestRegistryModulesList(t *testing.T) {
6262
assert.NotEmpty(t, modl.Items)
6363
assert.Equal(t, 1, modl.CurrentPage)
6464
})
65+
66+
t.Run("include no-code modules", func(t *testing.T) {
67+
options := RegistryModuleCreateOptions{
68+
Name: String("iam"),
69+
Provider: String("aws"),
70+
NoCode: Bool(true),
71+
RegistryName: PrivateRegistry,
72+
}
73+
rm, err := client.RegistryModules.Create(ctx, orgTest.Name, options)
74+
require.NoError(t, err)
75+
76+
modl, err := client.RegistryModules.List(ctx, orgTest.Name, &RegistryModuleListOptions{
77+
Include: []RegistryModuleListIncludeOpt{
78+
IncludeNoCodeModules,
79+
},
80+
})
81+
require.NoError(t, err)
82+
assert.Len(t, modl.Items, 3)
83+
for _, m := range modl.Items {
84+
if m.ID == rm.ID {
85+
assert.True(t, m.NoCode)
86+
assert.Len(t, m.RegistryNoCodeModule, 1)
87+
}
88+
}
89+
})
6590
}
6691

6792
func TestRegistryModulesCreate(t *testing.T) {

0 commit comments

Comments
 (0)