Skip to content

Commit

Permalink
remove external_id, spurious fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dsa0x committed Oct 17, 2024
1 parent 06bf105 commit 414e429
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
10 changes: 5 additions & 5 deletions registry_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ const (
// Use NewPublicRegistryModuleID or NewPrivateRegistryModuleID to build one

type RegistryModuleID struct {
// The unique external ID of the organization. If given, the other fields are ignored.
ExternalID string
// The unique ID of the module. If given, the other fields are ignored.
ID string
// The organization the module belongs to, see RegistryModule.Organization.Name
Organization string
// The name of the module, see RegistryModule.Name
Expand Down Expand Up @@ -527,7 +527,7 @@ func (r *registryModules) Read(ctx context.Context, moduleID RegistryModuleID) (
}

var u string
if moduleID.ExternalID == "" {
if moduleID.ID == "" {
if moduleID.RegistryName == "" {
log.Println("[WARN] Support for using the RegistryModuleID without RegistryName is deprecated as of release 1.5.0 and may be removed in a future version. The preferred method is to include the RegistryName in RegistryModuleID.")
moduleID.RegistryName = PrivateRegistry
Expand All @@ -547,7 +547,7 @@ func (r *registryModules) Read(ctx context.Context, moduleID RegistryModuleID) (
url.PathEscape(moduleID.Provider),
)
} else {
u = fmt.Sprintf("registry-modules/%s", url.PathEscape(moduleID.ExternalID))
u = fmt.Sprintf("registry-modules/%s", url.PathEscape(moduleID.ID))
}

req, err := r.client.NewRequest("GET", u, nil)
Expand Down Expand Up @@ -698,7 +698,7 @@ func (r *registryModules) DeleteVersion(ctx context.Context, moduleID RegistryMo
}

func (o RegistryModuleID) valid() error {
if validString(&o.ExternalID) && validStringID(&o.ExternalID) {
if validString(&o.ID) && validStringID(&o.ID) {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions registry_module_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1193,9 +1193,9 @@ func TestRegistryModulesRead(t *testing.T) {
})
})

t.Run("with a external ID field for private module", func(t *testing.T) {
t.Run("with a unique ID field for private module", func(t *testing.T) {
rm, err := client.RegistryModules.Read(ctx, RegistryModuleID{
ExternalID: registryModuleTest.ID,
ID: registryModuleTest.ID,
})
require.NoError(t, err)
require.NotEmpty(t, rm)
Expand Down
7 changes: 1 addition & 6 deletions tfe.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,7 @@ func (c *Client) NewRequestWithAdditionalQueryParams(method, path string, reqBod
q[k] = v
}

encodedParams := encodeQueryParams(q)
if u.RawQuery == "" {
u.RawQuery = encodedParams
} else if encodedParams != "" {
u.RawQuery = strings.Join([]string{u.RawQuery, encodedParams}, "&")
}
u.RawQuery = encodeQueryParams(q)

req, err := retryablehttp.NewRequest(method, u.String(), body)
if err != nil {
Expand Down

0 comments on commit 414e429

Please sign in to comment.