Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Merging Schemas #872

Answered by mpvl
rawkode asked this question in Q&A
Apr 2, 2021 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Note entirely sure what your flow is, but could you not just call Constrain repeatedly for the same value?

In general CUE, not using cuego, one could use FillPath or Unify for this purpose:

// Filling multiple Go values:

var r cue.Runtime
inst, err := r.Compile("foo", "_")
// ... handle error
v := inst.Value()

root := cue.Path{}

// Merge in Go values
v = v.FillPath(root, value1)
v = v.FillPath(root, value2)

// Merge in CUE values
inst, err = r.Compile("", cueString1)
v = v.Unify(inst.Value()) // can also use FillPath(root, v).

if err := v.Err(); err != nil {
    // handle error
}

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@rawkode
Comment options

Answer selected by rawkode
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants