forked from redhat-best-practices-for-k8s/certsuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow more than one skip functions per check. (redhat-best-practices-…
…for-k8s#1645) The check.WithSkipFn(func) has been replaced by a variadic func version to allow more than one skip functions to be called: check.WithSkipFn(skipFunc1, skipFunc2...) By default, the check will be skipped if any skip function returns true when they're called (which happens before running the CheckFn). If we need to skip the check in case all the skip functions return true, the check.WithSkipModeAll() needs to be used. Examples: 1. Skip check if no deployments *or* no statefulsets were found (testhelper.SkipIfEmptyAny()): check := checksdb.NewCheck(id, labels). WithSkipCheckFn(testhelper.GetNoDeploymentsUnderTestSkipFn(&env), testhelper.GetNoStatefulSetsUnderTestSkipFn(&env)). WithCheckFn(func() error { .. }) 2. We want to skip the check if no deployments *and* no statefulsets were found (testhelper.SkipIfEmptyAll()): check := checksdb.NewCheck(id, labels). WithSkipCheckFn(testhelper.GetNoDeploymentsUnderTestSkipFn(&env), testhelper.GetNoStatefulSetsUnderTestSkipFn(&env)). WithSkipCheckModeAll(). WithCheckFn(func() error { .. }) The skip functions are appended to a slice in the same order as they're passed to the check.WithSkipCheckFn() calls, and it can be called more than once. E.g.: in the previous examples, this call: ... WithSkipCheckFn(testhelper.GetNoDeploymentsUnderTestSkipFn(&env), testhelper.GetNoStatefulSetsUnderTestSkipFn(&env)). ... is equal to: ... WithSkipCheckFn(testhelper.GetNoDeploymentsUnderTestSkipFn(&env)). WithSkipCheckFn(testhelper.GetNoStatefulSetsUnderTestSkipFn(&env)). ... Extra changes: - Added helper skip func creators in the testhelper package for no CRDs, no statefulSets and no deployments found. - Adapted the observability ts.
- Loading branch information
1 parent
fa001e4
commit 7e2063a
Showing
4 changed files
with
121 additions
and
43 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