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 client generation for CRD #59

Closed
tamalsaha opened this issue Apr 9, 2018 · 8 comments
Closed

Support client generation for CRD #59

tamalsaha opened this issue Apr 9, 2018 · 8 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@tamalsaha
Copy link
Contributor

Following @mbohlool 's advice kubernetes/kube-openapi#13 (comment), I have managed to generate swagger.json for my CRD. In the spirit of not reinventing the wheel, I was hoping to generate Java client using this repo. But I noticed that the swagger.json file is hardcoded to Kubernetes repos swagger.json https://github.com/kubernetes-client/gen/blob/master/openapi/preprocess_spec.py#L302 .

Do you have any suggestion how can I go about generating Java client from my CRD's swagger.json ?

@tamalsaha
Copy link
Contributor Author

cc: @brendanburns

@tamalsaha
Copy link
Contributor Author

I tried using the swagger-generator directly who produced something https://github.com/tamalsaha/kube-openapi-generator . I am not sure whether I should be generating types shared from Kubernetes types and also how should auth work.

@mbohlool
Copy link
Contributor

You can add a flag to client generator to completely bypass preprocessing step if you don't need it.

@tamalsaha
Copy link
Contributor Author

tamalsaha commented Apr 15, 2018

I did some experimentation with the Java client generator for our Voyager project and was able to generate client. The generated client uses the models from Kubernetes java-client. One limitation is that there is no util.Config so instantiating client is kind of awkward.

Here are the relevant repos:

Here is the list of changes I had to make:

  • Update swagger.json path. I think this can be fixed by passing swagger.json using a --build-args.
  • Use my forked swagger-codegen to update templates for pom.xml, etc.
  • Update artifactid etc. for java generator config.
  • Update type and import mappings in java generator config so that generated code uses Kubernetes java-client models instead of regenerating them.
  • Skip generating custom object api client.
  • Pre-process swagger.json to remove definitions of official Kubernetes objects and shorten prefix for Voyager specific type definitions.

I would like to get your comments on how CRD projects should generate client for their projects based on this experiment.

tamalsaha added a commit to voyagermesh/gen that referenced this issue Jun 19, 2018
To generate client for CRDs, I needed to use a forked version of swagger-api.
ref: kubernetes-client#59 (comment)
tamalsaha added a commit to voyagermesh/gen that referenced this issue Jun 19, 2018
To generate client for CRDs, I needed to use a forked version of swagger-api.
ref: kubernetes-client#59 (comment)
tamalsaha added a commit to voyagermesh/gen that referenced this issue Jun 19, 2018
To generate client for CRDs, I needed to use a forked version of swagger-codegen.
ref: kubernetes-client#59 (comment)
tamalsaha added a commit to voyagermesh/gen that referenced this issue Jun 19, 2018
To generate client for CRDs, I needed to use a forked version of swagger-api.
ref: kubernetes-client#59 (comment)
tamalsaha added a commit to voyagermesh/gen that referenced this issue Jun 19, 2018
To generate client for CRDs, I needed to use a forked version of swagger-api.
ref: kubernetes-client#59 (comment)
tamalsaha added a commit to voyagermesh/gen that referenced this issue Jun 19, 2018
To generate client for CRDs, I needed to use a forked version of swagger-codegen.
ref: kubernetes-client#59 (comment)
tamalsaha added a commit to kubedb/gen that referenced this issue Jun 20, 2018
To generate client for CRDs, I needed to use a forked version of swagger-codegen.
ref: kubernetes-client#59 (comment)
tamalsaha added a commit to voyagermesh/gen that referenced this issue Jun 20, 2018
To generate client for CRDs, I needed to use a forked version of swagger-codegen.
ref: kubernetes-client#59 (comment)
brendandburns pushed a commit that referenced this issue Jun 29, 2018
To generate client for CRDs, I needed to use a forked version of swagger-api.
ref: #59 (comment)
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 23, 2019
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 23, 2019
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

4 participants