Skip to content

Commit

Permalink
thema: Disable schema emptiness invariants
Browse files Browse the repository at this point in the history
Attempting to migrate grafana/grafana to the new flattened lineage
format has revealed that there were a number of existing lineages that
contained no actual fields - only definitions. This violates the schema
non-emptiness invariant introduced during lineage flattening.

These lineages will be refactored, but to ease the transition, this
commit temporarily disables the schema non-emptiness invariant in thema
so that it can be handled gradually, rather than right away and up
front. This does not meaningfully degrade thema's guarantees, as we're
just returning to where it was pre-flattening.
  • Loading branch information
sam boyer committed May 8, 2023
1 parent b8c4356 commit 53a6fb0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions lineage.cue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ import (
//
// A lineage's joinSchema must never change as the lineage evolves.

joinSchema?: struct.MinFields(1)
// joinSchema?: struct.MinFields(1)
joinSchema: _

// schemas is the ordered list of all schemas in the lineage.
//
Expand Down Expand Up @@ -256,7 +257,7 @@ import (

_#schema: _join & schema

_schemaIsNonEmpty: struct.MinFields(1) & _#schema
// _schemaIsNonEmpty: struct.MinFields(1) & _#schema

// examples is an optional set of named examples of the schema, intended
// for use in documentation or other non-functional contexts.
Expand Down
1 change: 1 addition & 0 deletions lineage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func TestInvalidLineages(t *testing.T) {
ToDo: map[string]string{
"invalidlineage/defaultchange": "Thema compat analyzer fails to classify changes to default values as breaking",
"invalidlineage/joindef": "no invariant checker written to disallow definitions from joinSchema",
"invalidlineage/onlydef": "Lineage schema non-emptiness constraints are temporarily suspended while migrating grafana to flattened lineage structure",
},
}

Expand Down
8 changes: 4 additions & 4 deletions testdata/invalidlineage/empty-schemas.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ thema.#Lineage
name: "empty-schemas"
schemas: []
-- out/bindfail --
schemas: incompatible list lengths (0 and 1)
incompatible list lengths (0 and 1)
_sortedSchemas: invalid value [] (does not satisfy list.MinItems(1)): len(list) < MinItems(1) (0 < 1):
../../lineage.cue:97:7
../../lineage.cue:93:21
../../lineage.cue:97:21
../../lineage.cue:98:7
../../lineage.cue:94:21
../../lineage.cue:98:21
8 changes: 4 additions & 4 deletions testdata/invalidlineage/second-schema-versionless.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ lenses: [
]
-- out/bindfail --
_schemasAreOrdered.1: conflicting values true and false:
../../lineage.cue:124:3
../../lineage.cue:125:4
../../lineage.cue:130:5
../../lineage.cue:131:11
../../lineage.cue:125:3
../../lineage.cue:126:4
../../lineage.cue:131:5
../../lineage.cue:132:11
./in.cue:4:1

0 comments on commit 53a6fb0

Please sign in to comment.