Skip to content

Commit b6eb081

Browse files
committed
Add Helm schema
Problem: Deploying the chart with wrong values could result in an incorrectly configured NGF Solution: Enforce the values with a schema.json
1 parent 0723ab8 commit b6eb081

File tree

6 files changed

+639
-23
lines changed

6 files changed

+639
-23
lines changed

.pre-commit-config.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ repos:
77
- id: trailing-whitespace
88
exclude: (^tests/results/|\.avdl$|_generated.go$)
99
- id: end-of-file-fixer
10+
exclude: (^charts/nginx-gateway-fabric/values.schema.json$) # Remove this after helm-schema has a new release
1011
- id: check-yaml
1112
args: [--allow-multiple-documents]
1213
exclude: (^charts/nginx-gateway-fabric/templates)
@@ -20,6 +21,7 @@ repos:
2021
- id: check-symlinks
2122
- id: pretty-format-json
2223
args: [--autofix, --no-sort-keys, --no-ensure-ascii]
24+
exclude: (^charts/nginx-gateway-fabric/values.schema.json$) # Remove this after helm-schema has a new release
2325
- id: mixed-line-ending
2426
args: [--fix=lf]
2527
- id: no-commit-to-branch
@@ -85,6 +87,17 @@ repos:
8587
- id: shfmt-src
8688
args: [-w, -s, -i, "4"]
8789

90+
- repo: https://github.com./dadav/helm-schema
91+
rev: 0.12.0
92+
hooks:
93+
- id: helm-schema
94+
args:
95+
- --chart-search-root=charts
96+
- --add-schema-reference
97+
- "--skip-auto-generation=required,additionalProperties"
98+
# This has not been released yet, uncomment after 0.13.0 is released
99+
# - --append-newline
100+
88101
ci:
89102
skip: [golangci-lint-full, prettier, markdownlint-cli2, yamllint]
90103
autofix_prs: false

.yamllint.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
---
2-
yaml-files:
3-
- "*.yaml"
4-
- "*.yml"
5-
62
ignore:
7-
- charts/nginx-gateway-fabric/
3+
- charts/nginx-gateway-fabric/templates
84
- config/crd/bases/
95
- deploy/crds.yaml
106
- site/static
@@ -39,6 +35,7 @@ rules:
3935
.github/
4036
tests/suite/manifests/longevity/cronjob.yaml
4137
.goreleaser.yml
38+
charts/nginx-gateway-fabric/
4239
new-line-at-end-of-file: enable
4340
new-lines: enable
4441
octal-values: disable

Makefile

+7-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ CONTROLLER_TOOLS_VERSION = v0.16.2
3737
NODE_VERSION = 20
3838
# renovate: datasource=docker depName=quay.io/helmpack/chart-testing
3939
CHART_TESTING_VERSION = v3.11.0
40+
# renovate: datasource=github-tags depName=dadav/helm-schema
41+
HELM_SCHEMA_VERSION = 0.12.0
4042

4143
# variables that can be overridden by the user
4244
PREFIX ?= nginx-gateway-fabric## The name of the NGF image. For example, nginx-gateway-fabric
@@ -146,8 +148,12 @@ generate-api-docs: ## Generate API docs
146148
generate-helm-docs: ## Generate the Helm chart documentation
147149
go run github.com./norwoodj/helm-docs/cmd/helm-docs@$(HELM_DOCS_VERSION) --chart-search-root=charts --template-files _templates.gotmpl --template-files README.md.gotmpl
148150

151+
.PHONY: generate-helm-schema
152+
generate-helm-schema: ## Generate the Helm chart schema
153+
go run github.com./dadav/helm-schema/cmd/helm-schema@$(HELM_SCHEMA_VERSION) --chart-search-root=charts --add-schema-reference "--skip-auto-generation=required,additionalProperties"
154+
149155
.PHONY: generate-all
150-
generate-all: generate generate-crds generate-manifests generate-api-docs generate-helm-docs ## Generate all the necessary files
156+
generate-all: generate generate-crds generate-helm-schema generate-manifests generate-api-docs generate-helm-docs ## Generate all the necessary files
151157

152158
.PHONY: clean
153159
clean: ## Clean the build

charts/nginx-gateway-fabric/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
258258
| `affinity` | The affinity of the NGINX Gateway Fabric pod. | object | `{}` |
259259
| `extraVolumes` | extraVolumes for the NGINX Gateway Fabric pod. Use in conjunction with nginxGateway.extraVolumeMounts and nginx.extraVolumeMounts to mount additional volumes to the containers. | list | `[]` |
260260
| `metrics.enable` | Enable exposing metrics in the Prometheus format. | bool | `true` |
261-
| `metrics.port` | Set the port where the Prometheus metrics are exposed. Format: [1024 - 65535] | int | `9113` |
261+
| `metrics.port` | Set the port where the Prometheus metrics are exposed. | int | `9113` |
262262
| `metrics.secure` | Enable serving metrics via https. By default metrics are served via http. Please note that this endpoint will be secured with a self-signed certificate. | bool | `false` |
263263
| `nginx.config` | The configuration for the data plane that is contained in the NginxProxy resource. | object | `{}` |
264264
| `nginx.extraVolumeMounts` | extraVolumeMounts are the additional volume mounts for the nginx container. | list | `[]` |
@@ -271,7 +271,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
271271
| `nginx.usage.insecureSkipVerify` | Disable client verification of the NGINX Plus usage reporting server certificate. | bool | `false` |
272272
| `nginx.usage.secretName` | The namespace/name of the Secret containing the credentials for NGINX Plus usage reporting. | string | `""` |
273273
| `nginx.usage.serverURL` | The base server URL of the NGINX Plus usage reporting server. | string | `""` |
274-
| `nginxGateway.config.logging.level` | Log level. Supported values "info", "debug", "error". | string | `"info"` |
274+
| `nginxGateway.config.logging.level` | Log level. | string | `"info"` |
275275
| `nginxGateway.configAnnotations` | Set of custom annotations for NginxGateway objects. | object | `{}` |
276276
| `nginxGateway.extraVolumeMounts` | extraVolumeMounts are the additional volume mounts for the nginx-gateway container. | list | `[]` |
277277
| `nginxGateway.gatewayClassAnnotations` | Set of custom annotations for GatewayClass objects. | object | `{}` |
@@ -299,7 +299,7 @@ The following table lists the configurable parameters of the NGINX Gateway Fabri
299299
| `service.externalTrafficPolicy` | The externalTrafficPolicy of the service. The value Local preserves the client source IP. | string | `"Local"` |
300300
| `service.ports` | A list of ports to expose through the NGINX Gateway Fabric service. Update it to match the listener ports from your Gateway resource. Follows the conventional Kubernetes yaml syntax for service ports. | list | `[{"name":"http","port":80,"protocol":"TCP","targetPort":80},{"name":"https","port":443,"protocol":"TCP","targetPort":443}]` |
301301
| `service.type` | The type of service to create for the NGINX Gateway Fabric. | string | `"LoadBalancer"` |
302-
| `serviceAccount.annotations` | | object | `{}` |
302+
| `serviceAccount.annotations` | Set of custom annotations for the NGINX Gateway Fabric service account. | object | `{}` |
303303
| `serviceAccount.imagePullSecret` | The name of the secret containing docker registry credentials. Secret must exist in the same namespace as the helm release. | string | `""` |
304304
| `serviceAccount.imagePullSecrets` | A list of secret names containing docker registry credentials. Secrets must exist in the same namespace as the helm release. | list | `[]` |
305305
| `serviceAccount.name` | The name of the service account of the NGINX Gateway Fabric pods. Used for RBAC. | string | Autogenerated if not set or set to "" |

0 commit comments

Comments
 (0)