cue-lang / cue

The home of the CUE language! Validate and define text-based and dynamic configuration
https://cuelang.org
Apache License 2.0
5.1k stars 291 forks source link

encoding: emitting jsonpatch based on diff and default values #1968

Open bluebrown opened 2 years ago

bluebrown commented 2 years ago

Is your feature request related to a problem? Please describe.

Generating jsonpatch for things like Kubernetes admission webhooks is hard. In these situations, CUE could be used for mutating webhooks.

It could also be useful in any other place where the output from evaluation cannot be used directly but a jsonpatch is needed, which is the case with many http APIs.

So cue could be used to validate some data, potentially filling it with default values for a given schema and sending a jsonpatch to some upstream service to make the desired changes.

Describe the solution you'd like

The ability to generate jsonpatch based on diffs between two cue.Value's.

Describe alternatives you've considered

None.

Additional context

n/a

myitcv commented 2 years ago

I've updated the description to follow the format of the "Feature Request" template.