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

WiP use yqlib for yaml parsing and processing #329

Closed
wants to merge 1 commit into from

Conversation

ndeloof
Copy link
Collaborator

@ndeloof ndeloof commented Dec 19, 2022

This is an experiment to use yblib to load compose files

this will replace the existing logic:

  1. parse yaml file (goyaml.v2) into map[string]interface{}
  2. interpolate variables
  3. map to go structures (using mapstructure) and transform "short" into "long" syntax
  4. merge config files from go structures (mergo)

by

  1. parse yaml files (goyaml.v3) using yqlib
  2. merge yaml trees
  3. interpolate variables
  4. transform "short" into "log" syntax
  5. map yaml tree to go structs

beenfits using yqlib:

  • yq is a popular, battle-tested yaml processing command line
  • yq fully supports file merges, both with "override" and "append" logic
  • yq uses a navigation syntax (same as jq) to select nodes in the yaml tree, we can use to define transformation logic. Typically ".services.*.ports.[]": transformPorts
  • yq is up-to-date and uses goyaml.v3

this will also help implement compose-spec/compose-spec#284 as we can detect an null node and override, while mergo comes to late to distinguish null vs default value.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
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.

None yet

1 participant