-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from grafana/lineage/is-append-only-subsume
Lineage: First version of IsAppendOnly
- Loading branch information
Showing
21 changed files
with
658 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package cuetil | ||
|
||
import ( | ||
"cuelang.org/go/cue" | ||
) | ||
|
||
// Equal reports nil when the two cue values subsume each other or an error otherwise | ||
func Equal(val1 cue.Value, val2 cue.Value) error { | ||
if err := val1.Subsume(val2, cue.Raw()); err != nil { | ||
return err | ||
} | ||
|
||
if err := val2.Subsume(val1, cue.Raw()); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#firstLin: lin1 | ||
#secondLin: lin2 | ||
-- in.cue -- | ||
import "github.com/grafana/thema" | ||
|
||
lin1: thema.#Lineage | ||
lin1: name: "boundaries" | ||
lin1: schemas: [{ | ||
version: [0, 0] | ||
schema: { | ||
anInt: uint32 & >0 & <=24 | *12 | ||
} | ||
}] | ||
|
||
lin2: thema.#Lineage | ||
lin2: name: "boundaries" | ||
lin2: schemas: [{ | ||
version: [0, 0] | ||
schema: { | ||
anInt: uint32 & >0 & <=14 | *12 | ||
} | ||
}] | ||
-- out/isappendonly-fail -- | ||
field anInt not present in {anInt:*12 | >0 & <=24 & int}: | ||
../../../lineage.cue:247:10 | ||
./in.cue:7:10 | ||
missing field "anInt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#firstLin: lin1 | ||
#secondLin: lin2 | ||
-- in.cue -- | ||
import "github.com/grafana/thema" | ||
|
||
lin1: thema.#Lineage | ||
lin1: name: "defaultchange" | ||
lin1: schemas: [{ | ||
version: [0, 0] | ||
schema: { | ||
aunion: *"foo" | "bar" | "baz" | ||
} | ||
}] | ||
|
||
lin2: thema.#Lineage | ||
lin2: name: "defaultchange" | ||
lin2: schemas: [{ | ||
version: [0, 0] | ||
schema: { | ||
aunion: "foo" | *"bar" | "baz" | ||
} | ||
}] | ||
-- out/isappendonly-fail -- | ||
field aunion not present in {aunion:*"bar" | "foo" | "baz"}: | ||
../../../lineage.cue:247:10 | ||
./in.cue:16:13 | ||
missing field "aunion" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#firstLin: lin1 | ||
#secondLin: lin2 | ||
-- in.cue -- | ||
import "github.com/grafana/thema" | ||
|
||
lin1: thema.#Lineage | ||
lin1: name: "embedref" | ||
lin1: schemas: [{ | ||
version: [0, 0] | ||
schema: { | ||
#EmbedRef | ||
|
||
#EmbedRef: { | ||
refField1: string | ||
refField2: 42 | ||
} | ||
} | ||
}] | ||
|
||
lin2: thema.#Lineage | ||
lin2: name: "embedref" | ||
lin2: schemas: [{ | ||
version: [0, 0] | ||
schema: { | ||
#EmbedRef | ||
|
||
#EmbedRef: { | ||
refField1: string | ||
refField2: 1 | ||
} | ||
} | ||
}] | ||
-- out/isappendonly-fail -- | ||
field #EmbedRef not present in {#EmbedRef:{refField1:string,refField2:1},refField1:string,refField2:1}: | ||
../../../lineage.cue:247:10 | ||
./in.cue:21:13 | ||
field refField2 not present in {refField1:string,refField2:1}: | ||
./in.cue:24:20 | ||
missing field "#EmbedRef" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#firstLin: lin1 | ||
#secondLin: lin2 | ||
-- in.cue -- | ||
import "github.com/grafana/thema" | ||
|
||
lin1: thema.#Lineage | ||
lin1: name: "nested" | ||
lin1: schemas: [{ | ||
version: [0, 0] | ||
schema: { | ||
anObject: { | ||
aField: string | ||
} | ||
} | ||
}] | ||
|
||
lin2: thema.#Lineage | ||
lin2: name: "nested" | ||
lin2: schemas: [{ | ||
version: [0, 0] | ||
schema: { | ||
anObject: { | ||
aField: string | ||
aNewOptionalField?: string | ||
} | ||
} | ||
}] | ||
-- out/isappendonly-fail -- | ||
field anObject not present in {anObject:{aField:string}}: | ||
../../../lineage.cue:247:10 | ||
./in.cue:18:13 | ||
field not allowed in closed struct: aNewOptionalField | ||
missing field "anObject" |
Oops, something went wrong.