From 0e4741558a2eaa84a82c9b1dfe06250cc1a589ea Mon Sep 17 00:00:00 2001 From: David Wertenteil Date: Thu, 1 Feb 2024 21:36:04 +0200 Subject: [PATCH] ignore empty files Signed-off-by: David Wertenteil --- pkg/cleanup/cleanup.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/cleanup/cleanup.go b/pkg/cleanup/cleanup.go index c0134db5e..d8da957bb 100644 --- a/pkg/cleanup/cleanup.go +++ b/pkg/cleanup/cleanup.go @@ -98,6 +98,10 @@ func (h *ResourcesCleanupHandler) StartCleanupTask() { logger.L().Error("cleanup task error", helpers.Error(err)) return nil } + if metadata == nil { + // no metadata found + return nil + } toDelete := handler(resourceKind, path, metadata, h.resources) if toDelete { @@ -135,10 +139,17 @@ func loadMetadataFromPath(appFs afero.Fs, rootPath string) (*metav1.ObjectMeta, if err != nil { return nil, fmt.Errorf("failed to read file %s: %w", rootPath, err) } + data := metav1.ObjectMeta{ Annotations: map[string]string{}, Labels: map[string]string{}, } + + if len(input) == 0 { + // empty file + return nil, nil + } + // ujson parsing var parent string err = ujson.Walk(input, func(level int, key, value []byte) bool {