-
Is your feature request related to a problem? Please describe. I'd like to use the cue Go API to load cue content from both literal content and paths, but the API seems unclear if it supports this. # foo.cue
{
name: config.name
} instances := load.Instances("foo.cue", config)
literal := `
config: {
name: "bar"
}
`
cuectx := cuecontext.New()
value1 := cuectx.CompileString(content)
value2, _ := cuectx.BuildInstances(instances)
// how to build literal and instances at the same time? or get the literal to be an "instance"?
// desired output
{
name: "bar"
} With literal CUE contents, it seems like about all the API let's us do is convert them directly to a Overall, the terms context, instance, build, compile, and load make it very unclear how to use the Go API. I've gathered that to "build" cue stuff together you need to have all the bits of config be available. Values are for "fully rendered" stuff, you can't take the string content value and the BuildInstances Value and merge them together. Is it possible to combine expressions that originate from string literals and files? Or am I required to write them out to files? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
tldr: I've got a bunch of CUE contents, some are in Go strings some are files on disk. How do I use this Go library? |
Beta Was this translation helpful? Give feedback.
Hi @dghubble - I've moved your issue to be a discussion in the Q&A category.
For an example of how to load CUE via the Go API please see https://cuelang.org/docs/tutorial/loading-cue-go-api/.
If you wanted to augment what is on disk with more data, you could use an
Overlay
as part of a https://pkg.go.dev/cuelang.org/go/cue/load#Config value that is passed toload.Instances
.Would that cover your use case?
Happy to create an example of this for cuelang.org if that would be of help.