Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Schema Validation for Helm #4094

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

igooch
Copy link
Collaborator

@igooch igooch commented Jan 21, 2025

What type of PR is this?

/kind feature

What this PR does / Why we need it:

This PR adds the Helm schema validation file values.schema.json.

Reasoning for the addition of the validation file is described more fully in #4093:

The goal of this validation is to make any breaking changes in the Helm chart immediately apparent to the user.

JSON schema validation will validate the Agones Helm chart .Values object (note that this is not the values.yaml file itself. Details are in the Helm documentation on JSON schema files). Validation only applies to the helm install or helm upgrade, and not a direct kubectl install of the values.yaml file.

Which issue(s) this PR fixes:

Working on #4093

Special notes for your reviewer:

Details on the creation of the values.schema.json file:

  • Helm currently uses https://json-schema.org/draft-07/schema as the schema for the validation file.
  • The schema could not be automatically inferred (as described in https://www.arthurkoziel.com/validate-helm-chart-values-with-json-schemas/) from the values.yaml file nor the helm get values agones -n agones-system -a -ojson because this infers that all fields are required, when many of the fields are not in fact required, and can be safely set to nil.
  • Note in the Helm templating language (which is based off of Go templating, but not exactly the same):

    A pipeline is evaluated as false if the value is:
    a boolean false
    a numeric zero
    an empty string
    a nil (empty or null)
    an empty collection (map, slice, tuple, dict, array)

    • This means that Helm template conditionals such as {{- if .Values.agones.controller.generateTLS }} will evaluate to false if .Values.agones.controller.generateTLS is nil, so .Values.agones.controller.generateTLS is not a required value.
  • Helm template lines such as {{- $replicas := (int .Values.agones.controller.replicas) }} mean that agones, agones.controller, and agones.controller.replicas are all required values as these will throw errors if nil.
  • Whether or not a field was required was determined by the above logic for all template fields in install/helm/agones/templates.
  • Deprecated fields are not included in this PR. We do not currently have the ability to warn on deprecated fields (noted in JSON Schema Validation for Helm #4093). This should be included in a future PR once Helm has updated to a newer version of json schema.
  • In the event this validation schema misses a valid edge case, the user can still attempt a helm install or helm upgrade with the flag --skip-schema-validation.

CI/CD testing and documentation will be added in future PRs. This PR can be manually tested with:

me@me:~/agones/install/helm/agones$ helm lint .
==> Linting .

1 chart(s) linted, 0 chart(s) failed

@github-actions github-actions bot added kind/feature New features for Agones size/XL labels Jan 21, 2025
Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@agones-bot
Copy link
Collaborator

Build Failed 😭

Build Id: 2b3ac633-f045-4686-8a28-e14c86851ba0

Status: FAILURE

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@agones-bot
Copy link
Collaborator

Build Failed 😭

Build Id: decbfeb6-a5ed-47ac-86cb-deb1069309f1

Status: FAILURE

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@igooch
Copy link
Collaborator Author

igooch commented Jan 21, 2025

/gcbrun

@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 2fcdd657-cd8a-481f-b285-e763be78e8a5

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

git fetch https://github.com/googleforgames/agones.git pull/4094/head:pr_4094 && git checkout pr_4094
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.47.0-dev-2519685

Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@agones-bot
Copy link
Collaborator

Build Succeeded 🥳

Build Id: 4fda0ebf-7dba-4bb8-b086-788007e7ab8a

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

git fetch https://github.com/googleforgames/agones.git pull/4094/head:pr_4094 && git checkout pr_4094
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.47.0-dev-4df18f4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New features for Agones size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants