Skip to content

Commit

Permalink
Merge pull request #572 from Juniper/bug/570-device-allocation-system…
Browse files Browse the repository at this point in the history
…-attribute-empty

Fix `DeviceAllocationSystemAttributes.IsEmpty()`
  • Loading branch information
chrismarget-j authored Feb 19, 2024
2 parents 9a8be41 + 2c2bdd3 commit 9ffacbf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apstra/blueprint/device_allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,8 @@ func (o *DeviceAllocation) SetSystemAttributes(ctx context.Context, state *Devic
return
}

planSA := new(DeviceAllocationSystemAttributes)
diags.Append(o.SystemAttributes.As(ctx, planSA, basetypes.ObjectAsOptions{})...)
var planSA DeviceAllocationSystemAttributes
diags.Append(o.SystemAttributes.As(ctx, &planSA, basetypes.ObjectAsOptions{})...)
if diags.HasError() {
return
}
Expand Down
6 changes: 4 additions & 2 deletions apstra/blueprint/device_allocation_system_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,12 @@ func (o DeviceAllocationSystemAttributes) ResourceAttributes() map[string]resour
}

func (o *DeviceAllocationSystemAttributes) IsEmpty() bool {
if //o.Asn.IsNull() &&
o.Name.IsNull() &&
if o.Asn.IsNull() &&
o.Name.IsNull() &&
o.Hostname.IsNull() &&
o.LoopbackIpv4.IsNull() &&
o.Tags.IsNull() &&
o.DeployMode.IsNull() &&
o.LoopbackIpv6.IsNull() {
return true
}
Expand Down
4 changes: 4 additions & 0 deletions apstra/test_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func cidrOrNull(in *net.IPNet) string {
}

func stringSetOrNull(in []string) string {
if in == nil {
return "null"
}

sb := new(strings.Builder)
for i, s := range in {
if i == 0 {
Expand Down

0 comments on commit 9ffacbf

Please sign in to comment.