Skip to content

Commit e013ab4

Browse files
authored
verify check "kind" in config before create and update (#347)
1 parent 538b792 commit e013ab4

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
kind: Bugfix
2+
body: verify check "kind" in config before create and update
3+
time: 2024-11-06T12:07:13.981585-06:00

src/cmd/check.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cmd
33
import (
44
"encoding/json"
55
"fmt"
6+
"slices"
67

78
"github.com/opslevel/opslevel-go/v2024"
89

@@ -451,10 +452,13 @@ func (checkInputType *CheckInputType) IsUpdateInput() bool {
451452

452453
func readCheckInput() (*CheckInputType, error) {
453454
input, err := readResourceInput[CheckInputType]()
454-
fmt.Println(input)
455455
if err != nil {
456456
return nil, err
457457
}
458+
if !slices.Contains(opslevel.AllCheckType, string(input.Kind)) {
459+
return nil, fmt.Errorf("check kind '%s' not one of\n%s\nplease update config file",
460+
input.Kind, opslevel.AllCheckType)
461+
}
458462
if input.Version != CheckConfigCurrentVersion {
459463
return nil, fmt.Errorf("supported config version is '%s' but found '%s' | please update config file",
460464
CheckConfigCurrentVersion, input.Version)

0 commit comments

Comments
 (0)