Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for merging multiple config files from variable #43

Merged
merged 7 commits into from
Jan 5, 2021

Conversation

mumoshu
Copy link
Owner

@mumoshu mumoshu commented Dec 31, 2020

To better support the use-case of dynamically generating configs from other configs and variables, the following changes are made:

  • Added paths to file config source. Either the existing path or paths is required.
    • All the files listed in paths are merged using mergo with mergo.WithOverride and mergo.WithOverwriteWithEmptyValue
  • config source's paths and path can now refer to vars. variant internally builds a DAG of vars, confs, and secs to make it possible.
  • Added function block to define user-functions, with support for recursive call. Note that user-functions are visible within a variant command that defines it.
    • This means two things:
      • You can't import user-functions
      • User-functions defined in the parent variant command are not visible to imported variant commands.
  • Added new example for config-depends-on-var use-case at examples/advanced/dynamic-config-inheritance
  • Added new example for importing variant command with local user-function at examples/advanced/userfunc-local-scope

Resolves #42

@mumoshu mumoshu changed the title WIP: Support for merging multiple config files from variable Support for merging multiple config files from variable Dec 31, 2020
This might be useful to avoid repetition while building complex and dynamic list of config files to be loaded.
…files in a dir)

This allows you to import another variant with `import` and `imports`, even if the imported variant command uses any user functions. Previously it was impossible due to that any `job` runs in the scope of the parent variant command that imported the command with user-functions.
@mumoshu mumoshu merged commit 5ca020a into master Jan 5, 2021
@mumoshu mumoshu deleted the config-source-file-paths branch January 5, 2021 00:58
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.

Feature Request: Support Variables in config { .... } and multiple configs for deep merging in a single source
1 participant