argoproj / argoproj/argo-workflows
enum from configMapKeyRef, secretKeyRef
- Dominant language
- Go
- Stars
- 17k
- Forks
- 3.7k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 138
Description
## Summary
Workflow `spec.arguments.parameters` should support an `enumFrom` argument that works in a similar manner to the `valueFrom`
## Use Cases
We currently use workflows for CRUD operations involving ephemeral environments. "enum" is super helpful to provide developers with a list of options to select from. Our current workflows for upgrading and uninstalling applications within an env looks like:
```yaml
kind: Workflow
metadata:
generateName: upgrade-application-
spec:
arguments:
parameters:
- name: destination
enum:
- us/prod
- us/uat
- us/qa-foobar
---
kind: Workflow
metadata:
generateName: uninstall-application-
spec:
arguments:
parameters:
- name: destination
enum:
- us/prod
- us/uat
- us/qa-foobar
```
Some developers can also create new environments using a `create-environment` workflow. In addition to other things the `create-environment` workflow modifies the workflow templates for `uninstall-application` and `upgrade-application` by adding the new destination to the list of enums. The `destroy-environment` workflow does the same, it modifies the workflow templates and removes a destination from the enum options.
It would be far easier if the workflow template could fetch the enum values from an external resource, similar to how the "value" can be fetched using valueFrom.configMapKeyRef.
## Proposed Syntax
```yaml
---
kind: Workflow
metadata:
generateName: uninstall-application-
spec:
arguments:
parameters:
- name: destination
enumFrom:
configMapKeyRef:
name: simple-parameters
key: my-destinations
```
The current way we do this is rather janky and prone to errors.
```
yq e -i "(.spec.arguments.parameters[] | select(.name == \"destination\") | .enum) |= . + [\"${NEW_DESTINATION}\"]" uninstall-application.yaml
```
This feature could be useful when many workflows have to share some common elements from a single source of truth (the configmap)
---
**Message from the maintainers**:
Love this enhancement proposal? Give it a 👍. We prioritise the proposals with the most 👍.
Contributor guide
Research direction
Start by tracing how spec.arguments.parameters currently handles enum and valueFrom.configMapKeyRef. Define the behavior and validation for enumFrom, including the proposed configMapKeyRef syntax, then add coverage showing that enum values can be sourced from the external resource and that the resulting parameter options are usable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- backend-api-design, cloud
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100