Skip to content

Commit cd5b693

Browse files
committed
Fix inventory panic for v1beta1 objects
Signed-off-by: Stefan Prodan <[email protected]>
1 parent 49fd435 commit cd5b693

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

controllers/kustomization_controller.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,10 @@ func (r *KustomizationReconciler) prune(ctx context.Context, manager *ssa.Resour
757757

758758
func (r *KustomizationReconciler) finalize(ctx context.Context, kustomization kustomizev1.Kustomization) (ctrl.Result, error) {
759759
log := logr.FromContext(ctx)
760-
if kustomization.Spec.Prune && !kustomization.Spec.Suspend {
760+
if kustomization.Spec.Prune &&
761+
!kustomization.Spec.Suspend &&
762+
kustomization.Status.Inventory != nil &&
763+
kustomization.Status.Inventory.Entries != nil {
761764
objects, err := ListObjectsInInventory(kustomization.Status.Inventory)
762765

763766
impersonation := NewKustomizeImpersonation(kustomization, r.Client, r.StatusPoller, "")

controllers/kustomization_inventory.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ func AddObjectsToInventory(inv *kustomizev1.ResourceInventory, objects []*unstru
5757
func ListObjectsInInventory(inv *kustomizev1.ResourceInventory) ([]*unstructured.Unstructured, error) {
5858
objects := make([]*unstructured.Unstructured, 0)
5959

60+
if inv.Entries == nil {
61+
return objects, nil
62+
}
63+
6064
for _, entry := range inv.Entries {
6165
objMetadata, err := object.ParseObjMetadata(entry.ID)
6266
if err != nil {

0 commit comments

Comments
 (0)