-
Notifications
You must be signed in to change notification settings - Fork 98
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
List of objects just returns results for last item in list #348
Comments
Hi @mpatters72, thanks for submitting this issue. Example: $ kor sa,cm -n kor --group-by=resource
kor version: vdev
_ _____ ____
| |/ / _ \| _ \
| ' / | | | |_) |
| . \ |_| | _ <
|_|\_\___/|_| \_\
Unused ServiceAccounts:
+---+-----------+---------------+
| # | NAMESPACE | RESOURCE NAME |
+---+-----------+---------------+
| 1 | kor | test |
+---+-----------+---------------+
Unused ConfigMaps:
+---+-----------+---------------+
| # | NAMESPACE | RESOURCE NAME |
+---+-----------+---------------+
| 1 | kor | test |
+---+-----------+---------------+
$ kor sa,cm -n kor --group-by=namespace
kor version: vdev
_ _____ ____
| |/ / _ \| _ \
| ' / | | | |_) |
| . \ |_| | _ <
|_|\_\___/|_| \_\
Unused resources in namespace: "kor"
+---+---------------+---------------+
| # | RESOURCE TYPE | RESOURCE NAME |
+---+---------------+---------------+
| 1 | ConfigMap | test |
+---+---------------+---------------+ I will submit a fix and keep you updated. |
WIP in #349. for _, namespace := range namespaces {
allDiffs := retrieveNamespaceDiffs(clientset, namespace, resourceList, filterOpts)
for _, diff := range allDiffs {
if opts.DeleteFlag {
if diff.diff, err = DeleteResource(diff.diff, clientset, namespace, diff.resourceType, opts.NoInteractive); err != nil {
fmt.Fprintf(os.Stderr, "Failed to delete %s %s in namespace %s: %v\n", diff.resourceType, diff.diff, namespace, err)
}
}
switch opts.GroupBy {
case "namespace":
-------> resources[namespace] = make(map[string][]ResourceInfo)
resources[namespace][diff.resourceType] = diff.diff
case "resource":
appendResources(resources, diff.resourceType, namespace, diff.diff)
}
}
} I moved the initializtion outside of the diff loop, as is should be initialized once for every namespace, and not for every diff: if opts.GroupBy == "namespace" {
resources[namespace] = make(map[string][]ResourceInfo)
} And it seemed to have resolved the issue: $ kor sa,cm -n kor
kor version: vdev
_ _____ ____
| |/ / _ \| _ \
| ' / | | | |_) |
| . \ |_| | _ <
|_|\_\___/|_| \_\
Unused resources in namespace: "kor"
+---+----------------+---------------+
| # | RESOURCE TYPE | RESOURCE NAME |
+---+----------------+---------------+
| 1 | ServiceAccount | test |
| 2 | ConfigMap | test |
+---+----------------+---------------+ |
@mpatters72 Thanks for reporting the bug! This should be solved in the latest release(v0.5.5) Let us know if you have any further issues |
Describe the bug
When I provide a list of objects, it seems to just process last one in list instead of all of them and ignores previous ones.
To Reproduce
Provide argument with objects in list when you know more than 1 object will return results normally.
kor "pdb,replicaset"
Expected behavior
Would return results for all objects in list.
OS version, architecture and kor version
/opt/homebrew/Cellar/kor/0.5.4 on arm64 - MacBook Pro - M2 Max - macOS Sonoma 14.6.1
Additional context
The text was updated successfully, but these errors were encountered: