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

Output of thema lineage gen gobindings does not work outside a cue.mod #77

Closed
sdboyer opened this issue Oct 21, 2022 · 0 comments · Fixed by #84
Closed

Output of thema lineage gen gobindings does not work outside a cue.mod #77

sdboyer opened this issue Oct 21, 2022 · 0 comments · Fixed by #84

Comments

@sdboyer
Copy link
Contributor

sdboyer commented Oct 21, 2022

The CLI go bindings generator (thema lineage gen gobindings) produces a cueFS that tries to embed the right files. Even when it does, though, there's a problem - load.InstancesWithThema() requires a cue.mod/module.cue to exist at the root of the modFS that's passed in.

Or at least, that's the idea. But because of how CUE's load.Instances() scans the filesystem, load.InstancesWithThema() usually works even without that file so long as it's being executed with a cwd that either has a cue.mod, or one of its parent dirs does. This creates an awkward state where thema lineage gen gobindings creates working code sometimes - on the developer's local, when there's a cue.mod.

We need a more robust approach to generation that can work with defaults for the simple/demo case, but still be useful when the codebase in which it's being used has a larger embed.FS system in which the generated code exists. Grafana has such a system, and has built its own helpers - though they aren't great either, and this all really needs genericizing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant