Skip to content

Commit

Permalink
Merge pull request #91 from Sander0542/fix/proxy-host-domain-names-type
Browse files Browse the repository at this point in the history
Migrate ProxyHost.DomainNames to types.List
  • Loading branch information
Sander0542 authored Dec 23, 2023
2 parents bbbbd8b + 3ddbafb commit 5a78c8c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions nginxproxymanager/models/proxy_host.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type ProxyHost struct {
OwnerUserId types.Int64 `tfsdk:"owner_user_id"`
Meta types.Map `tfsdk:"meta"`

DomainNames []types.String `tfsdk:"domain_names"`
DomainNames types.List `tfsdk:"domain_names"`
ForwardScheme types.String `tfsdk:"forward_scheme"`
ForwardHost types.String `tfsdk:"forward_host"`
ForwardPort types.Int64 `tfsdk:"forward_port"`
Expand Down Expand Up @@ -57,10 +57,10 @@ func (m *ProxyHost) Load(ctx context.Context, resource *resources.ProxyHost) dia
m.AdvancedConfig = types.StringValue(resource.AdvancedConfig)
m.Enabled = types.BoolValue(resource.Enabled.Bool())

m.DomainNames = make([]types.String, len(resource.DomainNames))
for i, v := range resource.DomainNames {
m.DomainNames[i] = types.StringValue(v)
}
domainNames, domainNamesDiags := types.ListValueFrom(ctx, types.StringType, resource.DomainNames)
diags.Append(domainNamesDiags...)
m.DomainNames = domainNames

var locations []*ProxyHostLocation
for _, locationResponse := range resource.Locations {
location := &ProxyHostLocation{}
Expand Down Expand Up @@ -91,10 +91,9 @@ func (m *ProxyHost) Save(ctx context.Context, input *inputs.ProxyHost) diag.Diag
input.AdvancedConfig = m.AdvancedConfig.ValueString()
input.Meta = map[string]string{}

input.DomainNames = make([]string, len(m.DomainNames))
for i, v := range m.DomainNames {
input.DomainNames[i] = v.ValueString()
}
input.DomainNames = make([]string, 0, len(m.DomainNames.Elements()))
diags.Append(m.DomainNames.ElementsAs(ctx, &input.DomainNames, false)...)

input.Locations = make([]inputs.ProxyHostLocation, len(m.Locations))
for i, v := range m.Locations {
diags.Append(v.Save(ctx, &input.Locations[i])...)
Expand Down

0 comments on commit 5a78c8c

Please sign in to comment.