Skip to content

Commit

Permalink
Merge pull request hashicorp#74 from stevenaldinger/issue/64
Browse files Browse the repository at this point in the history
fixes issue/64: Add helms set-string option (set_string)
  • Loading branch information
mcuadros authored Sep 12, 2018
2 parents bbe6beb + 73a0d2f commit 929a28e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ resource "helm_release" "my_database" {
name = "mariadbPassword"
value = "qux"
}
set_string {
name = "image.tags"
value = "registry\\.io/terraform-provider-helm\\,example\\.io/terraform-provider-helm"
}
}
```

Expand Down
30 changes: 29 additions & 1 deletion helm/resource_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,23 @@ func resourceRelease() *schema.Resource {
},
},
},
"set_string": {
Type: schema.TypeSet,
Optional: true,
Description: "Custom string values to be merge with the values.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
},
"value": {
Type: schema.TypeString,
Required: true,
},
},
},
},
"namespace": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -306,7 +323,7 @@ func resourceReleaseRead(d *schema.ResourceData, meta interface{}) error {
return err
}

// d.Set("values_source_detected_md5", d.Get("values_sources_md5"))
// d.Set("values_source_detected_md5", d.Get("values_sources_md5"))

return setIDAndMetadataFromRelease(d, r)
}
Expand Down Expand Up @@ -520,6 +537,17 @@ func getValues(d *schema.ResourceData) ([]byte, error) {
}
}

for _, raw := range d.Get("set_string").(*schema.Set).List() {
set := raw.(map[string]interface{})

name := set["name"].(string)
value := set["value"].(string)

if err := strvals.ParseIntoString(fmt.Sprintf("%s=%s", name, value), base); err != nil {
return nil, fmt.Errorf("failed parsing key %q with value %s, %s", name, value, err)
}
}

yaml, err := yaml.Marshal(base)
if err == nil {
log.Printf("---[ values.yaml ]-----------------------------------\n%s\n", yaml)
Expand Down

0 comments on commit 929a28e

Please sign in to comment.