Skip to content

Commit 975813d

Browse files
feat: check if filters does not empty on add & remove
Signed-off-by: Matthis Holleville <[email protected]>
1 parent 9aa0e89 commit 975813d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

cmd/filters/add.go

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ var addCmd = &cobra.Command{
2222
// Verify filter exist
2323
invalidFilters := []string{}
2424
for _, f := range filters {
25+
if f == "" {
26+
color.Red("Filter cannot be empty. Please use correct syntax.")
27+
os.Exit(1)
28+
}
2529
foundFilter := false
2630
for _, filter := range analyzer.ListFilters() {
2731
if filter == f {

cmd/filters/remove.go

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ var removeCmd = &cobra.Command{
2424
defaultFilters = []string{}
2525
}
2626

27+
// Check if input filters is not empty
28+
for _, f := range filters {
29+
if f == "" {
30+
color.Red("Filter cannot be empty. Please use correct syntax.")
31+
os.Exit(1)
32+
}
33+
}
34+
2735
// verify dupplicate filters example: k8sgpt filters remove Pod Pod
2836
uniqueFilters, dupplicatedFilters := util.RemoveDuplicates(filters)
2937
if len(dupplicatedFilters) != 0 {

0 commit comments

Comments
 (0)