From a583b800a4d8c8c76af28785e11644736b418af5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 18 Jul 2014 17:20:56 -0700 Subject: [PATCH] config: add unknownKeys to Merge --- config/merge.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/config/merge.go b/config/merge.go index 29c68a5f6..be5bb39af 100644 --- a/config/merge.go +++ b/config/merge.go @@ -4,9 +4,26 @@ import ( "fmt" ) +// Merge merges two configurations into a single configuration. +// +// Merge allows for the two configurations to have duplicate resources, +// because the resources will be merged. This differs from a single +// Config which must only have unique resources. func Merge(c1, c2 *Config) (*Config, error) { c := new(Config) + // Merge unknown keys + unknowns := make(map[string]struct{}) + for _, k := range c1.unknownKeys { + unknowns[k] = struct{}{} + } + for _, k := range c2.unknownKeys { + unknowns[k] = struct{}{} + } + for k, _ := range unknowns { + c.unknownKeys = append(c.unknownKeys, k) + } + // Merge variables: Variable merging is quite simple. Set fields in // later set variables override those earlier. c.Variables = c1.Variables