From 7ff62116d725f9b90c842c1b55880aa1b67e44c3 Mon Sep 17 00:00:00 2001 From: David Bloss Date: Wed, 6 Nov 2024 12:07:26 -0600 Subject: [PATCH] verify check "kind" in config before create and update --- .changes/unreleased/Bugfix-20241106-120713.yaml | 3 +++ src/cmd/check.go | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changes/unreleased/Bugfix-20241106-120713.yaml diff --git a/.changes/unreleased/Bugfix-20241106-120713.yaml b/.changes/unreleased/Bugfix-20241106-120713.yaml new file mode 100644 index 00000000..d9408e42 --- /dev/null +++ b/.changes/unreleased/Bugfix-20241106-120713.yaml @@ -0,0 +1,3 @@ +kind: Bugfix +body: verify check "kind" in config before create and update +time: 2024-11-06T12:07:13.981585-06:00 diff --git a/src/cmd/check.go b/src/cmd/check.go index 91125924..937cfa71 100644 --- a/src/cmd/check.go +++ b/src/cmd/check.go @@ -3,6 +3,7 @@ package cmd import ( "encoding/json" "fmt" + "slices" "github.com/opslevel/opslevel-go/v2024" @@ -451,10 +452,13 @@ func (checkInputType *CheckInputType) IsUpdateInput() bool { func readCheckInput() (*CheckInputType, error) { input, err := readResourceInput[CheckInputType]() - fmt.Println(input) if err != nil { return nil, err } + if !slices.Contains(opslevel.AllCheckType, string(input.Kind)) { + return nil, fmt.Errorf("check kind '%s' not one of\n%s\nplease update config file", + input.Kind, opslevel.AllCheckType) + } if input.Version != CheckConfigCurrentVersion { return nil, fmt.Errorf("supported config version is '%s' but found '%s' | please update config file", CheckConfigCurrentVersion, input.Version)