@@ -14,8 +14,8 @@ import (
14
14
// belong to any inventory object.
15
15
// This is done by determining if the apply/prune operation
16
16
// can go through for a resource based on the comparison
17
- // the inventory-d annotation value in the package and that
18
- // in the live object.
17
+ // the inventory-id value in the package and the owning-inventory
18
+ // annotation in the live object.
19
19
type InventoryPolicy int
20
20
21
21
const (
@@ -26,12 +26,13 @@ const (
26
26
// The apply operation can go through when
27
27
// - A new resources in the package doesn't exist in the cluster
28
28
// - An existing resource in the package doesn't exist in the cluster
29
- // - An existing resource exist in the cluster. The inventory-id annotation in the live object
29
+ // - An existing resource exist in the cluster. The owning-inventory annotation in the live object
30
30
// matches with that in the package.
31
31
//
32
32
// The prune operation can go through when
33
- // - The inventory-id annotation in the live object match with that
33
+ // - The owning-inventory annotation in the live object match with that
34
34
// in the package.
35
+ // - The live object doesn't have the owning-inventory annotation.
35
36
InventoryPolicyMustMatch InventoryPolicy = iota
36
37
37
38
// AdoptIfNoInventory: This policy enforces that resources being applied
@@ -40,26 +41,28 @@ const (
40
41
//
41
42
// The apply operation can go through when
42
43
// - New resource in the package doesn't exist in the cluster
43
- // - If a new resource exist in the cluster, its inventory-id annotation is empty
44
+ // - If a new resource exist in the cluster, its owning-inventory annotation is empty
44
45
// - Existing resource in the package doesn't exist in the cluster
45
- // - If existing resource exist in the cluster, its inventory-id annotation in the live object
46
+ // - If existing resource exist in the cluster, its owning-inventory annotation in the live object
46
47
// is empty
47
- // - An existing resource exist in the cluster. The inventory-id annotation in the live object
48
+ // - An existing resource exist in the cluster. The owning-inventory annotation in the live object
48
49
// matches with that in the package.
49
50
//
50
51
// The prune operation can go through when
51
- // - The inventory-id annotation in the live object match with that
52
+ // - The owning-inventory annotation in the live object match with that
52
53
// in the package.
54
+ // - The live object doesn't have the owning-inventory annotation.
53
55
AdoptIfNoInventory
54
56
55
57
// AdoptAll: This policy will let the current inventory take ownership of any objects.
56
58
//
57
59
// The apply operation can go through for any resource in the package even if the
58
- // live object has an unmatched inventory-id annotation.
60
+ // live object has an unmatched owning-inventory annotation.
59
61
//
60
62
// The prune operation can go through when
61
- // - The inventory-id annotation in the live object match with that
63
+ // - The owning-inventory annotation in the live object match with that
62
64
// in the package.
65
+ // - The live object doesn't have the owning-inventory annotation.
63
66
AdoptAll
64
67
)
65
68
@@ -119,7 +122,7 @@ func CanPrune(inv InventoryInfo, obj *unstructured.Unstructured, policy Inventor
119
122
matchStatus := inventoryIDMatch (inv , obj )
120
123
switch matchStatus {
121
124
case Empty :
122
- return false
125
+ return true
123
126
case Match :
124
127
return true
125
128
case NoMatch :
0 commit comments