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

Support failedTemplate assert for schema validation errors #155

Merged
merged 1 commit into from
Sep 24, 2022

Conversation

rquinio
Copy link

@rquinio rquinio commented Feb 23, 2022

Fixes #134

This is only supported for helm v3.
FailedTemplateValidator now checks for a global error in validation context, before matching on per template rendering errors.

An alternative would be to use a dedicated "FailedSchemaValidator" with a structured representation of schema errors (i.e. parse using regex the string "values don't meet the specifications of the schema(s) in the following chart(s):\nwith-schema:\n- (root): image is required\n"), let me know what you think.

This is only supported for helm v3.
FailedTemplateValidator now checks for a global error in validation context, before matching on per template rendering errors.
@faithdoub
Copy link

faithdoub commented Feb 25, 2022

Good Morning @rquinio -- thanks a lot for this fix. I fetched your pull yesterday to test it out. I stared at the failed test for about 10 minutes (same as before) and then found the Failed Template Validate function where the Actual and Template Messages are available and hex encoded them only to find out that I was missing a Line Feed (my Error Message is 4 lines and I was only supplying the 3 lines where there was text). Thanks again to @quintush - would not write a helm chart without this plugin.

Looking back at your message and you have the training \n - my mistake. Easy mistake to make.

@rquinio
Copy link
Author

rquinio commented Feb 26, 2022

Hi @faithdoub,
Indeed I also have a \n at the end in the test:

it: should work
template: dummy.yaml
asserts:
  - failedTemplate:
      errorMessage: "values don't meet the specifications of the schema(s) in the following chart(s):\nwith-schema:\n- (root): image is required\n"

Btw I tried to use multi-line YAML with | but the YAML parser seemed confused, not sure why because I think multiline is supported in some other asserts (?).

@faithdoub
Copy link

faithdoub commented Mar 1, 2022

Hi @rquinio,

I was able to get the multi-line YAML working: (blank line at bottom is required)

asserts:
  - failedTemplate: 
      errorMessage: |
        values don't meet the specifications of the schema(s) in the following chart(s):
        eks-namespace-provisioning:
        - namespace: name is required

@eshepelyuk
Copy link

Any news on merging this PR ?

@faithdoub
Copy link

faithdoub commented Jun 22, 2022 via email

@eshepelyuk
Copy link

eshepelyuk commented Jun 22, 2022

No, I check every once in a while to see if there is a new release but there hasn't been one since 11/2021

any other maintained fork to switch to ? @faithdoub ?

@mederel
Copy link

mederel commented Jan 4, 2023

Hi @rquinio,

I was able to get the multi-line YAML working: (blank line at bottom is required)

asserts:
  - failedTemplate: 
      errorMessage: |
        values don't meet the specifications of the schema(s) in the following chart(s):
        eks-namespace-provisioning:
        - namespace: name is required

I guess this can be done with the > instead of | which inserts a new line at the end of the text block is there is not one.

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

Successfully merging this pull request may close these issues.

Helm values.schema.json and failedTemplate errorMessage
5 participants