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

Fix configurability of OverlappingRanges #164

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

cnitypes "github.com/containernetworking/cni/pkg/types"
types020 "github.com/containernetworking/cni/pkg/types/020"
"github.com/imdario/mergo"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/logging"
"github.com/k8snetworkplumbingwg/whereabouts/pkg/types"
)
Expand Down Expand Up @@ -62,7 +61,6 @@ func LoadIPAMConfig(bytes []byte, envArgs string) (*types.IPAMConfig, string, er
}

// Cycle through the path and parse the JSON config
flatipam := types.Net{}
foundflatfile := ""
for _, confpath := range confdirs {
if pathExists(confpath) {
Expand All @@ -80,7 +78,7 @@ func LoadIPAMConfig(bytes []byte, envArgs string) (*types.IPAMConfig, string, er
return nil, "", fmt.Errorf("LoadIPAMConfig Flatfile (%s) - ioutil.ReadAll error: %s", confpath, err)
}

if err := json.Unmarshal(jsonBytes, &flatipam.IPAM); err != nil {
if err := json.Unmarshal(jsonBytes, &n.IPAM); err != nil {
return nil, "", fmt.Errorf("LoadIPAMConfig Flatfile (%s) - JSON Parsing Error: %s / bytes: %s", confpath, err, jsonBytes)
}

Expand All @@ -90,10 +88,9 @@ func LoadIPAMConfig(bytes []byte, envArgs string) (*types.IPAMConfig, string, er
}
}

// Now let's try to merge the configurations...
// NB: Don't try to do any initialization before this point or it won't account for merged flat file.
if err := mergo.Merge(&n, flatipam); err != nil {
logging.Errorf("Merge error with flat file: %s", err)
// Unmarshal again to set the IPAM values (overriding the values originating from the flatfile)
if err := json.Unmarshal(bytes, &n); err != nil {
return nil, "", fmt.Errorf("LoadIPAMConfig - JSON Parsing Error: %s / bytes: %s", err, bytes)
}

// Logging
Expand Down