Skip to content

Commit

Permalink
verify check "kind" in config before create and update (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbloss authored Nov 6, 2024
1 parent 538b792 commit e013ab4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .changes/unreleased/Bugfix-20241106-120713.yaml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion src/cmd/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmd
import (
"encoding/json"
"fmt"
"slices"

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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit e013ab4

Please sign in to comment.