Skip to content

Commit

Permalink
ignore empty files (#95)
Browse files Browse the repository at this point in the history
Signed-off-by: David Wertenteil <[email protected]>
  • Loading branch information
David Wertenteil authored Feb 1, 2024
1 parent 5dec0b0 commit 54e72de
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/cleanup/cleanup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 54e72de

Please sign in to comment.