Skip to content

Conversation

MatteoVoges
Copy link

@MatteoVoges MatteoVoges commented Mar 20, 2023

Proposed Changes

  • Added support for specifying default values for non existing keys / dictionary-paths
  • Extended functionality to support a reference-tag as default value, e.g. ${spec:value||${default:value||another-default}}
  • Use || as delimiter, because it fits well in the kapitan ecosystem

Examples

parameters:
  existing:
    key: myvalue

  foo: ${non:existing:key||bar} # --> bar (default value)
  mykey: ${existing:key||bar} # --> myvalue (value exists)
parameters:
  defaults:  
    default1: myDefault

  spec:
    spec1: ${not:existing||${defaults:default1}} # --> myDefault (tag in default-value exists)
    spec2: ${not:existing||${defaults:notfound||fallback}} # --> fallback (tag in default-value not exists, default gets taken) 

Breaking changes

  • You should not have the || - delimiter in your yaml-keys anymore!

To Do

  • Add tests
  • Add documentation (also in kapitan docs)
    @ademariag Where should this be done?

Contributed by

@MatteoVoges MatteoVoges marked this pull request as ready for review March 21, 2023 10:35
@MatteoVoges MatteoVoges force-pushed the develop branch 2 times, most recently from 95f2f70 to 2f9f2ac Compare March 22, 2023 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant