rule

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStatusIcon

func GetStatusIcon(status Status) rune

GetStatusIcon returns the icon of a given Status string

Types

type CheckResult

type CheckResult struct {
	Status  Status
	Message string
	Target  Target
}

CheckResult contains information about a Rule check. Returned from Rule runs.

func AcceptedCheckResult

func AcceptedCheckResult(message string, target Target) CheckResult

AcceptedCheckResult returns a CheckResult with Accepted status and the given message and target

func ErroredCheckResult

func ErroredCheckResult(message string, target Target) CheckResult

ErroredCheckResult returns a CheckResult with Errored status and the given message and target

func FailedCheckResult

func FailedCheckResult(message string, target Target) CheckResult

FailedCheckResult returns a CheckResult with Failed status and the given message and target

func NotImplementedCheckResult

func NotImplementedCheckResult(message string, target Target) CheckResult

NotImplementedCheckResult returns a CheckResult with v status and the given message and target

func PassedCheckResult

func PassedCheckResult(message string, target Target) CheckResult

PassedCheckResult returns a CheckResult with Passed status and the given message and target

func SkippedCheckResult

func SkippedCheckResult(message string, target Target) CheckResult

SkippedCheckResult returns a CheckResult with Skipped status and the given message and target

func WarningCheckResult

func WarningCheckResult(message string, target Target) CheckResult

WarningCheckResult returns a CheckResult with Warning status and the given message and target

type Rule

type Rule interface {
	ID() string
	Name() string
	Run(ctx context.Context) (RuleResult, error)
}

Rule defines what is considered a rule in the context of Diki.

type RuleResult

type RuleResult struct {
	RuleID, RuleName string
	CheckResults     []CheckResult
}

RuleResult contains a Rule identification and the results of a Rule run.

func SingleCheckResult

func SingleCheckResult(r Rule, checkResult CheckResult) RuleResult

SingleCheckResult returns a RuleResult containing a single check.

type SkipRule

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

SkipRule is a Rule that always reports a predefined status.

func NewSkipRule

func NewSkipRule(id, name, justification string, status Status) *SkipRule

NewSkipRule returns a new skipped Rule.

func (*SkipRule) ID

func (s *SkipRule) ID() string

ID returns the id of the Rule.

func (*SkipRule) Name

func (s *SkipRule) Name() string

Name returns the name of the Rule.

func (*SkipRule) Run

Run immediately returns a RuleResult containing a single CheckResult with a predefined status and justification.

type Status

type Status string

Status of a CheckResult

const (
	// Passed status indicates that a check is satisfied.
	Passed Status = "Passed"
	// Skipped status indicates that a rule is skipped with explanation.
	Skipped Status = "Skipped"
	// Accepted status indicates that a check violation is accepted and justified
	// based on additional configuration.
	Accepted Status = "Accepted"
	// Warning status indicates that there is ambiguity and the check was not performed with confidence.
	Warning Status = "Warning"
	// Failed status indicates that a check reported a violation.
	Failed Status = "Failed"
	// Errored status indicates that an unexpected error occured during check execution.
	Errored Status = "Errored"
	// NotImplemented status indicates that a rule/check is not implemented.
	NotImplemented Status = "Not Implemented"
)

func Statuses

func Statuses() []Status

Statuses returns all supported statuses.

func (Status) Less

func (a Status) Less(b Status) bool

Less is used to define the priority of the statuses. The ascending order is as follows Passed, Skipped, Accepted, Warning, Failed, Errored, Not Implemented

type Target

type Target map[string]string

Target is used to describe the things that were checked during ruleset runs.

func NewTarget added in v0.3.0

func NewTarget(keyValuePairs ...string) Target

NewTarget creates a new Target with the given key values. Panics if the number of arguments is an odd number.

func (Target) With added in v0.3.0

func (t Target) With(keyValuePairs ...string) Target

With creates a new Target with additional key values. It does not modify the original one. Panics if the number of arguments is an odd number.

Jump to

Keyboard shortcuts

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