mirror of
https://github.com/coder/terraform-provider-envbuilder.git
synced 2025-07-26 13:27:51 +00:00
fix: do not quote stringy env variables (#21)
This commit is contained in:
parent
72ddd72815
commit
d30006a40b
2 changed files with 7 additions and 5 deletions
internal/provider
|
@ -595,14 +595,16 @@ func extractEnvbuilderFromImage(ctx context.Context, imgRef, destPath string) er
|
|||
// Check IsUnknown() first before calling String().
|
||||
type stringable interface {
|
||||
IsUnknown() bool
|
||||
IsNull() bool
|
||||
String() string
|
||||
}
|
||||
|
||||
func appendKnownEnvToList(list types.List, key string, value stringable) types.List {
|
||||
if value.IsUnknown() {
|
||||
if value.IsUnknown() || value.IsNull() {
|
||||
return list
|
||||
}
|
||||
elem := types.StringValue(fmt.Sprintf("%s=%s", key, value.String()))
|
||||
val := strings.Trim(value.String(), `"`)
|
||||
elem := types.StringValue(fmt.Sprintf("%s=%s", key, val))
|
||||
list, _ = types.ListValue(types.StringType, append(list.Elements(), elem))
|
||||
return list
|
||||
}
|
||||
|
|
|
@ -92,9 +92,9 @@ func TestAccCachedImageDataSource(t *testing.T) {
|
|||
resource.TestCheckResourceAttr("envbuilder_cached_image.test", "exists", "true"),
|
||||
resource.TestCheckResourceAttrSet("envbuilder_cached_image.test", "image"),
|
||||
resource.TestCheckResourceAttrWith("envbuilder_cached_image.test", "image", quotedPrefix(deps.CacheRepo)),
|
||||
resource.TestCheckResourceAttr("envbuilder_cached_image.test", "env.0", "FOO=\"bar\""),
|
||||
resource.TestCheckResourceAttr("envbuilder_cached_image.test", "env.1", fmt.Sprintf("ENVBUILDER_CACHE_REPO=%q", deps.CacheRepo)),
|
||||
resource.TestCheckResourceAttr("envbuilder_cached_image.test", "env.2", fmt.Sprintf("ENVBUILDER_GIT_URL=%q", deps.Repo.URL)),
|
||||
resource.TestCheckResourceAttr("envbuilder_cached_image.test", "env.0", "FOO=bar"),
|
||||
resource.TestCheckResourceAttr("envbuilder_cached_image.test", "env.1", fmt.Sprintf("ENVBUILDER_CACHE_REPO=%s", deps.CacheRepo)),
|
||||
resource.TestCheckResourceAttr("envbuilder_cached_image.test", "env.2", fmt.Sprintf("ENVBUILDER_GIT_URL=%s", deps.Repo.URL)),
|
||||
),
|
||||
},
|
||||
// Should produce an empty plan after apply
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue