cdk8s-team / cdk8s-cli

Apache License 2.0
37 stars 20 forks source link

`cdk8s import github:knative/operator@knative-v1.10.2` results in unsupported protocol github #2339

Open Vad1mo opened 10 months ago

Vad1mo commented 10 months ago

I am trying to import a CRD that is listed on https://doc.crds.dev/github.com/grafana/agent@v0.35.4 into cdk8s.

From the cdk8s import --help I got the description that cdk8s import github:crossplane/crossplane@0.14.0 Imports constructs for a GitHub repo using doc.crds.dev should work.

I tried cdk8s import github:crossplane/crossplane@0.14.0and the result was successful

❯ cdk8s import github:crossplane/crossplane@0.14.0
Importing resources, this may take a few moments...
apiextensions.crossplane.io
  apiextensions.crossplane.io/compositeresourcedefinition
  apiextensions.crossplane.io/composition
pkg.crossplane.io
  pkg.crossplane.io/configuration
  pkg.crossplane.io/configurationrevision
  pkg.crossplane.io/controllerconfig
  pkg.crossplane.io/provider
  pkg.crossplane.io/providerrevision
meta.pkg.crossplane.io
  meta.pkg.crossplane.io/configuration
  meta.pkg.crossplane.io/provider

Description of the bug:

When I however try to import github:grafana/agent@v0.35.4 I see this error:

❯ cdk8s import github:grafana/agent@v0.35.4
Error: unsupported protocol github:
    at download (/opt/homebrew/Cellar/cdk8s/2.50.0/libexec/lib/node_modules/cdk8s-cli/lib/util.js:177:19)
    at ImportCustomResourceDefinition.fromSpec (/opt/homebrew/Cellar/cdk8s/2.50.0/libexec/lib/node_modules/cdk8s-cli/lib/import/crd.js:108:52)
    at matchImporter (/opt/homebrew/Cellar/cdk8s/2.50.0/libexec/lib/node_modules/cdk8s-cli/lib/import/dispatch.js:35:49)
    at async importDispatch (/opt/homebrew/Cellar/cdk8s/2.50.0/libexec/lib/node_modules/cdk8s-cli/lib/import/dispatch.js:10:26)
    at async Object.handler (/opt/homebrew/Cellar/cdk8s/2.50.0/libexec/lib/node_modules/cdk8s-cli/lib/cli/cmds/import.js:31:9)

Reproduction Steps:

cdk8s import github:grafana/agent@v0.35.4

Error Log:

Error: unsupported protocol github:
    at download (/opt/homebrew/Cellar/cdk8s/2.50.0/libexec/lib/node_modules/cdk8s-cli/lib/util.js:177:19)
    at ImportCustomResourceDefinition.fromSpec (/opt/homebrew/Cellar/cdk8s/2.50.0/libexec/lib/node_modules/cdk8s-cli/lib/import/crd.js:108:52)
    at matchImporter (/opt/homebrew/Cellar/cdk8s/2.50.0/libexec/lib/node_modules/cdk8s-cli/lib/import/dispatch.js:35:49)
    at async importDispatch (/opt/homebrew/Cellar/cdk8s/2.50.0/libexec/lib/node_modules/cdk8s-cli/lib/import/dispatch.js:10:26)
    at async Object.handler (/opt/homebrew/Cellar/cdk8s/2.50.0/libexec/lib/node_modules/cdk8s-cli/lib/cli/cmds/import.js:31:9)

Environment:

Other:


This is :bug: Bug Report

pbar1 commented 10 months ago

I was also running into this and figured out it was due to the v prefix in the tag. Looks like that breaks the URL resolution here a bit. doc.crds.dev will output tags containing the v prefix (you and I probably copy-pasted it from the site), so it should probably be supported here 😄

Here's some evidence from my end:

~/code/pbcloud-next ↓3
♪ yarn cdk8s import github:projectcontour/contour@v1.25.0
Error: unsupported protocol github:
    at download (/Users/pierce/code/pbcloud-next/.yarn/unplugged/cdk8s-cli-npm-2.64.0-cf582c8fb4/node_modules/cdk8s-cli/lib/util.js:177:19)
    at ImportCustomResourceDefinition.fromSpec (/Users/pierce/code/pbcloud-next/.yarn/unplugged/cdk8s-cli-npm-2.64.0-cf582c8fb4/node_modules/cdk8s-cli/lib/import/crd.js:108:52)
    at matchImporter (/Users/pierce/code/pbcloud-next/.yarn/unplugged/cdk8s-cli-npm-2.64.0-cf582c8fb4/node_modules/cdk8s-cli/lib/import/dispatch.js:35:49)
    at async importDispatch (/Users/pierce/code/pbcloud-next/.yarn/unplugged/cdk8s-cli-npm-2.64.0-cf582c8fb4/node_modules/cdk8s-cli/lib/import/dispatch.js:10:26)
    at async Object.handler (/Users/pierce/code/pbcloud-next/.yarn/unplugged/cdk8s-cli-npm-2.64.0-cf582c8fb4/node_modules/cdk8s-cli/lib/cli/cmds/import.js:31:9)

~/code/pbcloud-next ↓3 ⚠ ERROR
ø yarn cdk8s import github:projectcontour/contour@1.25.0 
Importing resources, this may take a few moments...
projectcontour.io
  projectcontour.io/contourconfiguration
  projectcontour.io/contourdeployment
  projectcontour.io/extensionservice
  projectcontour.io/httpproxy
  projectcontour.io/tlscertificatedelegation
Vad1mo commented 10 months ago

@pbar1 thank you for your kind response, Indeed this was the issue.

This is the way to go without the vversion prefix.

cdk8s import github:grafana/agent@0.35.4
pbar1 commented 9 months ago

Hey, I wouldn't necessarily call this closed. Take https://doc.crds.dev/github.com/knative/operator for example - the tag one would want to import would also run into this issue without being able to remove the v prefix - the import command shakes out to look like:

cdk8s import github:knative/operator@knative-v1.10.2

One can't just remove the knative-v prefix in this case.

iliapolo commented 1 month ago

Hmm. The knative-v tags are definitely unexpected :\