console icon indicating copy to clipboard operation
console copied to clipboard

Introduce package kube-types: add generators for OpenShift and KubeVirt TypeScript definitions

Open atiratree opened this issue 6 years ago • 13 comments
trafficstars

This PR adds complete types with documentation for all Kubernetes/OpenShift/KubeVirt objects (please see old #1773 for more details).

The types are generated from OpenAPI specification taken from

  • openshift(https://github.com/openshift/origin/tree/master/api/swagger-spec)
  • kubevirt (https://github.com/kubevirt/kubevirt/tree/master/api/openapi-spec)

This PR uses openapi-generator instead of autorest which was mentioned in the last PR.

I found many problems with autorest:

  • unstable (crashes on quite a lot of nodejs versions)
  • slow
  • incorrect parsing of kubevirt's swagger.json.

openapi-generator worked quite well for me, but I still had to do few necessary changes in post processing phase.

Algorithm:

  • download current API Spec file (or add a custom URL to ENV variable)
  • process the spec file (remove paths key to inhibit API generation )
  • run openapi-generator which should generate just the models
  • for each generated file:
    • remove unnecessary functions (like IoK8sApiCoreV1SecretFromJSON)
    • remove unnecessary imports (like import { exists, mapValues } from '../runtime';) for these functions
    • import each file specifically instead of from './' to prevent circular dependencies
    • replace occurrences for example of IoK8sApiCoreV1Pod with V1Pod
  • run ESLint to enforce our formatting rules onto the generated files

@spadgett @alecmerdler @christianvogt @vojtechszocs

atiratree avatar Jun 25 '19 15:06 atiratree

Hi @suomiy. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

openshift-ci-robot avatar Jun 25 '19 15:06 openshift-ci-robot

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: suomiy To complete the pull request process, please assign alecmerdler You can assign the PR to them by writing /assign @alecmerdler in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

openshift-ci-robot avatar Jun 25 '19 15:06 openshift-ci-robot

/assign @alecmerdler

spadgett avatar Jun 26 '19 13:06 spadgett

/test e2e-aws-console-olm

atiratree avatar Jul 15 '19 10:07 atiratree

@alecmerdler can you please take a look?

atiratree avatar Jul 22 '19 09:07 atiratree

Things to consider:

  • we could generate the types just for development and not commit them into the repo. We would generate them each time yarn install or yarn dev is called. The generated files could be cached by comparing the commit hash of swagger.json. Main disadvantages:

    • our build depends on other repo (GH availability ) and location of certain file
    • we should lock our build to a release branch/tag of openshift/kubevirt to prevent building with potential breaking changes of the API. New versions still would have to be updated manually.
    • longer build time; +25s on my machine
  • currently, I am linting the generated files, but this step could be skipped by adding packages/kube-types into .eslintignore

atiratree avatar Jul 30 '19 10:07 atiratree

/retest

atiratree avatar Aug 13 '19 14:08 atiratree

In general, I like the idea of having comprehensive & updated types. Thanks for working on that. My concerns are just related to maintainability.

our build depends on other repo (GH availability ) and location of certain file

Exactly. I think it's better to keep the generated files or source for their generation in the repo. And commit changes wisely. In addition, it must be straightforward to do a build in an offline environment (which is already resolved for npm).

we should lock our build to a release branch/tag of openshift/kubevirt to prevent building with potential breaking changes of the API. New versions still would have to be updated manually.

IMO, this complexity out-weights benefits in the long-term.

currently, I am linting the generated files, but this step could be skipped by adding

I agree we do not need to care much about syntax in the generated code as long as the process for its creation is clear.

mareklibra avatar Aug 14 '19 06:08 mareklibra

@alecmerdler can we proceed with this now for 4.3 ?

atiratree avatar Sep 26 '19 09:09 atiratree

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close. Exclude this issue from closing by commenting /lifecycle frozen.

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

/lifecycle stale

openshift-bot avatar Sep 22 '20 23:09 openshift-bot

/lifecycle frozen

atiratree avatar Sep 23 '20 10:09 atiratree

@suomiy: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-gcp-console edc9f92e82afb8f7aa841d39fa927d248dfd374e link /test e2e-gcp-console
ci/prow/e2e-gcp edc9f92e82afb8f7aa841d39fa927d248dfd374e link /test e2e-gcp
ci/prow/analyze edc9f92e82afb8f7aa841d39fa927d248dfd374e link /test analyze
ci/prow/kubevirt-plugin edc9f92e82afb8f7aa841d39fa927d248dfd374e link /test kubevirt-plugin

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

openshift-ci-robot avatar Oct 06 '20 12:10 openshift-ci-robot

@atiratree: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/kubevirt-plugin edc9f92e82afb8f7aa841d39fa927d248dfd374e link /test kubevirt-plugin
ci/prow/ceph-storage-plugin edc9f92e82afb8f7aa841d39fa927d248dfd374e link /test ceph-storage-plugin
ci/prow/images edc9f92e82afb8f7aa841d39fa927d248dfd374e link true /test images
ci/prow/okd-scos-images edc9f92e82afb8f7aa841d39fa927d248dfd374e link true /test okd-scos-images
ci/prow/e2e-gcp-console edc9f92e82afb8f7aa841d39fa927d248dfd374e link true /test e2e-gcp-console
ci/prow/analyze edc9f92e82afb8f7aa841d39fa927d248dfd374e link true /test analyze
ci/prow/frontend edc9f92e82afb8f7aa841d39fa927d248dfd374e link true /test frontend
ci/prow/backend edc9f92e82afb8f7aa841d39fa927d248dfd374e link true /test backend

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

openshift-ci[bot] avatar Feb 17 '25 22:02 openshift-ci[bot]

PR needs rebase.

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-sigs/prow repository.

openshift-merge-robot avatar Feb 17 '25 22:02 openshift-merge-robot

stale

atiratree avatar Feb 18 '25 15:02 atiratree