Skip to content

Commit

Permalink
fix: allow loading of empty config files
Browse files Browse the repository at this point in the history
Fixes #3113.

Signed-off-by: Alexey Palazhchenko <alexey.palazhchenko@gmail.com>
  • Loading branch information
AlekSi authored and talos-bot committed Feb 6, 2021
1 parent 757cc20 commit 33de89e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkg/machinery/client/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ func (r *Rename) String() string {
//
// Current context is overridden from passed in config.
func (c *Config) Merge(cfg *Config) []Rename {
if c.Contexts == nil {
c.Contexts = map[string]*Context{}
}

mappedContexts := map[string]string{}
renames := []Rename{}

Expand Down
6 changes: 2 additions & 4 deletions pkg/machinery/client/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ func TestConfigMerge(t *testing.T) {
expectedContexts map[string]*config.Context
}{
{
name: "IntoEmpty",
config: &config.Config{
Contexts: map[string]*config.Context{},
},
name: "IntoEmpty",
config: &config.Config{},
configToMerge: &config.Config{
Context: "foo",
Contexts: map[string]*config.Context{
Expand Down

0 comments on commit 33de89e

Please sign in to comment.