Comments (8)
Any updates on this feature?
from cue.
It would be good for people to give examples of how they would like to use this functionality in a CLI.
There is an internal package for diffing CUE, which could potentially also be exposed as a Go API.
from cue.
Commenting simply to add the word semantic into the mix 😄
I've taken (perhaps incorrectly) to referring to cue diff
as a semantic diff, distinct from cmp
and friends ("plain diff") used in unity
.
from cue.
Would be nice to have a diff API in cue lib. Currently I'm using Value.Decode
and https://github.com/r3labs/diff to diff two cue instances in order to detect which part of the configuration has changed (based on this CI jobs are run).
However this works if the instances have only concrete values. So a similar API that can diff cue values directly would be nice (and required in my case to be able to use the flow API)
from cue.
@eonpatapon take a look at https://pkg.go.dev/cuelang.org/[email protected]/internal/diff. That is internal for now, but as we shape up the API it should be made non-internal.
from cue.
A semantic diff would be really interesting. I think with diffing kubernetes files, the most awkward part is the way that the kubernetes API wants to be given a list of yaml objects but the identity of those objects is usually best defined by their name rather than their position in a list. My current idea for diffing them is to write them out into a directory tree where the name of the file is based on the name and type of the object and then using git diff. Then as long as the yaml and all of its fields and lists of named objects are sorted in some stable way, this is good enough for most kubernetes things.
from cue.
Adding something of an experience report here from the world of unity
.
unity
tests (of cmd/cue
) generally follow this rough pattern:
- Ensure that evaluation of a given configuration semantically matches expectations. This is, in effect, a CUE semantic diff
- Verify that output in a specific format (JSON, Yaml, etc) matches expectations. This is, in effect, a semantic diff in the output format
In the case of point one this will look like:
# CUE semantic diff
cue eval -o out.cue X
cue diff out.cue ref.cue
# JSON diff
cue eval -o out.json X
cue diff out.json ref.json
Some questions:
- Is
cue eval
the right command here?cue eval
will becomecue
- but does that give the intended result, as far as concreteness etc are concerned? file.ref
will need to be a complete, self-contained configuration. This might well require it to be a txtar archive?
Stepping back a bit further, we should also be able to write a semantic diff for point 2, on the basis that CUE knows about the semantics of these different formats (even to some extent the different versions of, say, Yaml, JSON).
from cue.
This issue has been migrated to cue-lang/cue#8.
For more details about CUE's migration to a new home, please see cue-lang/cue#1078.
from cue.
Related Issues (20)
- cmd/cue: import/export (go|rust|...) HOT 3
- cmd/cue: import should ignore null documents HOT 4
- cmd/cue: fmt converts tabs to spaces in comments HOT 2
- cue eval panic instead of erroing with circular definition HOT 2
- Intermittent #FileInfo errors when parsing cue HOT 3
- cue vet hangs with template, list and default value HOT 1
- cmd/cue: simplify ["k"]: v to "k": v HOT 1
- Exporting binary & text protos via protoreflect HOT 1
- cuelang.org: document cue export for all conversions HOT 1
- panic in `cue get go github.com/argoproj/argo-cd/v2/...` HOT 2
- import cycle causes infinite loop HOT 2
- [regression] cue def openapi fails to handle disjunctions HOT 2
- cue segfault HOT 2
- exec.Run runner of kind "XXX" not found with k8s resources HOT 1
- cue trim bug: conjunctions and definitions HOT 1
- Parse error on default constraints (...type) HOT 5
- Tags across packages HOT 3
- YAML exports with strings in certain formats are interpreted as datetimes HOT 9
- `command "dump" is not defined` when running `cue dump ./...` HOT 2
- CUE has moved to a new home! HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cue.