mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Merge pull request #2135 from seans3/inventory-set
Fixed inventory Equal(), checking nil as passed parameter
This commit is contained in:
@@ -71,6 +71,9 @@ func parseInventory(inv string) (*Inventory, error) {
|
||||
// Equals returns true if the Inventory structs are identical;
|
||||
// false otherwise.
|
||||
func (i *Inventory) Equals(other *Inventory) bool {
|
||||
if other == nil {
|
||||
return false
|
||||
}
|
||||
return i.String() == other.String()
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,18 @@ func TestInventoryEqual(t *testing.T) {
|
||||
inventory2 *Inventory
|
||||
isEqual bool
|
||||
}{
|
||||
// "Other" inventory is nil, then not equal.
|
||||
{
|
||||
inventory1: &Inventory{
|
||||
Name: "test-inv",
|
||||
GroupKind: schema.GroupKind{
|
||||
Group: "apps",
|
||||
Kind: "Deployment",
|
||||
},
|
||||
},
|
||||
inventory2: nil,
|
||||
isEqual: false,
|
||||
},
|
||||
// Two equal inventories without a namespace
|
||||
{
|
||||
inventory1: &Inventory{
|
||||
|
||||
Reference in New Issue
Block a user