Skip to content

Commit

Permalink
list WEP and Policy should return empty KVP lists
Browse files Browse the repository at this point in the history
  • Loading branch information
gunjan5 committed May 9, 2017
1 parent baceaf3 commit 00226b7
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/backend/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,15 @@ func (c *KubeClient) listWorkloadEndpoints(l model.WorkloadEndpointListOptions)
WorkloadID: l.WorkloadID,
})
if err != nil {
// Error getting the endpoint.
return nil, err
}
if kvp == nil {
// The workload endpoint doesn't exist.
return nil, nil
switch err.(type) {
// Return empty slice of KVPair if the object doesn't exist, return the error otherwise.
case errors.ErrorResourceDoesNotExist:
return []*model.KVPair{}, nil
default:
return nil, err
}
}

return []*model.KVPair{kvp}, nil
}

Expand Down Expand Up @@ -558,8 +560,15 @@ func (c *KubeClient) listPolicies(l model.PolicyListOptions) ([]*model.KVPair, e
// Exact lookup on a NetworkPolicy.
kvp, err := c.getPolicy(model.PolicyKey{Name: l.Name})
if err != nil {
return []*model.KVPair{}, nil
switch err.(type) {
// Return empty slice of KVPair if the object doesn't exist, return the error otherwise.
case errors.ErrorResourceDoesNotExist:
return []*model.KVPair{}, nil
default:
return nil, err
}
}

return []*model.KVPair{kvp}, nil
}

Expand Down

0 comments on commit 00226b7

Please sign in to comment.