From 2d78e152a0551dfa56f3f82ea1f9943a46c1f99a Mon Sep 17 00:00:00 2001 From: MinUk Song Date: Wed, 31 Jan 2024 17:08:07 +0900 Subject: [PATCH] fix: Add missed nil check --- internal/services/cidrs/type.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/internal/services/cidrs/type.go b/internal/services/cidrs/type.go index 1ea9de5..742d8c2 100644 --- a/internal/services/cidrs/type.go +++ b/internal/services/cidrs/type.go @@ -44,8 +44,14 @@ func (t SpecType) Schema() *schema.Schema { func (t SpecType) Expand(ctx context.Context, d *schema.ResourceData, out *bluechip_models.CidrSpec) diag.Diagnostics { attr := d.Get("spec.0").(map[string]any) - out.Ipv4Cidrs = fwflex.ExpandStringSet(attr["ipv4_cidrs"].(*schema.Set)) - out.Ipv6Cidrs = fwflex.ExpandStringSet(attr["ipv6_cidrs"].(*schema.Set)) + + if attr["ipv4_cidrs"] != nil { + out.Ipv4Cidrs = fwflex.ExpandStringSet(attr["ipv4_cidrs"].(*schema.Set)) + } + + if attr["ipv6_cidrs"] != nil { + out.Ipv6Cidrs = fwflex.ExpandStringSet(attr["ipv6_cidrs"].(*schema.Set)) + } return nil }