Skip to content

Commit

Permalink
feat: introduce values schema
Browse files Browse the repository at this point in the history
Signed-off-by: Ievgenii Shepeliuk <[email protected]>
  • Loading branch information
eshepelyuk committed Oct 27, 2023
1 parent 6cc872b commit 305bd71
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 75 deletions.
28 changes: 28 additions & 0 deletions charts/opa-kube-mgmt/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://github.com/open-policy-agent/kube-mgmt",
"title": "kube-mgmt helm values",

"definitions": {
"image": {
"type": "object", "title": "OPA docker image configuration", "required": ["repository", "tag"],
"properties": {
"repository": {"type": "string"},
"tag": {"type": "string"},
"pullPolicy": {"type": "string", "default": "IfNotPresent"}
}
}
},

"type": "object", "required": ["image", "mgmt"], "additionalProperties": true,
"properties": {
"image": {"$ref": "#/definitions/image"},
"mgmt": {
"type": "object", "additionalProperties": true, "required": ["image", "enabled"],
"properties": {
"enabled": {"type": "boolean", "default": true},
"image": {"$ref": "#/definitions/image"}
}
}
}
}
4 changes: 2 additions & 2 deletions charts/opa-kube-mgmt/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ authz:
hostNetwork:
enabled: false

# Docker image and tag to deploy.
# OPA docker image configuration.
image:
repository: openpolicyagent/opa
tag: 0.53.1
Expand All @@ -134,7 +134,7 @@ mgmt:
enabled: true
image:
repository: openpolicyagent/kube-mgmt
tag: null # appVersion is used by default, set to desired value to override
tag: "0.0.0" # appVersion is used by default, set to desired value to override
pullPolicy: IfNotPresent
extraArgs: []
extraEnv: []
Expand Down
18 changes: 10 additions & 8 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,26 @@ _latest:
crane tag ${SKAFFOLD_IMAGE} latest
fi

_helm-unittest:
helm plugin ls | grep unittest || helm plugin install https://github.com/helm-unittest/helm-unittest.git

# golang linter
lint-go:
go vet ./...
staticcheck ./...

# helm linter
lint-helm:
./test/linter/test.sh
lint-helm filter="*": _helm-unittest
helm unittest -f '../../test/lint/{{filter}}.yaml' charts/opa-kube-mgmt

# run unit tests
# run all unit tests
lint: lint-go lint-helm

# stub
test-helm:
helm plugin ls | grep unittest || helm plugin install https://github.com/helm-unittest/helm-unittest.git
helm unittest -f '../../test/unit/*.yaml' charts/opa-kube-mgmt
# run helm unit tests
test-helm filter="*": _helm-unittest
helm unittest -f '../../test/unit/{{filter}}.yaml' charts/opa-kube-mgmt

# golang unit tests
# run golang unit tests
test-go:
go test ./...

Expand Down
65 changes: 65 additions & 0 deletions test/lint/images.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
suite: lint image and mgmt.image
templates:
- fake.yaml
tests:
- it: image is null
set:
image: null
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
opa-kube-mgmt:
- (root): image is required
- it: image.repository not string
set:
image:
repository: 5
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
opa-kube-mgmt:
- image.repository: Invalid type. Expected: string, given: integer
- it: image.tag not string
set:
image:
tag: 5
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
opa-kube-mgmt:
- image.tag: Invalid type. Expected: string, given: integer
- it: mgmt.image is null
set:
mgmt:
image: null
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
opa-kube-mgmt:
- mgmt: image is required
- it: mgmt.image.repository not string
set:
mgmt:
image:
repository: 5
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
opa-kube-mgmt:
- mgmt.image.repository: Invalid type. Expected: string, given: integer
- it: mgmt.image.tag not string
set:
mgmt:
image:
tag: 5
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
opa-kube-mgmt:
- mgmt.image.tag: Invalid type. Expected: string, given: integer
65 changes: 0 additions & 65 deletions test/linter/test.sh

This file was deleted.

0 comments on commit 305bd71

Please sign in to comment.