Skip to content

[helmcli] support YAMLValuesApplier helper function #25

@fuweid

Description

@fuweid

In #17, helmcli pkg allows to use key=value path string to update helm values.
For example, a.b.c=v path string is to represent the following YAML value.

a:
  b:
    c: v

kperf/helmcli/release.go

Lines 32 to 41 in 636d5a4

func StringPathValuesApplier(values ...string) ValuesApplier {
return func(to map[string]interface{}) error {
for _, v := range values {
if err := strvals.ParseInto(v, to); err != nil {
return fmt.Errorf("failed to parse (%s) into values: %w", v, err)
}
}
return nil
}
}

However, StringPathValuesApplier doesn't support array value type.
For instance, for the following YAML value, we can't use key=value format to represent it.

a:
- 1
- 2
- 3

So, we need to introduce new helper function: YAMLValuesApplier.

Since the helm values' type is map[string]interface{}, we need to unmarshal YAML into map[string]interface{} as well and then merge two values.

REF: https://github.com/kubernetes-sigs/yaml

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions