-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Determine namespaceability of resources from openapi schema #2978
Determine namespaceability of resources from openapi schema #2978
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mortent The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's good. I don't know what is the best way to detect it from there looking for parameter vs string pattern. You could build a test that walks through all of them and compares?
continue | ||
} | ||
|
||
if strings.Contains(path, "namespaces/{namespace}") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you have two options:
- Look for that specific pattern in the path, or
- A path parameter like this:
"in": "path",
"name": "namespace",
"required": true,
"type": "string",
- Or both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think both approaches should work equally well. The only tricky part is that even namespaced resources will have some paths that doesn't include the namespace path parameter (like /apis/apps/v1/deployments
). But the code does account for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that's fine! If you feel confident that this is good enough, go for it!
/lgtm
This uses the openapi schema to determine whether a resource is namespace-scoped or cluster-scoped as described here.
Since up until now the openapi schema that was included in kpt was not complete, but only included type definitions, I had to update the openapi schema. It is still based on kubernetes version 1.17.
This only makes the logic available in kyaml, it does not update kustomize to use it.
Ref: #2861