Closed gregth closed 2 years ago
Let's discuss if anyone else has bumped onto this before, possible solutions, and I proceed with a PR to fix this, if you'd like to.
I don't think anyone else has hit this. Feel free to add a flag to optionally disable that check
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.
This bot triages issues and PRs according to the following rules:
lifecycle/stale
is appliedlifecycle/stale
was applied, lifecycle/rotten
is appliedlifecycle/rotten
was applied, the issue is closedYou can:
/remove-lifecycle stale
/lifecycle rotten
/close
Please send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
Instead of adding an extra argument, we can fix this by modifying this if-else statement: https://github.com/kubernetes-client/gen/blob/34ea9c4d4e0c6aeb1c41858b2b230adac3bacfe3/openapi/preprocess_spec.py#L311-L320
so that it does not ignore io.k8s
if the user has explicitly specified a KUBERNETES_CRD_GROUP_PREFIX
that contains k8s.io
:
def filter_api_group(spec):
models = {}
for k, v in spec['definitions'].items():
if k.startswith(os.environ.get('KUBERNETES_CRD_GROUP_PREFIX')):
models[k] = v
elif k.startswith("io.k8s"):
print("Removing builtin Kubernetes Resource %s" %k)
else:
print("Ignoring Custom Resource %s" %k)
spec['definitions'] = models
@brendandburns what do you think? If we agree I can PR this and close this issue.
This issue was resolved by PR https://github.com/kubernetes-client/gen/pull/223.
I tried to generate models for Volume Snapshots, as follows:
This produced no models.
I inspected the code and it turns out that resources starting with "io.k8s" are considered built:
https://github.com/kubernetes-client/gen/blob/291f9a6ca5004cc91cfc4a744abf129c639d5682/openapi/preprocess_spec.py#L307-L316
This does not hold for (at least) Volume Snapshot resources which are well-known CRDs.
I tweaked a few lines of the script and here is a list of the Resources that were initially ignored, in my case: