Skip to content

Commit 1c5aa2b

Browse files
author
Takashi Kusumi
authored
Return error when output option is invalid (#235)
1 parent 371daf1 commit 1c5aa2b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

cmd/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ func (o *options) generateTemplate() (*template.Template, error) {
362362
t = fmt.Sprintf(" \"namespace\": \"{{color .PodColor .Namespace}}\",\n%s", t)
363363
}
364364
t = fmt.Sprintf("{\n%s\n}", t)
365+
default:
366+
return nil, errors.New("output should be one of 'default', 'raw', 'json', 'extjson', and 'ppextjson'")
365367
}
366368
t += "\n"
367369
}

cmd/cmd_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,18 @@ func TestOptionsGenerateTemplate(t *testing.T) {
254254
`,
255255
false,
256256
},
257+
{
258+
"invalid output",
259+
func() *options {
260+
o := NewOptions(streams)
261+
o.output = "invalid"
262+
263+
return o
264+
}(),
265+
"message",
266+
"",
267+
true,
268+
},
257269
{
258270
"template",
259271
func() *options {

0 commit comments

Comments
 (0)