Skip to content

Commit 8b236c2

Browse files
authored
INSIGHTS-159 - use go templating instead of custom function validation (#1056)
* use go templating instead of custom function validation * fix changelog
1 parent f504de3 commit 8b236c2

File tree

4 files changed

+35
-49
lines changed

4 files changed

+35
-49
lines changed

docs/changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ meta:
66

77
---
88

9+
## unreleased
10+
* Rewrite `hpaMaxAvailability` check to use go-template
11+
912
## 9.1.0
1013
* Add HPA `minAvailable` and HPA `maxAvailable` checks
1114
* Fix typo for PDB `minAvailable`
+32-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
11
successMessage: HPA has a valid max and min replica configuration
22
failureMessage: HPA maxReplicas and minReplicas should be different
33
category: Reliability
4-
target: autoscaling/HorizontalPodAutoscaler
4+
target: autoscaling/HorizontalPodAutoscaler
5+
schemaString: |
6+
"$schema": http://json-schema.org/draft-07/schema#
7+
type: object
8+
properties:
9+
spec:
10+
type: object
11+
properties:
12+
minReplicas:
13+
type: integer
14+
minimum: 1
15+
maxReplicas:
16+
type: integer
17+
minimum: 1
18+
required:
19+
- maxReplicas
20+
{{- if .spec.minReplicas }}
21+
if:
22+
properties:
23+
minReplicas:
24+
type: integer
25+
maxReplicas:
26+
type: integer
27+
then:
28+
properties:
29+
maxReplicas:
30+
exclusiveMinimum: {{ .spec.minReplicas }}
31+
else:
32+
properties:
33+
maxReplicas:
34+
minimum: 1
35+
{{- end }}

pkg/validator/schema.go

-2
Original file line numberDiff line numberDiff line change
@@ -369,8 +369,6 @@ func applySchemaCheck(conf *config.Configuration, checkID string, test schemaTes
369369
passes, issues, err = check.CheckContainer(test.Container)
370370
} else if check.Validator.SchemaURI != "" {
371371
passes, issues, err = check.CheckObject(test.Resource.Resource.Object)
372-
} else if customValidators[checkID] != nil {
373-
passes, issues, err = customValidators[checkID](test.Resource.Resource.Object)
374372
} else {
375373
passes, issues, err = true, []jsonschema.ValError{}, nil
376374
}

pkg/validator/validations.go

-46
This file was deleted.

0 commit comments

Comments
 (0)