0
0
mirror of https://github.com/bpg/terraform-provider-proxmox.git synced 2025-07-01 02:52:58 +00:00

fix(file): spurious unsupported content type warning (#395)

This commit is contained in:
Pavel Boldyrev 2023-07-01 08:52:42 -04:00 committed by GitHub
parent e9a74e9037
commit 4da2b682de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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,
),
},
}...)