Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Feature: Ability to lookup a value from an outside file or current yaml document and use it within a format marker #118

Open
ahuffman opened this issue Sep 2, 2022 · 1 comment

Comments

@ahuffman
Copy link
Contributor

ahuffman commented Sep 2, 2022

This is a decent use case where I'd like to look something up with a query within the same file or an external file, and plug it's value into somewhere within a yaml file (terrible statement). This may be something better suited for pure templating, but I think this could reduce some of the needs for templating in general. This needs to be thought out more, but I wanted to capture the idea.

Example:

File 1 - To look up a value I'd like to use in my overlays

---
some:
  stuff:
     here: cool
other:
  stuff:
    here:
      a: apple
      b: banana

Instructions file feature usage

---
# "path" key optional and would lookup a reference in the original yaml document?
references:
  - name: ref1 
    path: ./file1.yaml
    query: some.stuff.here
  - name: ref2
    path: ./file2.yaml
    query: other.stuff.here[b]

yamlFiles:
  - path: /file/to/modify.yaml
    overlays:
      - name: Use ref1
        query: metadata.labels[app.kubernetes.io/name]
        value: "%r{ref1}"
        action: replace
      - name: Use ref2
        query: kind
        value: "%r{ref2}"
        action: replace

Expected Behavior:

  1. overlay 1 replaces the value of metadata.labels['app.kubernetes.io/name'] with the value of cool
  2. overlay 2 replaces the value of kind with the value banana

I'd like to use this to lookup and reference maps and arrays as well.

A use for this would be I deploy a bunch of stuff with Terraform and then spit it out in an orderly way with a template.

Then I want to populate a yaml based variables file with some of the info that I spit out from the terraform steps by looking up those references from the output to create a new yaml file that is properly configured for my new environment before further automation runs.

@ahuffman
Copy link
Contributor Author

ahuffman commented Sep 2, 2022

We do have the %v{r somefile.yaml}, but I want to look up (query) that file for the dynamic value's contents.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant