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

values schema #811

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

values schema #811

wants to merge 31 commits into from

Conversation

wkloucek
Copy link
Contributor

@wkloucek wkloucek commented Nov 22, 2024

Description

Maintain a schema file to find misconfigurations.
There were already some misconfigurations found in the deployment examples (see the diff).

Related Issue

Motivation and Context

How Has This Been Tested?

  • tested in CI against CI values and deployment examples
  • tested against well known deployments outside of this Chart repo
    • the "B" project, see issue backref on this ticket
    • the "E" project, I ran a command like this helm lint charts/ocis -f ~/Projects/gitlab.xxx/exxx/ocis-infra/common/ocis/values.yaml -f ~/Projects/gitlab.xxx/exxx/ocis-infra/prod/apps/ocis/values.yaml

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation generated (make docs) and committed
  • Documentation ticket raised:
  • Documentation PR created:

@wkloucek wkloucek marked this pull request as draft November 22, 2024 10:27
@wkloucek wkloucek added the QA label Nov 25, 2024
@wkloucek wkloucek requested a review from d7oc November 25, 2024 14:23
@wkloucek
Copy link
Contributor Author

wkloucek commented Nov 25, 2024

@d7oc could you skim those changes to check if you agree with the principle of this change?

Most interesting from my side:

  • the effect on the values.yaml changes in the future (one needs to maintain the schema annotations)
  • the schema helps devs to put configuration in the right place and avoid configuration that does nothing (includes config that was removed)
  • the deployment examples stay up to date because their configuration is now linted, too
  • the schema forces us to have sane defaults / configuration methods

If we can agree on the schema beeing a good thing, I'll gonna do some polishing on this PR, especially on the configuration documentation that received a small fallout.

@wkloucek wkloucek marked this pull request as ready for review December 6, 2024 08:14
@wkloucek
Copy link
Contributor Author

wkloucek commented Dec 6, 2024

@d7oc I'd like to get this into the chart soonish or agree on a timeframe when this change does fits our risk analysis / schedule / ...

This week I had another occurence where this schema feature would have saved a college and my like 2 hours each because we had fine looking configuration on a wrong indention level.

Copy link
Contributor

@d7oc d7oc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submitting first feedback. Check until line 800 in values.yaml

Comment on lines +67 to +71
sha:
# @schema
# type: [string, null]
# required: true
# @schema
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should somehow limit the allowed strings here, as per Kubernetes API this can only be Always, Never or IfNotPresent.

Suggested change
sha:
# @schema
# type: [string, null]
# required: true
# @schema
sha:
# @schema
# enum: ["Always", "Never", "IfNotPresent", null]
# required: true
# @schema

Copy link
Contributor Author

@wkloucek wkloucek Dec 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding null to to the enum field does actually not end up in the final schema.

This would be no blocker for .Values.image.pullPolicy, because it is never null.

But .Values.services.<service>.image.pullPolicy needs to be nullable to fallback to .Values.image.pullPolicy

With your changes, liniting fails:

DEBU[2024-12-09T08:01:38+01:00] Using template files [charts/ocis/docs/templates/values-desc-table.adoc.gotmpl] for chart charts/ocis 
/home/wkloucek/go/bin/gomplate-v3.11.8 --file=charts/ocis/docs/templates/values.adoc.yaml.gotmpl  --out=charts/ocis/docs/values.adoc.yaml
/home/wkloucek/go/bin/helm-v3.16.2 lint charts/ocis -f 'charts/ocis/ci/absolute-minimum-values.yaml'
==> Linting charts/ocis
[INFO] Chart.yaml: icon is recommended
[ERROR] values.yaml: - services.activitylog.image.pullPolicy: services.activitylog.image.pullPolicy must be one of the following: "Always", "Never", "IfNotPresent"

As said, this is because the schema doesn't inherit the null:

                 "pullPolicy": {
                   "default": "",
                   "description": "Image pull policy",
+                  "enum": [
+                    "Always",
+                    "Never",
+                    "IfNotPresent"
+                  ],
                   "required": [],
-                  "title": "pullPolicy",
-                  "type": [
-                    "string",
-                    "null"
-                  ]
+                  "title": "pullPolicy"
                 },

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some further reading I guess we need to set type and enum. With type set to string and null as before and enum with the allowed string values. This should do the trick.

charts/ocis/values.yaml Show resolved Hide resolved
charts/ocis/values.yaml Outdated Show resolved Hide resolved
charts/ocis/values.yaml Outdated Show resolved Hide resolved
charts/ocis/values.yaml Show resolved Hide resolved
charts/ocis/values.yaml Show resolved Hide resolved
charts/ocis/values.yaml Show resolved Hide resolved
charts/ocis/values.yaml Show resolved Hide resolved
charts/ocis/values.yaml Show resolved Hide resolved
charts/ocis/values.yaml Show resolved Hide resolved
@d7oc
Copy link
Contributor

d7oc commented Dec 6, 2024

I'm missing the command here to generate the schema from the values.yaml or is there some magic I've overlooked?

@wkloucek wkloucek requested a review from d7oc December 17, 2024 13:58
Copy link
Contributor

@d7oc d7oc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finished review.

Comment on lines +829 to 834
# @schema
# type: [string, null]
# required: false
# @schema
# -- UUID of the initial admin user.
# If the given value matches a user's value from `features.externalUserManagement.oidc.userIDClaim`, the admin role will be assigned.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could used format: "uuid" here

Comment on lines +848 to +851
# @schema
# type: string
# required: true
# @schema
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use format: "email" here

Comment on lines +874 to +877
# @schema
# type: [string, null]
# required: false
# @schema
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use format: "uri" here

Comment on lines +993 to +996
# @schema
# type: [string, null]
# required: false
# @schema
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use format: "uri" here

Comment on lines 1102 to 1103
# -- The object class to use for users in the default user search filter like `inetOrgPerson`.
objectClass: inetOrgPerson
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this skipped intentionally?

Comment on lines +5096 to +5099
# @schema
# type: [string, null]
# required: false
# @schema
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could use format: "uri" here.

# -- Configure the {"styles": []} section in the Web config.json.
styles:
[]
# - href: /theme/foo.css
# @schema
# additionalProperties: true
# @schema
# -- Configure the {"styles": []} section in the Web config.json.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me that this description of the setting is wrong.

Comment on lines +5185 to +5189
postLogoutRedirectURI:
# @schema
# type: [string, null]
# required: false
# @schema
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add format: "uri" here.

Comment on lines +5180 to +5183
# @schema
# type: [string, null]
# required: false
# @schema
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add format: "uri" here.

Comment on lines +5212 to +5215
# @schema
# type: [string, null]
# required: false
# @schema
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add format: "uri" here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add values schema
2 participants