Skip to content

Commit

Permalink
per_hostname_tls_settings: correct handling of query parameters
Browse files Browse the repository at this point in the history
Updates the handling of the query parameters to be fed through
`buildURI` and actually use the `url` struct tags.

This fixes a bug upstream in the Terraform provider where the sorting
isn't being applied and you get the wrong identifier forcing a
replacement.
  • Loading branch information
jacobbednarz committed Nov 13, 2023
1 parent c262f14 commit d55e16b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions per_hostname_tls_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ type HostnameTLSSettingsResponse struct {

// ListHostnameTLSSettingsParams represents the data related to per-hostname tls settings being retrieved.
type ListHostnameTLSSettingsParams struct {
Setting string
PaginationOptions
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
Hostname []string `url:"hostname,omitempty"`
Setting string `json:"-" url:"setting,omitempty"`
PaginationOptions `json:"-"`
Limit int `json:"-" url:"limit,omitempty"`
Offset int `json:"-" url:"offset,omitempty"`
Hostname []string `json:"-" url:"hostname,omitempty"`
}

// UpdateHostnameTLSSettingParams represents the data related to the per-hostname tls setting being updated.
Expand Down Expand Up @@ -69,8 +69,8 @@ func (api *API) ListHostnameTLSSettings(ctx context.Context, rc *ResourceContain
return []HostnameTLSSetting{}, ResultInfo{}, ErrMissingHostnameTLSSettingName
}

uri := fmt.Sprintf("/zones/%s/hostnames/settings/%s", rc.Identifier, params.Setting)
res, err := api.makeRequestContext(ctx, http.MethodGet, uri, params)
uri := buildURI(fmt.Sprintf("/zones/%s/hostnames/settings/%s", rc.Identifier, params.Setting), params)
res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return []HostnameTLSSetting{}, ResultInfo{}, err
}
Expand Down Expand Up @@ -158,9 +158,9 @@ type HostnameTLSSettingsCiphersResponse struct {
// ListHostnameTLSSettingsCiphersParams represents the data related to per-hostname ciphers tls settings being retrieved.
type ListHostnameTLSSettingsCiphersParams struct {
PaginationOptions
Limit int `url:"limit,omitempty"`
Offset int `url:"offset,omitempty"`
Hostname []string `url:"hostname,omitempty"`
Limit int `json:"-" url:"limit,omitempty"`
Offset int `json:"-" url:"offset,omitempty"`
Hostname []string `json:"-" url:"hostname,omitempty"`
}

// UpdateHostnameTLSSettingCiphersParams represents the data related to the per-hostname ciphers tls setting being updated.
Expand All @@ -183,8 +183,8 @@ func (api *API) ListHostnameTLSSettingsCiphers(ctx context.Context, rc *Resource
return []HostnameTLSSettingCiphers{}, ResultInfo{}, ErrMissingZoneID
}

uri := fmt.Sprintf("/zones/%s/hostnames/settings/ciphers", rc.Identifier)
res, err := api.makeRequestContext(ctx, http.MethodGet, uri, params)
uri := buildURI(fmt.Sprintf("/zones/%s/hostnames/settings/ciphers", rc.Identifier), params)
res, err := api.makeRequestContext(ctx, http.MethodGet, uri, nil)
if err != nil {
return []HostnameTLSSettingCiphers{}, ResultInfo{}, err
}
Expand Down

0 comments on commit d55e16b

Please sign in to comment.