Fix inventory panic for v1beta1 objects
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
parent
49fd4356ae
commit
cd5b6930b3
|
|
@ -757,7 +757,10 @@ func (r *KustomizationReconciler) prune(ctx context.Context, manager *ssa.Resour
|
|||
|
||||
func (r *KustomizationReconciler) finalize(ctx context.Context, kustomization kustomizev1.Kustomization) (ctrl.Result, error) {
|
||||
log := logr.FromContext(ctx)
|
||||
if kustomization.Spec.Prune && !kustomization.Spec.Suspend {
|
||||
if kustomization.Spec.Prune &&
|
||||
!kustomization.Spec.Suspend &&
|
||||
kustomization.Status.Inventory != nil &&
|
||||
kustomization.Status.Inventory.Entries != nil {
|
||||
objects, err := ListObjectsInInventory(kustomization.Status.Inventory)
|
||||
|
||||
impersonation := NewKustomizeImpersonation(kustomization, r.Client, r.StatusPoller, "")
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ func AddObjectsToInventory(inv *kustomizev1.ResourceInventory, objects []*unstru
|
|||
func ListObjectsInInventory(inv *kustomizev1.ResourceInventory) ([]*unstructured.Unstructured, error) {
|
||||
objects := make([]*unstructured.Unstructured, 0)
|
||||
|
||||
if inv.Entries == nil {
|
||||
return objects, nil
|
||||
}
|
||||
|
||||
for _, entry := range inv.Entries {
|
||||
objMetadata, err := object.ParseObjMetadata(entry.ID)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue