Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore empty files #95

Merged
merged 1 commit into from
Feb 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading