helmsman icon indicating copy to clipboard operation
helmsman copied to clipboard

appsTemplates and multiple desired state files

Open galindro opened this issue 6 years ago • 4 comments

Hello. First of all congratulations for your work. This project is really very nice.

I would like to being able to define appsTemplates in one DSF and use them in other DSF. But, I'm getting this error:

$ helmsman -debug -subst-env-values -f main.yaml -f teleport.yaml 

 _          _ 
| |        | | 
| |__   ___| |_ __ ___  ___ _ __ ___   __ _ _ __
| '_ \ / _ \ | '_ ` _ \/ __| '_ ` _ \ / _` | '_ \ 
| | | |  __/ | | | | | \__ \ | | | | | (_| | | | | 
|_| |_|\___|_|_| |_| |_|___/_| |_| |_|\__,_|_| |_| version: v3.0.0
A Helm-Charts-as-Code tool.

2020-01-19 13:57:20 DEBUG: helm version --short -c
2020-01-19 13:57:20 DEBUG: kubectl version --client --short
2020-01-19 13:57:20 DEBUG: kubectl 
2020-01-19 13:57:21 DEBUG: helm 
2020-01-19 13:57:21 DEBUG: helm plugin list
2020-01-19 13:57:21 INFO: Parsed YAML [[ main.yaml ]] successfully and found [ 0 ] apps
2020-01-19 13:57:21 CRITICAL: yaml: unknown anchor 'defaults' referenced

This is the content of main.yaml:

helmRepos:
  my: "s3://my.s3.helm.repo"

appsTemplates:
  defaults: &defaults
    wait: true
    helmFlags:
      - "--atomic"

This is the content of teleport.yaml:

namespaces:
  teleport:

apps:
  teleport:
    name: "teleport"
    <<: *defaults
    namespace: "teleport"
    enabled: $TELEPORT_ENABLED
    chart: "my/teleport"
    version: "$TELEPORT_VERSION"
    protected: $TELEPORT_PROTECTION
    valuesFile: "values/teleport.yaml"

Is it a helmsman's well know behavior or a bug or mergo limitation?

galindro avatar Jan 19 '20 13:01 galindro

Hi @galindro,

appsTemplates was not introduced with such mergo tool in mind back then. Since I'm not familiarise with mergo, I can only tell that an anchor of &defaults in YAML can be referenced only in the same YAML file it was originally defined. So your specific use case is that you're having more than one DSF (which are not standalone) and you are merging them into one before running Helmsman with final file?

mkubaczyk avatar Jan 19 '20 16:01 mkubaczyk

Hi @mkubaczyk Actually I'm not merging them before execute helmsman. I'm just using helmsman multiple DSF feature. Therefore, what I'm trying to do is to reuse the a defined appsTemplates that lives in one DSF among multiple DSFs.

galindro avatar Mar 13 '20 17:03 galindro

appsTemplates is actually ignored by Helmsman and that's why it doesn't get merged. But I'm also not sure if it would make any difference, merging happens after unmarshelling and the anchors and aliases are handled during unmarshaling. I think this is more like a yaml limitation.

luisdavim avatar Apr 11 '20 00:04 luisdavim

This issue has been marked stale due to an inactivity.

github-actions[bot] avatar Aug 10 '22 05:08 github-actions[bot]