-
Notifications
You must be signed in to change notification settings - Fork 228
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
change emissary CRDs to non-strict + update the CRDs #155
Conversation
thank you for the detailed PR :) maybe we should put the non-strict schemas in their own dir so when a user will want to use the non-strict he will need to be explicit and add the suffix? |
I am not sure what is the intented way to use kubeconform. from the readme
It seems to me there is there is some naming convention intended here, that the path to the strict variante contains literaly "-strict" and "" for the non-strict. Also, thinking back to this PR, I should not have edited the v3 version of the schema. |
I agree this behavior is different from kubeconform, but as you mentioned, it is a separate project, so I'm OK with that. |
I thought a bit about that situation. And the case with emissary is unusual. It just so happen the v1 and v2 were updated way after they were created as a fix to k8s 1.22 breaking changes. I think I will make that PR simpler:
I think this is the easiest way to validate schemas in a sane way. would you be ok with that? |
sounds good to me :) |
@FrancoisPoinsot do you want to work on it or should I close this? |
right, I keep delaying |
specifically using this version of the kubeconform script: yannh/kubeconform#225
Ok so in the end I figured a bit more precisly what fields should or should not receive this This last commit of the current PR is the result running this version of the script. It is now reviewable @eyarz |
How it started
I was trying kubecomform with emissary CRDs and was getting some odd error on the schema.
example with this file
emissary.yaml
:the command:
A bit of history around emissary CRDs
There has been a few changes with emissary CRDs when kubernetes started to enforce a new standard for schema of the CRDs around k8s 1.22.
And to comply, emissary team had to release a v3 version of their schema.
The v1 and v2 lost some field declaration to pass the new requirement from k8s.
They are intended to be used with some unkown field.
Such as
ambassador_id
, which could not be anymore a "string or array".The problem in the schema of this repo
The script used to extract the json schema from the CRDs essentially adds
additionalProperties: false
everywhere, which seems to denies the ability to have unkown field in the resource you validate.The bit of code is the reason why it is added:
https://github.com/yannh/kubeconform/blob/9294e94a8d6471ed825e98401b36a5783382080a/scripts/openapi2jsonschema.py#L28
This kind of schema would be considered the "strict" version for kubeconform.
This is kind of related to that issue: #102
Except here, I am missing the non-strict version of the schema.
Support for strict and non-strict
For kubeconform, having a strict and non-strict version of the scema is resolved using
. StrictSuffix
var in-schema-location
I see that on this repository, there is only 1 other schema that has a strict and non-strict version: the openshift ones.
But I don't think I can reuse that file structure without breaking how to use this repository.
I tried to get something mostly retro-compatible so that the template string used for
-schema-location
when calling kubeconform would not be completly broken.Missing CRDs
I noticed some CRDs don't exist anymore:
I kept them around in this PR.
What that PR does
Running the validation
running against the same file as above: