checksdb

package
v0.0.0-...-0aa9544 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CheckResultPassed  = "passed"
	CheckResultSkipped = "skipped"
	CheckResultFailed  = "failed"
	CheckResultError   = "error"
	CheckResultAborted = "aborted"
)
View Source
const (
	SkipModeAny skipMode = iota
	SkipModeAll
)
View Source
const (
	PASSED  = 0
	FAILED  = 1
	SKIPPED = 2
)

Variables

This section is empty.

Functions

func FilterCheckIDs

func FilterCheckIDs() ([]string, error)

func GetReconciledResults

func GetReconciledResults() map[string]claim.Result

GetReconciledResults is a function added to aggregate a Claim's results. Due to the limitations of certsuite-claim's Go Client, results are generalized to map[string]interface{}.

func GetResults

func GetResults() map[string]claim.Result

func GetTestSuites

func GetTestSuites() []string

func GetTestsCountByState

func GetTestsCountByState(state string) int

func GetTotalTests

func GetTotalTests() int

func InitLabelsExprEvaluator

func InitLabelsExprEvaluator(labelsFilter string) error

func RunChecks

func RunChecks(timeout time.Duration) (failedCtr int, err error)

Types

type AbortPanicMsg

type AbortPanicMsg string

type Check

type Check struct {
	ID     string
	Labels []string

	BeforeCheckFn, AfterCheckFn func(check *Check) error
	CheckFn                     func(check *Check) error

	SkipCheckFns []func() (skip bool, reason string)
	SkipMode     skipMode

	Result         CheckResult
	CapturedOutput string

	StartTime, EndTime time.Time
	Timeout            time.Duration
	Error              error
	// contains filtered or unexported fields
}

func NewCheck

func NewCheck(id string, labels []string) *Check

func (*Check) Abort

func (check *Check) Abort(reason string)

func (*Check) GetLogger

func (check *Check) GetLogger() *log.Logger

func (*Check) GetLogs

func (check *Check) GetLogs() string

func (*Check) LogDebug

func (check *Check) LogDebug(msg string, args ...any)

func (*Check) LogError

func (check *Check) LogError(msg string, args ...any)

func (*Check) LogFatal

func (check *Check) LogFatal(msg string, args ...any)

func (*Check) LogInfo

func (check *Check) LogInfo(msg string, args ...any)

func (*Check) LogWarn

func (check *Check) LogWarn(msg string, args ...any)

func (*Check) Run

func (check *Check) Run() error

func (*Check) SetAbortChan

func (check *Check) SetAbortChan(abortChan chan string)

func (*Check) SetResult

func (check *Check) SetResult(compliantObjects, nonCompliantObjects []*testhelper.ReportObject)

func (*Check) SetResultAborted

func (check *Check) SetResultAborted(reason string)

func (*Check) SetResultError

func (check *Check) SetResultError(reason string)

func (*Check) SetResultSkipped

func (check *Check) SetResultSkipped(reason string)

func (*Check) WithAfterCheckFn

func (check *Check) WithAfterCheckFn(afterCheckFn func(check *Check) error) *Check

func (*Check) WithBeforeCheckFn

func (check *Check) WithBeforeCheckFn(beforeCheckFn func(check *Check) error) *Check

func (*Check) WithCheckFn

func (check *Check) WithCheckFn(checkFn func(check *Check) error) *Check

func (*Check) WithSkipCheckFn

func (check *Check) WithSkipCheckFn(skipCheckFn ...func() (skip bool, reason string)) *Check

func (*Check) WithSkipModeAll

func (check *Check) WithSkipModeAll() *Check

func (*Check) WithSkipModeAny

func (check *Check) WithSkipModeAny() *Check

This modifier is provided for the sake of completeness, but it's not necessary to use it, as the SkipModeAny is the default skip mode.

func (*Check) WithTimeout

func (check *Check) WithTimeout(duration time.Duration) *Check

type CheckResult

type CheckResult string

func (CheckResult) String

func (cr CheckResult) String() string

type ChecksGroup

type ChecksGroup struct {
	// contains filtered or unexported fields
}

func NewChecksGroup

func NewChecksGroup(groupName string) *ChecksGroup

func (*ChecksGroup) Add

func (group *ChecksGroup) Add(check *Check)

func (*ChecksGroup) OnAbort

func (group *ChecksGroup) OnAbort(abortReason string) error

func (*ChecksGroup) RecordChecksResults

func (group *ChecksGroup) RecordChecksResults()

func (*ChecksGroup) RunChecks

func (group *ChecksGroup) RunChecks(stopChan <-chan bool, abortChan chan string) (errs []error, failedChecks int)

Runs all the checks in the group whose labels match the label expression filter.

  1. Calls group.BeforeAll(). Then, for each Check in the group:
  2. Calls group.BeforeEach() -> normally used to get/refresh the test environment variable.
  3. Calls check.SkipCheckFn() -> if true, skip the check.Run() (step 4)
  4. Calls check.Run() -> Will call the actual CNF Cert requirement check function.
  5. Calls group.AfterEach()
  6. Calls group.AfterAll()

Issues/errors/panics:

  • BeforeAll panic/error: Set first check as error. Run AfterAll()
  • BeforeEach panic/error: Set check as error and skip remaining. Skip check.Run(), run AfterEach + AfterAll.
  • Check.Run() panic/error: Set check as panicked. Run AfterEach + AfterAll
  • AfterEach panic: Set check as error.

func (*ChecksGroup) WithAfterAllFn

func (group *ChecksGroup) WithAfterAllFn(afterAllFn func(checks []*Check) error) *ChecksGroup

func (*ChecksGroup) WithAfterEachFn

func (group *ChecksGroup) WithAfterEachFn(afterEachFn func(check *Check) error) *ChecksGroup

func (*ChecksGroup) WithBeforeAllFn

func (group *ChecksGroup) WithBeforeAllFn(beforeAllFn func(checks []*Check) error) *ChecksGroup

func (*ChecksGroup) WithBeforeEachFn

func (group *ChecksGroup) WithBeforeEachFn(beforeEachFn func(check *Check) error) *ChecksGroup

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL