Skip to content

Commit

Permalink
INSIGHTS-159 - use go templating instead of custom function validation (
Browse files Browse the repository at this point in the history
#1056)

* use go templating instead of custom function validation

* fix changelog
  • Loading branch information
vitorvezani authored Jun 27, 2024
1 parent f504de3 commit 8b236c2
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 49 deletions.
3 changes: 3 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ meta:

---

## unreleased
* Rewrite `hpaMaxAvailability` check to use go-template

## 9.1.0
* Add HPA `minAvailable` and HPA `maxAvailable` checks
* Fix typo for PDB `minAvailable`
Expand Down
33 changes: 32 additions & 1 deletion pkg/config/checks/hpaMaxAvailability.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
successMessage: HPA has a valid max and min replica configuration
failureMessage: HPA maxReplicas and minReplicas should be different
category: Reliability
target: autoscaling/HorizontalPodAutoscaler
target: autoscaling/HorizontalPodAutoscaler
schemaString: |
"$schema": http://json-schema.org/draft-07/schema#
type: object
properties:
spec:
type: object
properties:
minReplicas:
type: integer
minimum: 1
maxReplicas:
type: integer
minimum: 1
required:
- maxReplicas
{{- if .spec.minReplicas }}
if:
properties:
minReplicas:
type: integer
maxReplicas:
type: integer
then:
properties:
maxReplicas:
exclusiveMinimum: {{ .spec.minReplicas }}
else:
properties:
maxReplicas:
minimum: 1
{{- end }}
2 changes: 0 additions & 2 deletions pkg/validator/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,6 @@ func applySchemaCheck(conf *config.Configuration, checkID string, test schemaTes
passes, issues, err = check.CheckContainer(test.Container)
} else if check.Validator.SchemaURI != "" {
passes, issues, err = check.CheckObject(test.Resource.Resource.Object)
} else if customValidators[checkID] != nil {
passes, issues, err = customValidators[checkID](test.Resource.Resource.Object)
} else {
passes, issues, err = true, []jsonschema.ValError{}, nil
}
Expand Down
46 changes: 0 additions & 46 deletions pkg/validator/validations.go

This file was deleted.

0 comments on commit 8b236c2

Please sign in to comment.