Skip to content

Commit

Permalink
Fixed column validation with KeyifyHeader (#1525)
Browse files Browse the repository at this point in the history
Signed-off-by: rcmadhankumar <rcmadhankumar@gmail.com>
  • Loading branch information
rcmadhankumar authored Apr 11, 2024
1 parent 395574c commit d308378
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cli/pkg/kctrl/cmd/core/print_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func validateColumns(headers *[]uitable.Header, cols *[]string) error {
for _, col := range *cols {
found := false
for _, head := range *headers {
if col == head.Key || col == head.Title {
if uitable.KeyifyHeader(col) == head.Key || col == head.Title {
found = true
break
}
Expand Down
10 changes: 10 additions & 0 deletions cli/test/e2e/package_available_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ spec:
require.Exactly(t, expectedOutputRows, output.Tables[0].Rows)
})

logger.Section("listing packages with column names in mixed cases", func() {
out := kappCtrl.Run([]string{"package", "available", "list", "--json", "--column=nAMe,NameSpace"})
output := uitest.JSONUIFromBytes(t, []byte(out))
expectedOutputRows := []map[string]string{{
"name": packageName,
"namespace": env.Namespace,
}}
require.Exactly(t, expectedOutputRows, output.Tables[0].Rows)
})

logger.Section("listing packages with non existing column names", func() {
_, err := kappCtrl.RunWithOpts([]string{"package", "available", "list", "--json", "--column=name,invalid,namespace,ns"}, RunOpts{
AllowError: true,
Expand Down

0 comments on commit d308378

Please sign in to comment.