Skip to content

Commit

Permalink
report if no unused resources found in a namespace (#48)
Browse files Browse the repository at this point in the history
* report if no unused resources found in a namespace

* no changes required in this file, reverting

---------

Co-authored-by: Ozgur Demir <ozgur.demir@itutor.com>
  • Loading branch information
ozgurcd and Ozgur Demir committed Sep 3, 2023
1 parent 5b3dfd2 commit eb2cc6f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/kor/kor.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,27 @@ func FormatOutputAll(namespace string, allDiffs []ResourceDiff) string {
var buf bytes.Buffer
table := tablewriter.NewWriter(&buf)
table.SetHeader([]string{"#", "Resource Type", "Resource Name"})

// TODO parse resourceType, diff

allEmpty := true
for _, data := range allDiffs {
if len(data.diff) == 0 {
continue
}

allEmpty = false
for _, val := range data.diff {
row := []string{fmt.Sprintf("%d", i+1), data.resourceType, val}
table.Append(row)
i += 1
}
}

if allEmpty {
return fmt.Sprintf("No unused resources found in the namespace: %s", namespace)
}

table.Render()
return fmt.Sprintf("Unused Resources in Namespace: %s\n%s", namespace, buf.String())
}
Expand Down

0 comments on commit eb2cc6f

Please sign in to comment.