diff --git a/helm/data_template.go b/helm/data_template.go index d3c686e46..5b1f71390 100644 --- a/helm/data_template.go +++ b/helm/data_template.go @@ -124,7 +124,7 @@ func dataTemplate() *schema.Resource { // TODO: use ValidateDiagFunc once an SDK v2 version of StringInSlice exists. // https://github.com/hashicorp/terraform-plugin-sdk/issues/534 ValidateFunc: validation.StringInSlice([]string{ - "auto", "string", + "auto", "string", "literal", }, false), }, }, @@ -167,7 +167,7 @@ func dataTemplate() *schema.Resource { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringInSlice([]string{ - "auto", "string", + "auto", "string", "literal", }, false), }, }, diff --git a/helm/resource_release.go b/helm/resource_release.go index 1cd41468d..61e40e712 100644 --- a/helm/resource_release.go +++ b/helm/resource_release.go @@ -161,7 +161,7 @@ func resourceRelease() *schema.Resource { // TODO: use ValidateDiagFunc once an SDK v2 version of StringInSlice exists. // https://github.com/hashicorp/terraform-plugin-sdk/issues/534 ValidateFunc: validation.StringInSlice([]string{ - "auto", "string", + "auto", "string", "literal", }, false), }, }, @@ -204,7 +204,7 @@ func resourceRelease() *schema.Resource { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringInSlice([]string{ - "auto", "string", + "auto", "string", "literal", }, false), }, }, @@ -1394,6 +1394,10 @@ func getValue(base, set map[string]interface{}) error { if err := strvals.ParseIntoString(fmt.Sprintf("%s=%s", name, value), base); err != nil { return fmt.Errorf("failed parsing key %q with value %s, %s", name, value, err) } + case "literal": + if err := strvals.ParseLiteralInto(fmt.Sprintf("%s=%s", name, value), base); err != nil { + return fmt.Errorf("failed parsing key %q with value %s, %s", name, value, err) + } default: return fmt.Errorf("unexpected type: %s", valueType) } diff --git a/helm/resource_release_test.go b/helm/resource_release_test.go index 4187f3de0..5f7059771 100644 --- a/helm/resource_release_test.go +++ b/helm/resource_release_test.go @@ -1266,6 +1266,27 @@ func TestGetValuesString(t *testing.T) { } } +func TestGetValuesLiteral(t *testing.T) { + d := resourceRelease().Data(nil) + err := d.Set("set", []interface{}{ + map[string]interface{}{"name": "foo", "value": "{[]_who", "type": "literal"}, + }) + if err != nil { + t.Fatalf("error setting values: %s", err) + return + } + + values, err := getValues(d) + if err != nil { + t.Fatalf("error getValues: %s", err) + return + } + + if values["foo"] != "{[]_who" { + t.Fatalf("error merging values, expected %q, got %s", "{[]_who", values["foo"]) + } +} + func TestUseChartVersion(t *testing.T) { type test struct {