class CNFInstall::Config::ConfigUpdater

Defined in:

tasks/utils/cnf_installation/config_updater/config_updater.cr

Constant Summary

VERSION_PARSERS = {ConfigVersion::V1 => ->(raw_input_config : String) do ConfigV1.from_yaml(raw_input_config) end}

Define parsing rules at the top of the class REQUIRES FUTURE EXTENSION in case of new config format.

VERSION_TRANSFORMATIONS = {ConfigVersion::V1 => ->(input_config : ConfigBase) do (V1ToV2Transformation.new(input_config.as(ConfigV1))).transform end}

This approach could be extended in future by making use of abstract classes, which would remove the need for hashes. Define transformation rules at the top of the class REQUIRES FUTURE EXTENSION in case of new config format.

Constructors

Instance Method Summary

Constructor Detail

def self.new(raw_input_config : String) #

[View source]

Instance Method Detail

def serialize_to_file(file_path : String) : String #

Serialize the updated config to a file and return the file path.


[View source]
def serialize_to_string : String #

Serialize the updated config to a string.


[View source]
def transform #

Performs the transformation from Vx to Vy. Uses the VERSION_TRANSFORMATIONS hash.


[View source]