Skip to content

Commit

Permalink
Fix null-value tag list handling
Browse files Browse the repository at this point in the history
  • Loading branch information
janartodesk committed Nov 28, 2024
1 parent 1da269a commit 032dc7e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion internal/resource/host/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ func (s *State) ApplyHost(ctx context.Context, host *definednet.Host) (diags dia
s.RoleID = types.StringValue(host.RoleID)
}

s.Tags, diags = types.ListValueFrom(ctx, types.StringType, host.Tags)
s.Tags = types.ListNull(types.StringType)
if len(host.Tags) > 0 {
s.Tags, diags = types.ListValueFrom(ctx, types.StringType, host.Tags)
}

return diags
}
11 changes: 7 additions & 4 deletions internal/resource/lighthouse/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,24 @@ func (s *State) ApplyHost(ctx context.Context, lighthouse *definednet.Host) (dia

diags.Append(d...)

tags := types.ListNull(types.StringType)
if len(lighthouse.Tags) > 0 {
tags, d = types.ListValueFrom(ctx, types.StringType, lighthouse.Tags)
diags.Append(d...)
}

s.ID = types.StringValue(lighthouse.ID)
s.Name = types.StringValue(lighthouse.Name)
s.NetworkID = types.StringValue(lighthouse.NetworkID)
s.StaticAddresses = staticAddrs
s.ListenPort = types.Int32Value(int32(lighthouse.ListenPort))
s.IPAddress = types.StringValue(lighthouse.IPAddress)
s.Tags = tags

s.RoleID = types.StringNull()
if lo.IsNotEmpty(lighthouse.RoleID) {
s.RoleID = types.StringValue(lighthouse.RoleID)
}

tags, d := types.ListValueFrom(ctx, types.StringType, lighthouse.Tags)
s.Tags = tags
diags.Append(d...)

return diags
}

0 comments on commit 032dc7e

Please sign in to comment.