accesscontroltool icon indicating copy to clipboard operation
accesscontroltool copied to clipboard

Clean up YAML handling

Open kwin opened this issue 6 years ago • 2 comments

The current parsing logic for translating the YAML files into Java classes is a bit convoluted and also leads to issues like #364. We should clean this up and

  1. Upgrade to YAML Spec 1.2 (that means switching to https://bitbucket.org/asomov/snakeyaml-engine/src/default/ for parsing)
  2. Simplify YAML -> Pojo mapping by leveraging the approach from https://www.baeldung.com/java-snake-yaml#custom-type
  3. Make configuration pojos immutable classes (get rid of the setters)
  4. Make configuration pojos expose the parsed values only (not raw data which needs to be post-processed, like Strings which are supposed to be split)
  5. Leverage YAML Collections for multi-value properties
  6. Come up with builder classes to construct the config pojos from the repo state
  7. Add unit tests for parsing and dumping
  8. Leverage variable substitution from snakeyaml (https://bitbucket.org/asomov/snakeyaml-engine/wiki/Documentation#markdown-header-variable-substitution)
  9. Come up with a Schema (JSON?) which should be used to validate the YAML files prior to parsing.

kwin avatar May 23 '19 07:05 kwin

At the same time it would probably be wise to get rid of lists of associative arrays in case the keys are unique. I.e. instead of

- user_config:
  - user1:
    - somesomething: somevalue

rather do

user_config:
  user1:
    something: somevalue

kwin avatar Dec 03 '19 14:12 kwin

Alternatively we could consider switching from SnakeYaml to Jackson.

kwin avatar Jun 04 '21 06:06 kwin