Skip to content

Commit

Permalink
feat(valigator): Add COntrol for Environment (HSP-9244) (#6)
Browse files Browse the repository at this point in the history
* feat(valigator): Add COntrol for Environment (HSP-9244)

* all

---------

Co-authored-by: Christian Eickhoff <[email protected]>
  • Loading branch information
eic-chr and Christian Eickhoff authored Aug 23, 2024
1 parent 8d903eb commit e9e3fc9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cmd/spectral.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

const (
rulesetQueryParam = "ruleset"
environmentParam = "environment"
errorsOnlyQueryParam = "errors-only"
acceptHeader = "Accept"
)
Expand Down
8 changes: 5 additions & 3 deletions cmd/valigator.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ func (config ValigatorConfig) Url() string {

func (config ValigatorConfig) CreateContext() (*ValigatorContext, error) {
ruleSets := []string{
"v5",
"v10",
"v5-de",
"v5-pr",
"v10-de",
"v10-pr",
}

// TODO: read rulesets from file system
Expand Down Expand Up @@ -139,7 +141,7 @@ func (context *ValigatorContext) validate(w http.ResponseWriter, r *http.Request
}

query := r.URL.Query()
ruleset := query.Get(rulesetQueryParam)
ruleset := strings.ToLower(query.Get(rulesetQueryParam) + "-" + query.Get(environmentParam))
hasRuleset := context.hasRuleset(ruleset)
if !hasRuleset {
log.Println("Unknown ruleset:", ruleset)
Expand Down
2 changes: 1 addition & 1 deletion valigator.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"basePath": "/valigator",
"skipRules": [],
"displayOnlyFailures": true,
"ruleSets": [ "v5", "v10" ]
"ruleSets": [ "v5-de","v5-pr", "v10-de", "v10-pr" ]
}

0 comments on commit e9e3fc9

Please sign in to comment.