From 946d9f6cfbab40a94709d6abd73fce9f1e4b6fc2 Mon Sep 17 00:00:00 2001 From: Tom Schutte Date: Tue, 5 Mar 2024 15:55:29 -0600 Subject: [PATCH] Always base64 encode filter content strings handle things like 'true' which are valid base64 strings but still need to be encoded. --- internal/provider/filter_resource.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/internal/provider/filter_resource.go b/internal/provider/filter_resource.go index c7b114c..90706a5 100644 --- a/internal/provider/filter_resource.go +++ b/internal/provider/filter_resource.go @@ -129,18 +129,9 @@ func (r *FilterResource) Create(ctx context.Context, req resource.CreateRequest, var createFilter Ambar.CreateFilterRequest createFilter.Description = plan.Description.ValueStringPointer() - // Filters we encode the content string in base64 for API requests to compact complex filters and prevent white spaces - // from giving any issues. If the customer already encoded the contents, great. But it is not required. So we will - // check if they already did it, and otherwise encode it. - _, err := base64.StdEncoding.DecodeString(plan.FilterContents.ValueString()) - if err != nil { - // decoding failed, and we will want to encode and assign - encodedContents := base64.StdEncoding.EncodeToString([]byte(plan.FilterContents.ValueString())) - createFilter.FilterContents = encodedContents - } else { - // customer already base64 encoded, so just pass it on through. - createFilter.FilterContents = plan.FilterContents.ValueString() - } + // Encode the customers filter string + encodedContents := base64.StdEncoding.EncodeToString([]byte(plan.FilterContents.ValueString())) + createFilter.FilterContents = encodedContents createFilter.DataSourceId = plan.DataSourceId.ValueString()