Arnavion / k8s-openapi

Rust definitions of the resource types in the Kubernetes client API
Apache License 2.0
379 stars 41 forks source link

Support custom spec sources #90

Closed MikailBag closed 3 years ago

MikailBag commented 3 years ago

Usage example:

kubectl proxy &
cd k8s-openapi-codegen
VERSIONS=v1.20=http://127.0.0.1:8001/openapi/v2 cargo run

This change is not useful on its own, but it eventually it should allow support non-builtin API groups, such as metrics.k8s.io.

I have not written any documentation yet. What is the best location for docs?

To summarize, using the VERSIONS environment variable user can: 1) Request that only a subset of kubernetes versions should be handled 2) For each version they can provide custom specification URL E.g.: VERSIONS=v.19,v1.20=http://foo.bar/spec.json Here codegen will generate v1.19 (using spec from k/k github repository) and v1.20 (using spec from http://foo.bar/spec.json)

Arnavion commented 3 years ago

I have not written any documentation yet. What is the best location for docs?

Well -codegen has been an "internal" tool up to this point, with the other crates being the point of the repo. But we can change that of course.

Just add it to k8s-openapi-codegen/README.md

To summarize, using the VERSIONS environment variable user can:

It would be better to take it as CLI args:

# Generate all with built-in URLs
k8s-openapi-codegen

# Only generate 1.19 and 1.20 with built-in URLs
k8s-openapi-codegen --generate 1.19 --generate 1.20

# Only generate 1.19 and 1.20, and override URL for 1.20
k8s-openapi-codegen --generate 1.19 --generate 1.20:http://foo.bar/spec.json

(Use structopt please.)

Arnavion commented 3 years ago

I fixed a few things and pushed to https://github.com/Arnavion/k8s-openapi/compare/pr/90

Does that branch look okay to you?

Also, I remembered why I suggested --generate instead of --version - --version already has a use for getting the binary version (as pointless as it is for an "internal" tool like this), and I don't want to override it. So I've renamed it to --generate

MikailBag commented 3 years ago

Does that branch look okay to you?

Yes, sure. Thanks for your review and fixes.