Replies: 7 comments 38 replies
-
Does the @embed proposal support embedding directories? The proposal does not seem to indicate so. I would expect that if the path resolved (by glob or specific) is a directory, all files are embedded recursively, probably with the |
Beta Was this translation helpful? Give feedback.
-
Can multiple
|
Beta Was this translation helpful? Give feedback.
-
When loading files from a path, e.g. Maybe by default only the basename should be used as the key? At least in all of my use cases, only the file name is relevant, never the full path. |
Beta Was this translation helpful? Give feedback.
-
NamingI feel the name used for this feature ("embedding") and the attribute name ( The parallel with Go's I think there will be cognitive dissonance between folks' understanding of what embedding already "means", coming from Go, and what's actually meant by CUE. And also for non-Go users, who I believe will expect some concept of fixed-ness when encountering the term "embedded". As a possible alternative, I think [FWIW, I don't feel this is pure bikeshedding; given that the feature's name will be baked in, on its first release, I think avoiding user confusion ahead of that release is important!] |
Beta Was this translation helpful? Give feedback.
-
Operator ControlCurrently, the The person who invokes a I feel that the relationship between author and operator should be maintained in its current state, and that this feature should be enabled via an explicit command line flag. I acknowledge that this would take the "just trying out the feature" process from 2 elements ( |
Beta Was this translation helpful? Give feedback.
-
When to use file embedding and when not to use file embedding?As a follow-up to the discussion in #3264 (comment), we should make clear when to use file embedding and when not. For example, when writing a There are perhaps similar/further FAQs which could be answered in the proposal, or as a follow-up documentation on https://cuelang.org/. |
Beta Was this translation helpful? Give feedback.
-
Other than slack I couldn't find documentation on how to enable the embed experiment from the Go API. For others looking for this: import (
"cuelang.org/go/cue/cuecontext"
"cuelang.org/go/cue/interpreter/embed"
)
os.Setenv("CUE_EXPERIMENT", "embed")
embedding := cuecontext.Interpreter(embed.New())
ctxOpts := []cuecontext.Option{embedding}
c := cuecontext.New(ctxOpts...) |
Beta Was this translation helpful? Give feedback.
-
We propose a solution for directly loading files of any type as part of CUE evaluation.
Abstract
Users frequently need to load JSON, YAML, or other types of files into their CUE code. As CUE only supports
import
declarations that reference CUE packages, users currently resort to the CUE tooling layer (cue cmd
) to load non-CUE files, which can be overly complex for their needs. The tooling layer was introduced to handle external influences that make a configuration non-hermetic, typically files.However, files that are part of a CUE module can be considered hermetic. We aim to make it easier to reference these files.
https://github.com/cue-lang/proposal/blob/main/designs/3264-embed.md
Experimental implementation
v0.10.0-alpha.1 includes an experimental implementation of this initial version of the proposal. It is hoped this will allow for rapid refinement of both the proposal and implementation, based on user feedback and real-world experience.
Enable the embed experiment by setting the
CUE_EXPERIMENT
environment variable:"Embedding data files in a CUE evaluation" shows a working example using the proposed
@embed()
attribute.Known issues
See the issue tracker: embed
Feedback and next steps
This section will be updated with feedback and next steps distilled from responses below
**
seemingly a good approach to supporting directories: Embed proposal #3264 (reply in thread)type=*auto|text
seemingly an acceptable UX for handling mixed (recursive) directory contents with a fallback: Embed proposal #3264 (reply in thread)@embed
attributes appearing on a field: cue/interpreter/embed: support embed attribute appearing multiple times for single field declaration? #3294@embed()
attribute, or instead "defer" to thepath
package: Embed proposal #3264 (comment)@embed
(vs@read
, etc): Embed proposal #3264 (comment)@embed
should behave with respect to symlinks: cue/interpreter/embed: embed should not follow symbolic links #3299 and all: to what extent should CUE support symlinks? #3300@embed
support should need explicit enabling (via a flag or similar) or not: Embed proposal #3264 (comment)Beta Was this translation helpful? Give feedback.
All reactions