Allow overriding variable choices via choices.d/<name>.yml - #135
Allow overriding variable choices via choices.d/<name>.yml#135arvind4501 wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
df12084 to
7602655
Compare
|
Is |
i have not thought about that, i think we don't want to override the options/vars which is expose by obsah. i went with choices because thats something i think could vary between distributions of foremanctl. |
|
Yeah, right now we do not need that. I just wonder if by explicitly calling this "choices override" we put us into a corner which we will need coordinated migration (as the paths and structure will be used in a different repository that actually declares the overrides) if we ever decide in the future we need more fields. |
Any thoughts on masking exposed options? I can imagine we'd have some options in upstream that shouldn't be possible in downstream. |
yes, that's something to think about, i have not thought that far ahead but if you have suggestions about making it more general than overriding "just choices" , i would love to apply that |
Summary
choiceslist without editing itsmetadata.obsah.yaml. If a variable declareschoicesin metadata, obsah will now also look forchoices.d/<variable_name>.ymlnext to the playbook's metadata file; if present, its contents fully replace the metadata-defined choices for that variable.flavorvariable) per deployment/distribution without forking or patching the upstream playbook's metadata.choices.d/<name>.ymlfile exists, behavior is unchanged — the metadata'schoicesare used as before.Example
metadata.obsah.yaml:choices.d/flavor.yml:Result: the
flavorvariable's choices become[alpha, beta], completely replacing[gamma].Note: the override is only consulted for variables that already declare a
choiceskey in metadata (even a placeholder value); variables without achoiceskey are unaffected.Test plan
tests/test_choices_directory.pywith a new fixture playbook (tests/fixtures/playbooks/choices_file/) covering both the override and fallback (no-override) cases.tests/fixtures/help.txt/help-3.12.txtgolden files to include the new fixture playbook in the parser help output.pytest tests/); all tests pass except pre-existing, environment-specific failures unrelated to this change (sandbox lacks permission to write to~/.ansible/tmp).Made with Cursor