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

V1ServicePort with wrong type for targetPort #666

Closed
Saeger opened this issue Jun 3, 2021 · 10 comments · Fixed by #741 or kubernetes-client/gen#213
Closed

V1ServicePort with wrong type for targetPort #666

Saeger opened this issue Jun 3, 2021 · 10 comments · Fixed by #741 or kubernetes-client/gen#213
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@Saeger
Copy link

Saeger commented Jun 3, 2021

Describe the bug
The "targetPort" type is defined as "object" while the possibility of values can be both number and string.
With this said, you can't set a type for a variable and fill targetPort with a number the way it's implemented.
"Type 'number' is not assignable to type 'object'.ts(2322)"

** Client Version **
0.14.3

** Server Version **
1.18.0

To Reproduce
Steps to reproduce the behavior:
Define a variable of type V1Service and try to make the specs for ports.

Expected behavior
The type definition could be defined as number | string since both are supported.

** Example Code**
ports: [ { name: 'http', port: 80, targetPort: 3000, protocol: 'TCP', }, ],

Environment (please complete the following information):

  • OS: OSX
  • NodeJS Version 14
@brendandburns
Copy link
Contributor

Officially, the targetPort is an IntOrString so we need to implement special handlingwhich currently doesn't exist.

@Saeger
Copy link
Author

Saeger commented Jun 4, 2021

@brendanburns where should I start looking and see if I could help with a fix ?

@brendandburns
Copy link
Contributor

@Saeger thanks for offering to help.

We haven't done this for Javascript before, so it's likely to be a little rocky, but here's what (I think) you need to do.

We need to add typeMappings and importMappings, similar to this one in the Java client:
https://github.com/kubernetes-client/gen/blob/master/openapi/java.xml#L96

To the Javascript client config:
https://github.com/kubernetes-client/gen/blob/master/openapi/typescript.xml

Then you need to regenerate the client:
npm run generate

This code should not compile because it will be missing the IntOrString type, so then you'll need to add custom.ts (or somesuch) and define the IntOrString class in that file.

As I mentioned, complicated, please feel free to ping this issue if you try and see errors!

@k8s-triage-robot
Copy link

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:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/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 Sep 2, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/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 Oct 2, 2021
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closing this issue.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/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.

@brendandburns
Copy link
Contributor

/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Nov 18, 2021
@alex-bezek
Copy link
Contributor

@brendandburns thanks for pointing me to this issue, I've created a couple of pull requests which I think address the issue:

@brendandburns
Copy link
Contributor

I have just pushed an 0.16.1 release to npm that contains a fix for IntOrString types. Many thanks to @alex-bezek for sending the PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
5 participants