From 6169aa3331cfc73c57f1adf83063bb662fd4a935 Mon Sep 17 00:00:00 2001 From: David Fialho Date: Thu, 9 Jan 2025 15:39:41 +0000 Subject: [PATCH] Fix import failures on old teams locations Recently a change was made to teams locations which adds the "endpoints" field. However, old locations still don't have that field. The provider was failing to read these old locations because it was assuming the field was there. This was fixed by excluding this field when not available. --- .changelog/4859.txt | 3 +++ internal/sdkv2provider/resource_cloudflare_teams_location.go | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 .changelog/4859.txt diff --git a/.changelog/4859.txt b/.changelog/4859.txt new file mode 100644 index 0000000000..e8880bba67 --- /dev/null +++ b/.changelog/4859.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/cloudflare_teams_location: Fix import failures on teams locations +``` diff --git a/internal/sdkv2provider/resource_cloudflare_teams_location.go b/internal/sdkv2provider/resource_cloudflare_teams_location.go index 5b2301ae66..fcf8f855c0 100644 --- a/internal/sdkv2provider/resource_cloudflare_teams_location.go +++ b/internal/sdkv2provider/resource_cloudflare_teams_location.go @@ -386,6 +386,9 @@ func flattenTeamsLocationNetworksIntoList(networks []cloudflare.TeamsLocationNet } func flattenTeamsEndpoints(endpoint *cloudflare.TeamsLocationEndpoints) []interface{} { + if endpoint == nil { + return nil + } flattenedEndpoints := map[string]interface{}{ "ipv4": flattenTeamsEndpointIpv4Field(endpoint.IPv4Endpoint), "ipv6": flattenTeamsEndpointIpv6Field(endpoint.IPv6Endpoint),