fix(internal/provider): correct escaping of strings in envbuilder_cached_image.env ()

Fixes 

We had previously been doing the equivalent of value.String() when writing envbuilder_cached_image.env. This was incorrectly escaping newlines, potentially breaking ENVBUILDER_INIT_SCRIPT.

This PR modifies the behaviour to correctly handle string values via ValueString() instead.
This commit is contained in:
Cian Johnston 2024-08-14 14:55:22 +01:00 committed by GitHub
commit 68cc59d705
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 36 additions and 25 deletions
examples/resources/envbuilder_cached_image

View file

@ -66,10 +66,11 @@ resource "envbuilder_cached_image" "example" {
builder_image = var.builder_image
git_url = var.repo_url
cache_repo = local.cache_repo
insecure = true
extra_env = {
"ENVBUILDER_VERBOSE" : "true"
"ENVBUILDER_INSECURE" : "true" # due to local registry
"ENVBUILDER_INIT_SCRIPT" : "sleep infinity"
"ENVBUILDER_INIT_SCRIPT" : "#!/usr/bin/env bash\necho Hello && sleep infinity"
"ENVBUILDER_PUSH_IMAGE" : "true"
}
depends_on = [docker_container.registry]
@ -77,8 +78,8 @@ resource "envbuilder_cached_image" "example" {
// Run the cached image. Depending on the contents of
// the cache repo, this will either be var.builder_image
// or a previously built image pusehd to var.cache_repo.
// Running `terraform apply` once (assuming empty cache)
// or a previously built image pushed to var.cache_repo.
// Running `terraform apply` once (assuming empty cache)
// will result in the builder image running, and the built
// image being pushed to the cache repo.
// Running `terraform apply` again will result in the
@ -105,4 +106,3 @@ output "id" {
output "image" {
value = envbuilder_cached_image.example.image
}