-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
117 additions
and
79 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
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 |
---|---|---|
@@ -1,22 +1,24 @@ | ||
package assert | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jmespath-community/go-jmespath/pkg/binding" | ||
"k8s.io/apimachinery/pkg/util/validation/field" | ||
) | ||
|
||
func Validate(assertion interface{}, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { | ||
return validate(nil, assertion, value, bindings) | ||
func Validate(ctx context.Context, assertion interface{}, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { | ||
return validate(ctx, nil, assertion, value, bindings) | ||
} | ||
|
||
func Assert(assertion Assertion, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { | ||
return assert(nil, assertion, value, bindings) | ||
func Assert(ctx context.Context, assertion Assertion, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { | ||
return assert(ctx, nil, assertion, value, bindings) | ||
} | ||
|
||
func validate(path *field.Path, assertion interface{}, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { | ||
return assert(path, Parse(assertion), value, bindings) | ||
func validate(ctx context.Context, path *field.Path, assertion interface{}, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { | ||
return assert(ctx, path, Parse(ctx, assertion), value, bindings) | ||
} | ||
|
||
func assert(path *field.Path, assertion Assertion, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { | ||
return assertion.assert(path, value, bindings) | ||
func assert(ctx context.Context, path *field.Path, assertion Assertion, value interface{}, bindings binding.Bindings) (field.ErrorList, error) { | ||
return assertion.assert(ctx, path, value, bindings) | ||
} |
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
package assert | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/jmespath-community/go-jmespath/pkg/binding" | ||
"k8s.io/apimachinery/pkg/util/validation/field" | ||
) | ||
|
||
type Assertion interface { | ||
assert(*field.Path, interface{}, binding.Bindings) (field.ErrorList, error) | ||
assert(context.Context, *field.Path, interface{}, binding.Bindings) (field.ErrorList, error) | ||
} |
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
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
Oops, something went wrong.