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

fix(cli): include CUEPath in BindingConfig #131

Closed
wants to merge 398 commits into from
Closed

Conversation

mildwonkey
Copy link

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.

sam boyer and others added 30 commits January 23, 2022 23:09
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
AgnesToulet and others added 23 commits February 21, 2023 17:54
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
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).
@mildwonkey mildwonkey requested a review from sdboyer April 28, 2023 15:13
Copy link
Contributor

@sdboyer sdboyer left a 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

Comment on lines -8 to +9
"cuelang.org/go/cue/build"
{{ if .CUEPath }}"cuelang.org/go/cue"{{ end }}
"cuelang.org/go/cue/build"
Copy link
Contributor

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

Copy link
Author

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```

Copy link
Contributor

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...

encoding/gocode/gen.go Show resolved Hide resolved
@@ -5,7 +5,8 @@ import (
"io/fs"
"path/filepath"

"cuelang.org/go/cue/build"
{{ if .CUEPath }}"cuelang.org/go/cue"{{ end }}
Copy link
Contributor

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 😄

Suggested change
{{ if .CUEPath }}"cuelang.org/go/cue"{{ end }}
"cuelang.org/go/cue"

Copy link
Author

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.

Copy link
Contributor

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.

Copy link
Author

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?

Copy link
Contributor

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.

Copy link
Author

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
Copy link
Contributor

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 🙏🏻

Copy link
Contributor

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

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 this pull request may close these issues.

None yet

9 participants