Tag Injection Across Modules #3006
Replies: 3 comments
-
|
i tried; ''' this will output both packages, but the injection isnt working like you would think and foovar is not defined in :foo |
Beta Was this translation helpful? Give feedback.
-
|
I don't believe this is currently possible
tl;dr tag injection is part of the Another thing to consider, what would happen if you use a tag and one of the 3rd party modules you import has the same tag, but expects a different kind of value. Thus it makes sense to only process tags at the top-level (entrypoint package) and ignore others. Typically and generally speaking, libraries don't expose flags directly, but may give you a handle to expose them in your own applications. You should be define the flags and then expose them like so -- library.cue --
package library
#flags: {
foo: string @tag(foo)
}
#thing: {
flags: #flags
bar: *flags.foo | "bar"
}
-- main.cue --
package main
import "foo.com/library"
myflags: library.#flags
thing: library.#thing & { flags: myflags }
|
Beta Was this translation helpful? Give feedback.
-
|
I don't think there is a satisfying workaround for conditional building based on flags right now. e.g. -- library.cue --
package library
#thing : {
bar : string
}
-- library_cpp.cue --
@if(foo)
package library
#thing : {
bar : "foo"
}
-- main.cue --
package main
import "foo.com/library"
thing: library.#thing |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have a module with a bunch of packages that I import and use across files. I want to specify tags in one file and be able to inject the tags from another file. However, this seems to be impossible so I wanted to post here asking for suggestions!
library.cue
main.cue
This command works, as expected
I want to be able to call this from the command line as so:
But this returns with the following error:
no tag for "injectedValue"Is there any way I can get this to work? Any help would be deeply appreciated thank you!
Beta Was this translation helpful? Give feedback.
All reactions