Skip to content

Commit

Permalink
feat: add IsNil to Any and AssertionTree (#526)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored Sep 27, 2024
1 parent 7bc2053 commit 790f57d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/apis/policy/v1alpha1/any.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func NewAny(value any) Any {
}
}

func (t *Any) IsNil() bool {
return t._value == nil
}

func (t *Any) Compile(path *field.Path, compilers compilers.Compilers) (projection.ScalarHandler, *field.Error) {
return projection.ParseScalar(path, t._value, compilers)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/policy/v1alpha1/assertion_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func NewAssertionTree(value any) AssertionTree {
}
}

func (t *AssertionTree) IsNil() bool {
return t._tree == nil
}

func (t *AssertionTree) Compile(path *field.Path, compilers compilers.Compilers) (assertion.Assertion, *field.Error) {
return assertion.Parse(path, t._tree, compilers)
}
Expand Down

0 comments on commit 790f57d

Please sign in to comment.