Custom resources or ConfigMaps are parsed into a user defined case class(es). Besides parsing, Freya converts a user defined case class for status into a JSON string.
Supported libraries to parse JSON/YAML:
Add import statement at place of constructing your operator:
Jackson Scala module allows parsing simple case classes (no ADT, recursion, etc.) automatically, i.e. no extra code needs to be written. Thus, only import of the Freya Jackson module is needed.
Circe can derive its decoder/encoders automatically, when using its
generic module with special import.
Circe auto codecs derivation requires below module in your dependency settings:
Let's use ADT (algebraic data types) to design custom resource case class for
Secret properties. Also, some classes will have default values.
Jackson provides several annotations to configure deserialisation for enum-like classes:
Circe provides generic-extras module to cope with above hierarchy of case classes:
Define encoders and decoders. Let's wrap decoders into a Scala trait for later convenient injection into the operator construction site. However, usage of a trait is not necessarily:
Then mixin or import all implicit values from the
Codecs trait into the operator construction site.