types

package
v0.2.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GVK

GVK returns the GroupVersionKind string of the given resource

func NamespacedName

func NamespacedName(obj unstructured.Unstructured) string

NamespacedName returns the namespaced name string of the given resource

Types

type Check

type Check struct {
	ID          string            `json:"id"`
	Match       Match             `json:"match"`
	Validations []Validation      `json:"validations"`
	Variables   []Variable        `json:"variables"`
	Params      map[string]any    `json:"params"`
	Severity    Severity          `json:"severity"`
	Message     string            `json:"message"`
	Labels      map[string]string `json:"labels,omitempty"`

	Builtin bool   `json:"builtin"`
	Path    string `json:"path,omitempty"`
}

type CheckResult

type CheckResult struct {
	ID       string            `json:"id"`
	Message  string            `json:"message"`
	Severity Severity          `json:"severity"`
	Builtin  bool              `json:"builtin"`
	Path     string            `json:"path"`
	Labels   map[string]string `json:"labels,omitempty"`

	Status  CheckStatus         `json:"status"`
	Failed  map[string][]string `json:"failed"`
	Passed  map[string][]string `json:"passed"`
	Skipped map[string][]string `json:"skipped"`
	Errors  []string            `json:"errors"`

	TotalFailed  int `json:"totalFailed"`
	TotalPassed  int `json:"totalPassed"`
	TotalSkipped int `json:"totalSkipped"`
}

func NewCheckResult

func NewCheckResult(check Check) *CheckResult

func (*CheckResult) AddError

func (r *CheckResult) AddError(err error)

func (*CheckResult) AddErrors

func (r *CheckResult) AddErrors(errs ...error)

func (*CheckResult) AddFailed

func (r *CheckResult) AddFailed(obj unstructured.Unstructured)

func (*CheckResult) AddPassed

func (r *CheckResult) AddPassed(obj unstructured.Unstructured)

func (*CheckResult) AddSkipped

func (r *CheckResult) AddSkipped(obj unstructured.Unstructured)

func (*CheckResult) UpdateStatus

func (r *CheckResult) UpdateStatus()

type CheckStatus

type CheckStatus int
const (
	StatusUnknown CheckStatus = iota
	StatusPassed
	StatusSkipped
	StatusFailed
	StatusError
)

func ParseStatus added in v0.1.6

func ParseStatus(s string) CheckStatus

func (CheckStatus) MarshalJSON

func (s CheckStatus) MarshalJSON() ([]byte, error)

func (CheckStatus) String

func (s CheckStatus) String() string

func (*CheckStatus) UnmarshalJSON added in v0.1.6

func (s *CheckStatus) UnmarshalJSON(b []byte) error

type Match

type Match struct {
	Resources []ResourceRule `json:"resources"`
}

type Report

type Report struct {
	KubeVersion *version.Info     `json:"kubeVersion"`
	Checks      []*CheckResult    `json:"checks"`
	GVRs        map[string]string `json:"gvrs,omitempty"`
}

func NewReport

func NewReport(kubeVersion *version.Info) *Report

func (*Report) Add

func (r *Report) Add(cr *CheckResult)

func (*Report) HasError added in v0.1.3

func (r *Report) HasError() bool

type ResourceRule

type ResourceRule struct {
	Group    string `json:"group,omitempty"`
	Version  string `json:"version"`
	Resource string `json:"resource"`
}

func (*ResourceRule) ToGVR

type Severity

type Severity int
const (
	SeverityUnknown Severity = iota
	SeverityLow
	SeverityMedium
	SeverityHigh
	SeverityCritical
)

func ParseSeverity

func ParseSeverity(s string) Severity

func (Severity) MarshalJSON

func (s Severity) MarshalJSON() ([]byte, error)

func (Severity) String

func (s Severity) String() string

func (*Severity) UnmarshalJSON

func (s *Severity) UnmarshalJSON(b []byte) error

type Test

type Test struct {
	Name        string        `json:"name"`
	Input       string        `json:"input"`
	Params      any           `json:"params"`
	APIVersions []string      `json:"apiVersions"`
	KubeVersion *version.Info `json:"kubeVersion"`
	Pass        bool          `json:"pass"`
	Message     string        `json:"message"`
}

type Validation

type Validation struct {
	Expression string `json:"expression"`
	Message    string `json:"message,omitempty"`
}

type Variable added in v0.2.2

type Variable struct {
	Name       string `json:"name"`
	Expression string `json:"expression"`
}

Jump to

Keyboard shortcuts

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