-
Notifications
You must be signed in to change notification settings - Fork 294
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
cmd/cue: tags across packages #1070
Comments
Original reply by @maurerbot in cuelang/cue#1070 (comment) Adding |
Original reply by @verdverm in cuelang/cue#1070 (comment) Related is #1005 |
@maurerbot - thanks for raising this. As @verdverm linked above, this is very much related to #1005 insofar as the current documentation is lacking. FYI - I have just tweaked #1005 to make it clearer to the reader what is going on, and added detail on the In case it's useful, here is my encoding of your example using the techniques for creating reproducers described in the wiki:
This passes. i.e. it's expected that running So I think this is working as expected, modulo us fixing up the documentation to make it clearer (thank you for the Stepping back for one second though, can you describe in more detail what you are trying to do here? |
Here is one use case for cross package tags: I'd like to build a system similar to Helm charts for my operator; I put in a CRD and have Cue generate a list of K8s resources. The CRD is always the same type but the "chart" varies depending on a field in the CRD (selection of the chart package happens in the operator). I inject my CRD using JSON in a tag:
Now I a) don't want to include this in my output and b) I don't want to repeat this code in every single chart and c) I want to be able to render just one chart and not all at once. I think this requires cross package tags. How about a syntax that contains the package name:
? |
Being explicit about in which package to inject something seems reasonable. |
I like the package suggestion. What I also realized, is that for some configurations, maybe yours, there may be full control over the tag namespace. That is, it may be okay to apply tags to all packages in the same module. That will certainly not be okay for all setups, but we could make it an option. For instance, in the above the tag from the package could potentially be defined as
Here, the The default scope would be In a similar vain, I could imagine that a company with multiple CUE modules could want to scope on a specific module prefix, for instance. Feedback welcome. |
I like the idea. What would happen if a package x: string @tag(name) And in package y: string @tag(name, scope=mod)
For me:
Maybe another option would be to have a different attribute for module scoped tags, but naming is hard :) |
@eonpatapon @jgillich In other words, for the default scope (package) a tag would only apply if that package is the one that is loaded (the target of the the command line args). For tags listed as module scope, a tag specified on the command line would also apply if the package is merely imported. So yes, I think we are in agreement. For people just jumping in: note that tags are a simple pre-evaluation syntactic rewrite. So the loader just scans the syntax tree and rewrites all tags that match. Currently it only does so for the main package. But with this proposal it would need to also scan all imported packages in the same module. Naming is indeed hard. :) But I would not add another |
Hi, any news about that?
If you put that type in some other package and execute |
Originally opened by @maurerbot in cuelang/cue#1070
cue
seems to be unable to pick up tags across packages.What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
cue/cue.mod/module.cue
module: my.tld
cue/schema/base/base.cue
cue/schema/v1alpha1/test.cue
What did you expect to see?
What did you see instead?
no tag for "name"
Alternatively
Other Questions
Spec
is the right approachThe text was updated successfully, but these errors were encountered: