Skip to content

Commit

Permalink
update models to ignore facility when null
Browse files Browse the repository at this point in the history
  • Loading branch information
aayushrangwala committed Feb 22, 2024
1 parent 34565b2 commit 445f79e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions internal/resources/metal/vlans/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ func (m *DataSourceModel) parse(vlan *packngo.VirtualNetwork) diag.Diagnostics {
m.ID = types.StringValue(vlan.ID)
m.ProjectID = types.StringValue(vlan.Project.ID)
m.VlanID = types.StringValue(vlan.ID)
m.Facility = types.StringValue(vlan.FacilityCode)

m.Facility = types.StringNull()
if vlan.FacilityCode != "" {
m.Facility = types.StringValue(vlan.FacilityCode)
}

m.Description = types.StringValue(vlan.Description)
m.Vxlan = types.Int64Value(int64(vlan.VXLAN))

Expand All @@ -46,7 +51,12 @@ type ResourceModel struct {
func (m *ResourceModel) parse(vlan *packngo.VirtualNetwork) diag.Diagnostics {
m.ID = types.StringValue(vlan.ID)
m.ProjectID = types.StringValue(vlan.Project.ID)
m.Facility = types.StringValue(vlan.FacilityCode)

m.Facility = types.StringNull()
if vlan.FacilityCode != "" {
m.Facility = types.StringValue(vlan.FacilityCode)
}

m.Description = types.StringValue(vlan.Description)
m.Vxlan = types.Int64Value(int64(vlan.VXLAN))

Expand Down
1 change: 1 addition & 0 deletions internal/resources/metal/vlans/resource_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func resourceSchema(ctx context.Context) schema.Schema {
},
PlanModifiers: []planmodifier.String{
stringplanmodifier.RequiresReplace(),
stringplanmodifier.UseStateForUnknown(),
},
// TODO: aayushrangwala to check if this is needed with the framework changes
//DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool {
Expand Down

0 comments on commit 445f79e

Please sign in to comment.