Skip to content

Deep merge of values files #1620

Closed
Closed

Description

@thomastaylor312

Helm should be able to deep merge multiple values files. This is helpful when you want to pass different variables for different environments (like whether or not to use a PVC) As it stands right now, it just overwrites the previous variable.

Example

Given these two values files for an example postgresql subchart

secrets.yaml

postgresql:
  postgresPassword: "super-secret-pass"

dev_environment.yaml

postgresql:
  persistence:
    enabled: false

Current Behavior
When using -f secrets.yaml -f dev_environment.yaml with helm install, the variables available would look like this:

postgresql:
  persistence:
    enabled: false

If we swap the flags: -f dev_environment.yaml -f secrets.yaml, the variables look like:

postgresql:
  postgresPassword: "super-secret-pass"

Desired Behavior
When using -f secrets.yaml -f dev_environment.yaml with helm install, the variables available would look like this:

postgresql:
  postgresPassword: "super-secret-pass"
  persistence:
    enabled: false

Is there another way to get this behavior or would this need to be added?

Activity

  1. thomastaylor312 commented on Dec 1, 2016

    @thomastaylor312
    ContributorAuthor

    Side note: I know that this would make the ordering of the files passed with the -f flag important, because if there are variables with the same name, one would overwrite the others.

  2. technosophos commented on Dec 1, 2016

    @technosophos
    Member

    I am not sure Cobra will allow us to repeat flags. But if we can figure out a way around that, I think we could just pass files through the existing -f/--set merge logic.

    We might be able to change -f to accept a []string, which (IIRC) is expressed on CLI as -f foo.yaml,bar.yaml.

  3. added this to the milestone on Dec 1, 2016
  4. thomastaylor312 commented on Dec 2, 2016

    @thomastaylor312
    ContributorAuthor

    @technosophos: Thanks for the quick response. It looks like it does (from the godoc example):

    // Set is the method to set the flag value, part of the flag.Value interface.
    // Set's argument is a string to be parsed to set the flag.
    // It's a comma-separated list, so we split it.
    func (i *interval) Set(value string) error {
        // If we wanted to allow the flag to be set multiple times,
        // accumulating values, we would delete this if statement.
        // That would permit usages such as
        //	-deltaT 10s -deltaT 15s
        // and other combinations.
        if len(*i) > 0 {
            return errors.New("interval flag already set")
        }
        for _, dt := range strings.Split(value, ",") {
            duration, err := time.ParseDuration(dt)
            if err != nil {
                return err
            }
            *i = append(*i, duration)
        }
        return nil
    }
    
  5. added 5 commits that reference this issue on Dec 7, 2016
    5e6774f
    e13e391
    0102bc5
    e0f5166
    1a1d84c
  6. modified the milestones: 2.1.0, on Dec 13, 2016
  7. added a commit that references this issue on Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions