Skip to content

Commit

Permalink
Omit actuals from violation and encode rule config
Browse files Browse the repository at this point in the history
  • Loading branch information
jtigger committed Sep 6, 2022
1 parent a787f84 commit b3ed8cd
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/validations/filetests/all-rules-are-run.tpltest
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ ERR:
- "config" (stdin:4) requires "custom rule"; fail: fails (by stdin:3)
- "config" (stdin:4) requires "length greater or equal to 10"; fail: length of 2 is less than 10 (by stdin:3)
- "config" (stdin:4) requires "length less than or equal to 1"; fail: length of 2 is more than 1 (by stdin:3)
- "config" (stdin:4) requires "a value greater or equal to [2, 2]"; fail: yamlfragment(*yamlmeta.Array) is less than [2, 2] (by stdin:3)
- "config" (stdin:4) requires "a value less than or equal to [0, 0]"; fail: yamlfragment(*yamlmeta.Array) is more than [0, 0] (by stdin:3)
- "config" (stdin:4) requires "a value greater or equal to [2, 2]"; fail: value is less than [2, 2] (by stdin:3)
- "config" (stdin:4) requires "a value less than or equal to [0, 0]"; fail: value is more than [0, 0] (by stdin:3)
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ foo: 11
+++

ERR:
- "foo" (stdin:2) requires "a value less than or equal to 10"; fail: 11 is more than 10 (by stdin:1)
- "foo" (stdin:2) requires "a value less than or equal to 10"; fail: value is more than 10 (by stdin:1)
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ value: 9
+++

ERR:
- "value" (stdin:2) requires "a value greater or equal to 10"; fail: 9 is less than 10 (by stdin:1)
- "value" (stdin:2) requires "a value greater or equal to 10"; fail: value is less than 10 (by stdin:1)
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ foo: critical
+++

ERR:
- "foo" (stdin:2) requires "one of"; fail: critical not in ["debug", "info", "warning", "error", "fatal"] (by stdin:1)
- "foo" (stdin:2) requires "one of"; fail: value not in ["debug", "info", "warning", "error", "fatal"] (by stdin:1)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ max_of_int: #@ assert.max(2).check(3)
+++

ERR:
- fail: 3 is more than 2
- fail: value is more than 2
in lambda
assert.max:? | __ytt_tplXXX_set_ctx_type("yaml") (generated)
stdin:1 | #@ load("@ytt:assert", "assert")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ min_of_int: #@ assert.min(3).check(2)
+++

ERR:
- fail: 2 is less than 3
- fail: value is less than 3
in lambda
assert.min:? | __ytt_tplXXX_set_ctx_type("yaml") (generated)
stdin:1 | #@ load("@ytt:assert", "assert")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pass:
fail:
not_in_enum:
- null
- 'fail: not-in-set not in ["aws", "azure", "vsphere"]'
- 'fail: value not in ["aws", "azure", "vsphere"]'
enum_not_a_sequence:
int:
- null
Expand Down
6 changes: 3 additions & 3 deletions pkg/yttlibrary/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (m AssertModule) MinLen(thread *starlark.Thread, f *starlark.Builtin, args
func NewAssertMin(min starlark.Value) *Assertion {
return NewAssertionFromSource(
"assert.min",
`lambda val: True if yaml.decode(yaml.encode(val)) >= yaml.decode(yaml.encode(min)) else fail("{} is less than {}".format(val, min))`,
`lambda val: True if yaml.decode(yaml.encode(val)) >= yaml.decode(yaml.encode(min)) else fail("value is less than {}".format(yaml.decode(yaml.encode(min))))`,
starlark.StringDict{"min": min, "yaml": YAMLAPI["yaml"]},
)
}
Expand All @@ -252,7 +252,7 @@ func (m AssertModule) Min(thread *starlark.Thread, f *starlark.Builtin, args sta
func NewAssertMax(max starlark.Value) *Assertion {
return NewAssertionFromSource(
"assert.max",
`lambda val: True if yaml.decode(yaml.encode(val)) <= yaml.decode(yaml.encode(max)) else fail("{} is more than {}".format(val, max))`,
`lambda val: True if yaml.decode(yaml.encode(val)) <= yaml.decode(yaml.encode(max)) else fail("value is more than {}".format(yaml.decode(yaml.encode(max))))`,
starlark.StringDict{"max": max, "yaml": YAMLAPI["yaml"]},
)
}
Expand Down Expand Up @@ -389,7 +389,7 @@ func (m AssertModule) oneNotNullCheck(keys starlark.Sequence) core.StarlarkFunc
func NewAssertOneOf(enum starlark.Sequence) *Assertion {
return NewAssertionFromSource(
"assert.one_of",
`lambda val: True if yaml.decode(yaml.encode(val)) in yaml.decode(yaml.encode(enum)) else fail("{} not in {}".format(yaml.decode(yaml.encode(val)), yaml.decode(yaml.encode(enum))))`,
`lambda val: True if yaml.decode(yaml.encode(val)) in yaml.decode(yaml.encode(enum)) else fail("value not in {}".format(yaml.decode(yaml.encode(enum))))`,
starlark.StringDict{"enum": enum, "yaml": YAMLAPI["yaml"]},
)
}
Expand Down

0 comments on commit b3ed8cd

Please sign in to comment.