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

import failed: no CUE files in k8s.io/api/core/v1 #515

Closed
cueckoo opened this issue Jul 3, 2021 · 6 comments
Closed

import failed: no CUE files in k8s.io/api/core/v1 #515

cueckoo opened this issue Jul 3, 2021 · 6 comments
Labels
get go issues related to cue get go roadmap/errors Related to improving error messages.

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

Originally opened by @weberc2-tempus in cuelang/cue#515

What version of CUE are you using (cue version)?

$ cue version
cue version 0.2.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

Following the tutorial, I did

$ cue mod init foobar
invalid host name "foobar"
$ cue mod init
$ echo 'import "k8s.io/api/core/v1"' > main.cue
$ echo 'services: [string]: v1.#Service' >> main.cue
$ cue get go k8s.io/api/core/v1
$ cue eval
build constraints exclude all CUE files in . (ignored: main.cue)
$ cue eval main.cue
import failed: no CUE files in k8s.io/api/core/v1:
    ./main.cue:1:8

What did you expect to see? / What did you see instead?

I seem to be misunderstanding a few things (I'm brand new to cue, so I assume I'm missing something obvious):

  1. Why can't I pass a module name argument to cue mod init per the documentation?
  2. Why does cue eval ignore main.cue?
  3. Why does the import fail at the end? This is pretty much straight from the example on import Go definitions unless I've made an error somehow?
@cueckoo cueckoo added get go issues related to cue get go roadmap/errors Related to improving error messages. labels Jul 3, 2021
@cueckoo cueckoo closed this as completed Jul 3, 2021
@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @mpvl in cuelang/cue#515 (comment)

CUE files without a package clause need to be listed explicitly on the command line. So if you add a package clause at the top of the file you're good.

This should be mentioned in a better error message.

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @mpvl in cuelang/cue#515 (comment)

also, run go get k8s.io/api/core/v1 first.

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @weberc2-tempus in cuelang/cue#515 (comment)

CUE files without a package clause need to be listed explicitly on the command line. So if you add a package clause at the top of the file you're good. This should be mentioned in a better error message.

Ah, thanks very much.

also, run go get k8s.io/api/core/v1 first.

Does this mean "run go get k8s.io/... before cue mod init"? Because I am running it before cue eval fwiw.

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @verdverm in cuelang/cue#515 (comment)

I think those two commands order does not matter, and that the go get needs to happen before cue get go

cue mod init hof.io/foo  // this needs to be a domain/pkg
go get k8s.io/api/...      // also needs domain/pkg format
cue get go k8s.io/api/core/v1

this did not actually work, to get the files, I had to additionally run the following

go get k8s.io/api/core/v1
cue get go k8s.io/api/core/v1

I now have the files there

It seems that the initial directory specified may need to have Go files / types that Cue can process? (@mpvl ?)

It does look like cue get go k8s.io/api/... works

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @jpugliesi in cuelang/cue#515 (comment)

I'm seeing the same issue as described by @weberc2-tempus. Here's my setup:

file structure:

$ tree -L 2
.
├── cue.mod
│   ├── gen
│   ├── module.cue
│   ├── pkg
│   └── usr
└── services
    ├── main.cue

cue.mod/module.cue:

module: "github.com/jpugliesi/infrastructure"

Attempting to install the k8s packages

go get k8s.io/api/apps/v1
cue get go k8s.io/api/apps/v1
cue get go k8s.io/api/core/v1

listing files in cue.mod (note there aren't any generated files):

$ find ./cue.mod
./cue.mod
./cue.mod/usr
./cue.mod/gen
./cue.mod/gen/k8s.io
./cue.mod/gen/k8s.io/api
./cue.mod/gen/k8s.io/api/core
./cue.mod/gen/k8s.io/api/core/v1
./cue.mod/gen/k8s.io/api/apps
./cue.mod/gen/k8s.io/api/apps/v1
./cue.mod/module.cue
./cue.mod/pkg

main.cue:

import (
  "k8s.io/api/core/v1"
  apps_v1 "k8s.io/api/apps/v1"
)

service: [string]:     v1.#Service
deployment: [string]:  apps_v1.#Deployment
daemonSet: [string]:   apps_v1.#DaemonSet
statefulSet: [string]: apps_v1.#StatefulSet

Error:

$ cue eval -c main.cue
import failed: no CUE files in k8s.io/api/apps/v1:
    ./main.cue:3:3

Cue Version Info

$ cue version
cue version v0.3.0-alpha5.0.20201207144701-6de877a926cf darwin/amd64

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @myitcv in cuelang/cue#515 (comment)

@jpugliesi - from the looks of your repro you are missing a go mod init ABC step, hence the go get succeeds but in the void.

@verdverm - see cuelang/cue#645 for the issue regarding cue mod init being overly restrictive on the module name.

@weberc2-tempus - this issue generally feels like a symptom of the the various issues I summarised in
cuelang/cue#621 (comment). On the basis we have a clear path forward via cuelang/cue#621 (comment), I'm going to close this issue effectively as a duplicate of cuelang/cue#621 (preferring that issue because of the more complete commentary)

Please feel free to raise any further questions/issues over there, or in a separate issue if you think it a separate issue.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
get go issues related to cue get go roadmap/errors Related to improving error messages.
Projects
None yet
Development

No branches or pull requests

1 participant