mayope / keycloakmigration

Manage your Keycloak configuration with code.
https://mayope.net
MIT License
108 stars 22 forks source link

Detection of unused parameter substitutions #14

Closed sideisra closed 4 years ago

sideisra commented 4 years ago

At the moment the parameter substitution works silently. A placeholder (${VAR}) will be substituted with the corresponding parameter, if the parameter exists. When the parameter does not exist two things can happen: when the placeholder is the value of a boolean flag the parsing of the changeset fails and the migration aborts, when the placeholder is part of a string value it is not replaced and the migration continues silently.

It would be great when the usage of placeholders is more transparent. My suggestion is that the parameter replacement has two modes:

  1. warning mode: the migration writes warnings in the log when a parameter for a placeholder is not set but continues the migration
  2. error mode: the migration writes errors in the log when a parameter for a placeholder is not set and aborts the migration

In both modes the migration fails when a boolean value is not set correctly ("true" or "false")

klg71 commented 4 years ago

Hello @sideisra thanks for opening this issue. I think I should be able to make an implementation proposal.

klg71 commented 4 years ago

First thing i noticed was that, I have some implicit features in the environmet substitution I didn't document.

For the environment substitution I use the apache commons-text library specifically the class: StringSubstitutor, so for example you can give it default values with the ${undefinedValue:-1234} syntax (default value is after ":-" )

Also you can use interpolation to resolve files or base64 etc but i would need to turn on string interpolation.

klg71 commented 4 years ago

Released with version 0.1.38 please review :)