From 8ff84d341009271351ba0b6fffd136baf3acab93 Mon Sep 17 00:00:00 2001 From: bwjuniper Date: Wed, 30 Oct 2024 13:01:01 -0700 Subject: [PATCH 1/3] fix logic to look at null_when_not_found --- apstra/blueprint/node_system.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apstra/blueprint/node_system.go b/apstra/blueprint/node_system.go index 4d0b1a7a..a6f7f577 100644 --- a/apstra/blueprint/node_system.go +++ b/apstra/blueprint/node_system.go @@ -79,6 +79,9 @@ func (o *NodeTypeSystem) AttributesFromApi(ctx context.Context, client *apstra.C case !o.Id.IsNull(): desiredNode, ok = nodeResponse.Nodes[o.Id.ValueString()] if !ok { + if o.NullWhenNotFound.ValueBool() { + o.Attributes = types.ObjectNull(NodeTypeSystemAttributes{}.AttrTypes()) + } diags.AddError("Node not found", fmt.Sprintf("Node with ID %q not found in blueprint %q", o.Id.ValueString(), o.BlueprintId.ValueString())) @@ -92,6 +95,9 @@ func (o *NodeTypeSystem) AttributesFromApi(ctx context.Context, client *apstra.C } } if !ok { + if o.NullWhenNotFound.ValueBool() { + o.Attributes = types.ObjectNull(NodeTypeSystemAttributes{}.AttrTypes()) + } diags.AddError("Node not found", fmt.Sprintf("Node with Name %q not found in blueprint %q", o.Name.ValueString(), o.BlueprintId.ValueString())) From f2052e31794c17bd15b98565774910ee5b490dfc Mon Sep 17 00:00:00 2001 From: bwjuniper Date: Wed, 30 Oct 2024 13:25:53 -0700 Subject: [PATCH 2/3] add return (duh) --- apstra/blueprint/node_system.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apstra/blueprint/node_system.go b/apstra/blueprint/node_system.go index a6f7f577..70340b6f 100644 --- a/apstra/blueprint/node_system.go +++ b/apstra/blueprint/node_system.go @@ -81,6 +81,7 @@ func (o *NodeTypeSystem) AttributesFromApi(ctx context.Context, client *apstra.C if !ok { if o.NullWhenNotFound.ValueBool() { o.Attributes = types.ObjectNull(NodeTypeSystemAttributes{}.AttrTypes()) + return } diags.AddError("Node not found", fmt.Sprintf("Node with ID %q not found in blueprint %q", @@ -97,6 +98,7 @@ func (o *NodeTypeSystem) AttributesFromApi(ctx context.Context, client *apstra.C if !ok { if o.NullWhenNotFound.ValueBool() { o.Attributes = types.ObjectNull(NodeTypeSystemAttributes{}.AttrTypes()) + return } diags.AddError("Node not found", fmt.Sprintf("Node with Name %q not found in blueprint %q", From 2dd4fb50383b926b26de35b8ea3a78ff0dd9891a Mon Sep 17 00:00:00 2001 From: bwjuniper Date: Wed, 30 Oct 2024 13:28:19 -0700 Subject: [PATCH 3/3] go fumpt --- apstra/blueprint/node_system.go | 1 + 1 file changed, 1 insertion(+) diff --git a/apstra/blueprint/node_system.go b/apstra/blueprint/node_system.go index 70340b6f..c195f887 100644 --- a/apstra/blueprint/node_system.go +++ b/apstra/blueprint/node_system.go @@ -3,6 +3,7 @@ package blueprint import ( "context" "fmt" + "github.com/Juniper/apstra-go-sdk/apstra" "github.com/Juniper/terraform-provider-apstra/apstra/utils" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator"