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

Can't import CRD if kind is object #1291

Closed
disaster37 opened this issue Apr 19, 2023 · 5 comments
Closed

Can't import CRD if kind is object #1291

disaster37 opened this issue Apr 19, 2023 · 5 comments
Labels
bug Something isn't working closed-for-staleness Issue/PR was closed due to staleness effort/medium 1 week tops priority/p2 Dependent on community feedback. PR's are welcome :)

Comments

@disaster37
Copy link

disaster37 commented Apr 19, 2023

Description of the bug:

We can't import CRD with kind object.
I get error kubernetes.crossplane.io.ts:91:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
If I rename the ressource Object2, it's work.

before rename:

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    controller-gen.kubebuilder.io/version: v0.11.1
  creationTimestamp: null
  name: objects.kubernetes.crossplane.io
spec:
  group: kubernetes.crossplane.io
  names:
    categories:
    - crossplane
    - managed
    - kubernetes
    kind: Object
    listKind: ObjectList
    plural: objects
    singular: object
  scope: Cluster

after rename:

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    controller-gen.kubebuilder.io/version: v0.11.1
  creationTimestamp: null
  name: objects.kubernetes.crossplane.io
spec:
  group: kubernetes.crossplane.io
  names:
    categories:
    - crossplane
    - managed
    - kubernetes
    kind: Object2
    listKind: ObjectList
    plural: objects
    singular: object
  scope: Cluster

Reproduction Steps:

cdk8s import \
    https://raw.githubusercontent.com/crossplane-contrib/provider-kubernetes/v0.7.0/package/crds/kubernetes.crossplane.io_objects.yaml \
    --language go

Error Log:

Importing resources, this may take a few moments...
kubernetes.crossplane.io
  kubernetes.crossplane.io/object
NOTE: Temp directory retained due to an error: /tmp/temp-fKiLXi
Error: jsii compilation failed with non-zero exit code: 1
  | [2023-04-19T14:13:34.028] [ERROR] jsii/compiler - Compilation errors prevented the JSII assembly from being created
  | warning JSII6: A "peerDependency" on "constructs" at "10.2.1" means you should take a "devDependency" on "constructs" at "10.2.1" (found "undefined")
  | warning JSII6: A "peerDependency" on "cdk8s" at "2.7.56" means you should take a "devDependency" on "cdk8s" at "2.7.56" (found "undefined")
  | warning JSII3: There is no "README.md" file. It is required in order to generate valid PyPI (Python) packages.
  | kubernetes.crossplane.io.ts:91:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 91   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                    ~~~~~~~
  | kubernetes.crossplane.io.ts:91:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 91   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                            ~
  | kubernetes.crossplane.io.ts:91:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 91   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                               ~
  | kubernetes.crossplane.io.ts:180:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 180   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:180:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 180   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:180:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 180   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:263:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 263   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:263:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 263   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:263:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 263   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:304:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 304   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:304:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 304   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:304:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 304   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:357:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 357   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:357:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 357   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:357:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 357   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:394:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 394   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:394:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 394   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:394:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 394   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:439:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 439   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:439:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 439   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:439:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 439   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:484:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 484   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:484:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 484   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:484:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 484   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:521:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 521   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:521:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 521   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:521:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 521   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:558:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 558   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:558:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 558   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:558:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 558   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:595:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 595   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:595:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 595   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:595:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 595   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:632:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 632   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:632:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 632   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:632:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 632   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:672:76 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 672     'annotations': ((obj.annotations) === undefined) ? undefined : (Object.entries(obj.annotations).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {})),
  |                                                                                ~~~~~~~
  | kubernetes.crossplane.io.ts:672:109 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 672     'annotations': ((obj.annotations) === undefined) ? undefined : (Object.entries(obj.annotations).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {})),
  |                                                                                                                 ~
  | kubernetes.crossplane.io.ts:672:112 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 672     'annotations': ((obj.annotations) === undefined) ? undefined : (Object.entries(obj.annotations).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {})),
  |                                                                                                                    ~
  | kubernetes.crossplane.io.ts:673:66 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 673     'labels': ((obj.labels) === undefined) ? undefined : (Object.entries(obj.labels).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {})),
  |                                                                      ~~~~~~~
  | kubernetes.crossplane.io.ts:673:94 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 673     'labels': ((obj.labels) === undefined) ? undefined : (Object.entries(obj.labels).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {})),
  |                                                                                                  ~
  | kubernetes.crossplane.io.ts:673:97 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 673     'labels': ((obj.labels) === undefined) ? undefined : (Object.entries(obj.labels).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {})),
  |                                                                                                     ~
  | kubernetes.crossplane.io.ts:677:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 677   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:677:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 677   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:677:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 677   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:730:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 730   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:730:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 730   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:730:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 730   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:791:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 791   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:791:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 791   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:791:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 791   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  | kubernetes.crossplane.io.ts:876:17 - error TS2339: Property 'entries' does not exist on type 'typeof Object'.
  | 876   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                     ~~~~~~~
  | kubernetes.crossplane.io.ts:876:41 - error TS7006: Parameter 'r' implicitly has an 'any' type.
  | 876   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                             ~
  | kubernetes.crossplane.io.ts:876:44 - error TS7006: Parameter 'i' implicitly has an 'any' type.
  | 876   return Object.entries(result).reduce((r, i) => (i[1] === undefined) ? r : ({ ...r, [i[0]]: i[1] }), {});
  |                                                ~
  +----------------------------------------------------------------------------------
  | Command: /usr/local/share/nvm/versions/node/v19.8.1/lib/node_modules/cdk8s-cli/node_modules/jsii/bin/jsii --silence-warnings reserved-word
  | Workdir: /tmp/temp-fKiLXi
  +----------------------------------------------------------------------------------
    at newError (/usr/local/share/nvm/versions/node/v19.8.1/lib/node_modules/cdk8s-cli/node_modules/jsii-srcmak/lib/util.js:62:20)
    at ChildProcess.<anonymous> (/usr/local/share/nvm/versions/node/v19.8.1/lib/node_modules/cdk8s-cli/node_modules/jsii-srcmak/lib/util.js:79:29)
    at Object.onceWrapper (node:events:627:26)
    at ChildProcess.emit (node:events:512:28)
    at ChildProcess._handle.onexit (node:internal/child_process:293:12)

Environment:

  • Framework Version: cdk8s 2.2.14
  • OS: ubuntu

Other:


This is 🐛 Bug Report

@disaster37 disaster37 added bug Something isn't working needs-triage Priority and effort undetermined yet labels Apr 19, 2023
@sumupitchayan sumupitchayan self-assigned this Apr 19, 2023
@sumupitchayan sumupitchayan added effort/small 1 day tops priority/p1 Should be on near term plans and removed needs-triage Priority and effort undetermined yet labels Apr 19, 2023
@sumupitchayan
Copy link
Contributor

@disaster37 I believe this is happening because there is a built in Object type in Typescript, so when cdk8s tries to convert the CRD into a Typescript class it will not work.

I am unsure if there is any way around this other than renaming the the resource as you did.

@sumupitchayan sumupitchayan added the response-requested Awaiting response from author label Apr 19, 2023
@disaster37
Copy link
Author

I haven't understand how it import crd. But I think it can detect that the kind is 'object' and name it with different name. A the end, when it generates yaml resource, it must redo 'object'. 

Maybee there are a workground to overwrite something on generated with object2 to simply get object when generate kubernetes manifest like overwrite getKind() 

@github-actions github-actions bot removed the response-requested Awaiting response from author label Apr 19, 2023
@sumupitchayan sumupitchayan added priority/p2 Dependent on community feedback. PR's are welcome :) effort/medium 1 week tops and removed priority/p1 Should be on near term plans effort/small 1 day tops labels Apr 20, 2023
@sumupitchayan
Copy link
Contributor

@disaster37 We are going to label this as a p2 issue, which means we will not prioritize implementing a workaround for this issue as it is a pretty rare case. Since there is not way to get around the default Object class in Typescript, the likely solution to this problem would be to rename any CRD imports with the kind Object by prefixing the group to its class name. For example, KubernetesCrossplaneIoObject instead of Object.

Contributions are very much welcome though, so feel free to put up a PR for this issue if you'd like. To get around this issue for now, you can rename the Object kind in the CRD as you have done.

@IsaacLeeWebDev
Copy link

IsaacLeeWebDev commented Jul 25, 2023

I ran into this same issue while trying to import github:upbound/provider-aws-s3, which– being S3– works with Objects.

I think a good fix for this would include support for --class-prefix on all imports, and a corresponding cdk8s.yaml API for setting it.

Copy link
Contributor

This issue has not received any attention in 1 year and will be closed soon. If you want to keep it open, please leave a comment below @mentioning a maintainer.

@github-actions github-actions bot added the closing-soon Issue/PR will be closing soon if no response is provided label Jul 24, 2024
@github-actions github-actions bot added closed-for-staleness Issue/PR was closed due to staleness and removed closing-soon Issue/PR will be closing soon if no response is provided labels Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working closed-for-staleness Issue/PR was closed due to staleness effort/medium 1 week tops priority/p2 Dependent on community feedback. PR's are welcome :)
Projects
None yet
Development

No branches or pull requests

3 participants