From 4da2b682de1f2c7f456c6f7c7bc06048881cb8b9 Mon Sep 17 00:00:00 2001 From: Pavel Boldyrev <627562+bpg@users.noreply.github.com> Date: Sat, 1 Jul 2023 08:52:42 -0400 Subject: [PATCH] fix(file): spurious unsupported content type warning (#395) --- proxmoxtf/resource/file.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/proxmoxtf/resource/file.go b/proxmoxtf/resource/file.go index ba566017b..4785e3788 100644 --- a/proxmoxtf/resource/file.go +++ b/proxmoxtf/resource/file.go @@ -17,6 +17,7 @@ import ( "net/url" "os" "path/filepath" + "sort" "strings" "time" @@ -404,13 +405,15 @@ func fileCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag return diag.Errorf("failed to determine the datastore path") } + sort.Strings(datastore.Content) + _, found := slices.BinarySearch(datastore.Content, *contentType) if !found { diags = append(diags, diag.Diagnostics{ diag.Diagnostic{ Severity: diag.Warning, - Summary: fmt.Sprintf("the datastore %q does not support content type %q", - *datastore.Storage, *contentType, + Summary: fmt.Sprintf("the datastore %q does not support content type %q; supported content types are: %v", + *datastore.Storage, *contentType, datastore.Content, ), }, }...)