Skip to content

Commit

Permalink
fix(file): spurious unsupported content type warning (#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpg authored Jul 1, 2023
1 parent e9a74e9 commit 4da2b68
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions proxmoxtf/resource/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"net/url"
"os"
"path/filepath"
"sort"
"strings"
"time"

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

0 comments on commit 4da2b68

Please sign in to comment.