Skip to content

Commit

Permalink
Merge pull request #241 from shalb/helm-set-values
Browse files Browse the repository at this point in the history
Helm set values
  • Loading branch information
romanprog authored Nov 18, 2023
2 parents 79620d8 + 5ab6f87 commit 027fcf8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
15 changes: 11 additions & 4 deletions docs/units-helm.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,13 @@ units:
values:
- file: ./argo/values.yaml
apply_template: true
- set:
global:
image:
tag: "v1.8.3"
- set: {{ insertYaml .varables.argocd.values }}
inputs:
global.image.tag: v1.8.3
global.image.tag: v1.8.3 # (same as values.set )
```
In addition to common options the following are available:
Expand All @@ -39,11 +44,13 @@ In addition to common options the following are available:

* `additional_options` - *map of any*, *optional*. Corresponds to [Terraform helm_release resource options](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release#argument-reference). Will be passed as is.

* `values` - *array*, *optional*. List of values files in raw yaml to be passed to Helm. Values will be merged, in order, as Helm does with multiple -f options.
* `values` - *array*, *optional*. List of values (file name or values data) to be passed to Helm. Values will be merged, in order, as Helm does with multiple -f options.

* `file` - *string*, *required*. Path to the values file.
* `set` - *map of any*, *required one of set/file*. Set of helm values.

* `apply_template` - *bool*, *optional*. Defines whether a template should be applied to the values file. By default is set to `true`.
* `file` - *string*, *required one of set/file*. Path to the values file.

* `apply_template` - *bool*, *optional*. Defines whether a template should be applied to the values file. By default is set to `true`. Used only with `file` option

* `inputs` - *map of any*, *optional*. A map that represents [Terraform helm_release sets](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release#set). This block allows to use functions `remoteState` and `insertYAML`. For example:

Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cdev/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var applyCmd = &cobra.Command{
return NewCmdErr(project, "apply", err)
}
err = project.LockState()
defer project.UnLockState()
if err != nil {
return NewCmdErr(project, "apply", err)
}
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/cdev/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var destroyCmd = &cobra.Command{
return NewCmdErr(project, "destroy", err)
}
err = project.LockState()
defer project.UnLockState()
if err != nil {
return NewCmdErr(project, "destroy", err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/cdev/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func Run() {
if p != nil {
st.ProjectID = p.UUID
if len(p.Backends) == 0 || p.Backends[p.StateBackendName] == nil {
st.BackendType = p.Backends[p.StateBackendName].Provider()
} else {
st.BackendType = "null"
} else {
st.BackendType = p.Backends[p.StateBackendName].Provider()
}
} else {
st.ProjectID = "null"
Expand Down
12 changes: 11 additions & 1 deletion pkg/units/shell/terraform/helm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,17 @@ func (u *Unit) ReadConfig(spec map[string]interface{}, stack *project.Stack) err
}
valuesFileName, ok := valuesCatMap["file"].(string)
if !ok {
return fmt.Errorf("read unit config: 'values.file' is required field")
setData, ok := valuesCatMap["set"].(map[string]interface{})
if !ok {
return fmt.Errorf("read unit config: one of 'values.file' or 'values.set' required")
}
u.ValuesYAML = append(u.ValuesYAML, setData)
yamlDaya, err := yaml.Marshal(setData)
if err != nil {
return fmt.Errorf("read unit config: %w", err)
}
u.ValuesFilesList = append(u.ValuesFilesList, string(yamlDaya))
continue
}
vfPath := filepath.Join(u.Stack().TemplateDir, valuesFileName)
valuesFileContent, err := os.ReadFile(vfPath)
Expand Down

0 comments on commit 027fcf8

Please sign in to comment.