-
Notifications
You must be signed in to change notification settings - Fork 14
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
fix(cli): include CUEPath in BindingConfig #131
Conversation
Kernel: return error for target schema in validation
This is nearly there as a matter of implementation. But it needs to be refactored for smooth entry depending on whether we have a scalar, list, or struct type, proper docs need to be written, and it needs to be moved into the root thema package.
thema: Introduce `AssignableTo` func and use it to fix `NewInputKernel()` type checking
Cause `UnarySchema.successor` returns a `*UnarySchema`, returning `nil` actually becomes `*UnarySchema(nil)`. In effect, the interface returned from `UnarySchena.Successor` itself is never nil (only the boxed value is), so comparing against nil does not work
UnarySchema: use untyped nil
Remove underscores in Go names
Update cuetsy to v0.1.6
Fix missing underscores
Fix previous refactor to reuse iterate functions
Fix surface Less function and add tests
… only pkg/codegen and pkg/util, which thema's go codegen utilizes, and made changes to pkg/codegen based on the unmerged deepmap/oapi-codegen PR (oapi-codegen/oapi-codegen#717) to fix bug where thema go codegen creates empty interfaces for lineages with joinSchema or any joined (&) CUE values.
…'d codegen package to the main one. Added a txtar test for joinSchema.
…egen [bugfix] Fork deepmap/oapi-codegen to fix joinSchema empty interface codegen bug
Update Cuetsy and Cuelang to the latest version
Fix oapi-codegen check
The cue path (-p flag) was not being passed down to GenerateLineageBinding, so the lineage lookup was missing from generated bindings. This fixes that and also wraps the lineage in quotes (if not already present).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, thank you! Just some small things
"cuelang.org/go/cue/build" | ||
{{ if .CUEPath }}"cuelang.org/go/cue"{{ end }} | ||
"cuelang.org/go/cue/build" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't be necessary? we have a call to goimports in the generator that eliminates unused imports if they're not needed
not a big deal, though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it wasn't necessary, but this is the message thema emits without that line:
"cuelang.org/go/cue"
Relying on goimports to find imports significantly slows down code generation. Either add these imports with an AST manipulation in cfg.ApplyFuncs, or set cfg.IgnoreDiscoveredImports to true```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OH!
derp, i misread the change. yes, it's definitely key to include any imports that may be present, it's just not necessary to wrap them in a conditional in the template. So...
@@ -5,7 +5,8 @@ import ( | |||
"io/fs" | |||
"path/filepath" | |||
|
|||
"cuelang.org/go/cue/build" | |||
{{ if .CUEPath }}"cuelang.org/go/cue"{{ end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...this is what i should have suggested 😄
{{ if .CUEPath }}"cuelang.org/go/cue"{{ end }} | |
"cuelang.org/go/cue" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not better - if we aren't setting the cue path, we're not adding a line with cue.Path, so that import will be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, this is more of a consistency nit than anything. There are other imports in that list - at least embed
and io/fs
- which are only conditionally necessary, as well. But they're not wrapped in a conditional.
The conclusion i came to after writing a few of these templates is that it's easier to maintain a template with the full set of imports that may be necessary and rely on goimports
to remove unnecessary ones for particular cases, than to have the additional conditionals in the template file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I can do that. Can I remove the warning about relying on goimports, if that's now how expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC there shouldn't be a warning about goimports now, because that warning only happens if goimports
is trying to add an import, not if it removes one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And yet, when I ran the command, I got a warning, which is why I made the change. I'd like to either add the import or remove the warning.
cmd/thema/thema
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oop, also need to remove the committed binary
i'd ask that this be rebased out so that it's not in the git commit history 🙏🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i just pushed a commit to main to add this to gitignore
3661c17
to
9e9efc4
Compare
The cue path (-p flag) was not being passed down to GenerateLineageBinding, so the lineage lookup was missing from generated bindings. This fixes that, adds the cue import (if cuepath is set) and finally wraps the lineage value in quotes (if not already present). Both
lineage gen gobindings -p lineage
and `lineage gen gobindings -p "lineage" produce the expected outcome.