|
| 1 | +// Copyright 2019 The Kubernetes Authors. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +package inventory |
| 5 | + |
| 6 | +// InventoryPolicy defines if an inventory object can take over |
| 7 | +// objects that belong to another inventory object or don't |
| 8 | +// belong to any inventory object. |
| 9 | +// This is done by determining if the apply/prune operation |
| 10 | +// can go through for a resource based on the comparison |
| 11 | +// the inventory-d annotation value in the package and that |
| 12 | +// in the live object. |
| 13 | +type InventoryPolicy int |
| 14 | + |
| 15 | +const ( |
| 16 | + // InvnetoryPolicyMustMatch: This policy enforces that the resources being applied can not |
| 17 | + // have any overlap with objects in other inventories or objects that already exist |
| 18 | + // in the cluster but don't belong to an inventory. |
| 19 | + // |
| 20 | + // The apply operation can go through when |
| 21 | + // - A new resources in the package doesn't exist in the cluster |
| 22 | + // - An existing resource in the package doesn't exist in the cluster |
| 23 | + // - An existing resource exist in the cluster. The inventory-id annotation in the live object |
| 24 | + // matches with that in the package. |
| 25 | + // |
| 26 | + // The prune operation can go through when |
| 27 | + // - The inventory-id annotation in the live object match with that |
| 28 | + // in the package. |
| 29 | + InventoryPolicyMustMatch InventoryPolicy = iota |
| 30 | + |
| 31 | + // AdoptIfNoInventory: This policy enforces that resources being applied |
| 32 | + // can not have any overlap with objects in other inventories, but are |
| 33 | + // permitted to take ownership of objects that don't belong to any inventories. |
| 34 | + // |
| 35 | + // The apply operation can go through when |
| 36 | + // - New resource in the package doesn't exist in the cluster |
| 37 | + // - If a new resource exist in the cluster, its inventory-id annotation is empty |
| 38 | + // - Existing resource in the package doesn't exist in the cluster |
| 39 | + // - If existing resource exist in the cluster, its inventory-id annotation in the live object |
| 40 | + // is empty |
| 41 | + // - An existing resource exist in the cluster. The inventory-id annotation in the live object |
| 42 | + // matches with that in the package. |
| 43 | + // |
| 44 | + // The prune operation can go through when |
| 45 | + // - The inventory-id annotation in the live object match with that |
| 46 | + // in the package. |
| 47 | + AdoptIfNoInventory |
| 48 | + |
| 49 | + // AdoptAll: This policy will let the current inventory take ownership of any objects. |
| 50 | + // |
| 51 | + // The apply operation can go through for any resource in the package even if the |
| 52 | + // live object has an unmatched inventory-id annotation. |
| 53 | + // |
| 54 | + // The prune operation can go through when |
| 55 | + // - The inventory-id annotation in the live object match with that |
| 56 | + // in the package. |
| 57 | + AdoptAll |
| 58 | +) |
0 commit comments