Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX(#1158): add support for helm literal values #1510

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions helm/data_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
},
Expand Down Expand Up @@ -167,7 +167,7 @@ func dataTemplate() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"auto", "string",
"auto", "string", "literal",
}, false),
},
},
Expand Down
8 changes: 6 additions & 2 deletions helm/resource_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
},
Expand Down Expand Up @@ -204,7 +204,7 @@ func resourceRelease() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{
"auto", "string",
"auto", "string", "literal",
}, false),
},
},
Expand Down Expand Up @@ -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)
}
Expand Down
21 changes: 21 additions & 0 deletions helm/resource_release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading