defenseunicorns / defenseunicorns/uds-cli

Toggle variable substitution per `values` element.

Open
#1,031 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
54
Forks
21
Avg merge
2d 15h
Merged PRs (30d)
45

Description

### Is your feature request related to a problem? Please describe
When setting `values` within a uds-bundle.yaml, it is sometimes required that a literal environment variable key is passed on as an override. For example, this happens to be the case for Loki. In Loki, when the `config.expand-env` argument is called for the Loki binary, Loki will then expand references to environment variables (values matching the same [regex](https://github.com/defenseunicorns/uds-cli/blob/1761f29c9031c913435641fee7fb92bb77ea7880/src/pkg/bundle/overrides.go#L29) syntax as we use in UDS CLI) and use their values at runtime. However, if today you attempt to set the value of a helm values path to something like `"${EXAMPLE}"`, you would see the override value rendered as `${EXAMPLE_not_found}` because you did not set `${EXAMPLE}` with `UDS_EXAMPLE`, or with `--set`, or in `uds-config.yaml`.

Because it's a bit confusing to describe in words, here is what I want in the final configmap, after UDS has deployed my bundle/package/helm chart:
```yaml
kind: ConfigMap
metadata:
name: example-data
data:
myconf.yaml: |
some-setting: "${EXAMPLE}"
```

And here's how I'd like to supply that value to the configmap via uds-bundle:
```yaml
values:
- path: path.to.myconf.some-setting
value: "${EXAMPLE}"
```

Today I get

```
kind: ConfigMap
metadata:
name: example-data
data:
myconf.yaml: |
some-setting: "${EXAMPLE_not_found}"
```

### Describe the solution you'd like

- **Given** a state
- **When** an action is taken
- **Then** something happens

Given the presence of a value in uds-bundle.yaml that matches the [regex](https://github.com/defenseunicorns/uds-cli/blob/1761f29c9031c913435641fee7fb92bb77ea7880/src/pkg/bundle/overrides.go#L29), when I set the attribute `substitute` to `false` for the value matching the regex, with would like the UDS CLI to NOT attempt to substitute the value of the `value` key. E.g.

```yaml
values:
- path: path.to.myconf.some-setting
value: "${EXAMPLE}"
substitute: false
```

### Describe alternatives you've considered
You can currently work around this by turning the `values` element into a `variables` element and then setting, for example `UDS_EXAMPLE='${EXAMPLE}'`, which then just substitutes `${EXAMPLE}` in the uds-bundle.yaml with `${EXAMPLE}`. The same process works for `--set` or specifying the value to be substituted in `uds-config.yaml`, or even as a values.yaml passed as a valuesFile to the UDS package. This feels a bit clunky though, seeing as the name of the environment variable isn't likely to change all that often, so hardcoding it as a value is more clear.

### Additional context

Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.