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

Add ArrayEncodedMap #2750

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Commits on Apr 26, 2023

  1. Add ArrayEncodedMap

    It's a common pattern in Porter to represent a map of items, with a unique key, as a list in the porter.yaml or a file representation of the resource because the UX for autocomplete is better. We can't change that now, parameters and credentials for example will always be a list, but we can use a map in Porter's code so that it's easier to work with.
    
    I've added ArrayEncodedMap, a data structure that reads in a list and stores it in-memory as a map:
    
    - name: a
      value: stuff
    - name: b
      value: things
    
    We can use this as a base data structure initially for Parameter and Credential Sets, storing the mapping of the parameter/credential name to the secret resolution strategy. Over time, it may make sense to use it for the other data structures in porter.yaml as well.
    
    It has support for iterating as a map, or as a sorted list of values. The sorted list is good for unit tests, and anytime we need the output to be stable. The map isn't exposed directly and I have a funky "best you can do with Go" iterator to help keep our for loops looking pretty normal.
    
    Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
    carolynvs committed Apr 26, 2023
    Configuration menu
    Copy the full SHA
    c86de16 View commit details
    Browse the repository at this point in the history