Fix nil-pointer check

Signed-off-by: Nico Schieder <nschieder@redhat.com>
This commit is contained in:
Nico Schieder
2021-03-06 11:34:24 +01:00
parent e27c48b391
commit 8f32968f73
2 changed files with 56 additions and 5 deletions

View File

@ -143,6 +143,9 @@ func LoadIPAMConfig(bytes []byte, envArgs string) (*IPAMConfig, string, error) {
if err := json.Unmarshal(bytes, &n); err != nil {
return nil, "", err
}
if n.IPAM == nil {
return nil, "", fmt.Errorf("IPAM config missing 'ipam' key")
}
// load IP from CNI_ARGS
if envArgs != "" {
@ -203,10 +206,6 @@ func LoadIPAMConfig(bytes []byte, envArgs string) (*IPAMConfig, string, error) {
}
}
if n.IPAM == nil {
return nil, "", fmt.Errorf("IPAM config missing 'ipam' key")
}
// Validate all ranges
numV4 := 0
numV6 := 0