Documentation ¶
Index ¶
Constants ¶
const ( Fail Status = "fail" Warn Status = "warn" Error Status = "error" Pass Status = "pass" Skip Status = "skip" Low Severity = "low" Medium Severity = "medium" High Severity = "high" )
Enums for predefined values from the PolicyReport spec
const ( DefaultPriority = iota DebugPriority InfoPriority WarningPriority CriticalPriority ErrorPriority )
Internal Priority definitions and weighting
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PolicyReport ¶
type PolicyReport struct { Name string Namespace string Results map[string]Result Summary Summary CreationTimestamp time.Time }
PolicyReport from the PolicyReport spec wgpolicyk8s.io/v1alpha1.PolicyReport
func (PolicyReport) GetIdentifier ¶
func (pr PolicyReport) GetIdentifier() string
GetIdentifier returns a global unique PolicyReport identifier
func (PolicyReport) GetNewResults ¶
func (pr PolicyReport) GetNewResults(or PolicyReport) []Result
GetNewResults filters already existing Results from the old PolicyReport and returns only the diff with new Results
func (PolicyReport) GetType ¶
func (pr PolicyReport) GetType() Type
GetType returns the Type of the Report
func (PolicyReport) HasResult ¶
func (pr PolicyReport) HasResult(id string) bool
HasResult returns if the Report has an Rusult with the given ID
func (PolicyReport) ResultHash ¶
func (pr PolicyReport) ResultHash() string
ResultHash generates a has of the current result set
type PolicyReportCallback ¶
type PolicyReportCallback = func(watch.EventType, PolicyReport, PolicyReport)
PolicyReportCallback is called whenever a new PolicyReport comes in
type PolicyReportStore ¶
type PolicyReportStore struct {
// contains filtered or unexported fields
}
PolicyReportStore caches the latest version of an PolicyReport
func NewPolicyReportStore ¶
func NewPolicyReportStore() *PolicyReportStore
NewPolicyReportStore construct a PolicyReportStore
func (*PolicyReportStore) Add ¶
func (s *PolicyReportStore) Add(r PolicyReport)
Add a PolicyReport to the Store
func (*PolicyReportStore) Get ¶
func (s *PolicyReportStore) Get(rType Type, id string) (PolicyReport, bool)
Get an PolicyReport by Type and ID
func (*PolicyReportStore) List ¶
func (s *PolicyReportStore) List(rType Type) []PolicyReport
List all PolicyReports of the given Type
func (*PolicyReportStore) Remove ¶
func (s *PolicyReportStore) Remove(rType Type, id string)
Remove a PolicyReport with the given Type and ID from the Store
type PolicyResultCallback ¶
PolicyResultCallback is called whenever a new PolicyResult comes in
type PolicyResultClient ¶
type PolicyResultClient interface { // RegisterCallback register Handlers called on each PolicyReport watch.Event RegisterCallback(PolicyReportCallback) // RegisterPolicyResultCallback register Handlers called on each PolicyReport watch.Event for each changed PolicyResult RegisterPolicyResultCallback(PolicyResultCallback) // RegisterPolicyResultWatcher register a handler for ClusterPolicyReports and PolicyReports who call the registered PolicyResultCallbacks RegisterPolicyResultWatcher(skipExisting bool) // StartWatching calls the WatchAPI, waiting for incoming PolicyReport watch.Events and call the registered Handlers StartWatching(ctx context.Context) error // GetFoundResources as Map of Names GetFoundResources() map[string]string }
PolicyResultClient watches for PolicyReport Events and executes registered callback
type Priority ¶
type Priority int
Priority Enum for internal Result weighting
func NewPriority ¶
NewPriority creates a new Priority based an its string representation
func PriorityFromSeverity ¶
PriorityFromSeverity creates a Priority based on a Severity
func PriorityFromStatus ¶
PriorityFromStatus creates a Priority based on a Status
func (Priority) MarshalJSON ¶
MarshalJSON marshals the enum as a quoted json string
type Result ¶
type Result struct { Message string Policy string Rule string Priority Priority Status Status Severity Severity `json:",omitempty"` Category string `json:",omitempty"` Source string `json:"source,omitempty"` Scored bool Timestamp time.Time Resource Resource Properties map[string]string }
Result from the PolicyReport spec wgpolicyk8s.io/v1alpha1.PolicyReportResult
func (Result) GetIdentifier ¶
GetIdentifier returns a global unique Result identifier
func (Result) HasResource ¶
HasResource checks if the result has an valid Resource