Fix inventory panic for v1beta1 objects

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
Stefan Prodan 2021-10-08 17:48:05 +03:00
parent 49fd4356ae
commit cd5b6930b3
No known key found for this signature in database
GPG Key ID: 3299AEB0E4085BAF
2 changed files with 8 additions and 1 deletions

View File

@ -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, "")

View File

@ -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 {