info

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PolicyInfo

type PolicyInfo struct {
	// Name is policy name
	Name string
	// RKind represents the resource kind
	RKind string
	// RName is resource name
	RName string
	// Namespace is the ns of resource
	// empty on non-namespaced resources
	RNamespace string
	//TODO: add check/enum for types
	ValidationFailureAction string // BlockChanges, ReportViolation
	Rules                   []RuleInfo
	// contains filtered or unexported fields
}

PolicyInfo defines policy information

func NewPolicyInfo

func NewPolicyInfo(policyName, rKind, rName, rNamespace, validationFailureAction string) PolicyInfo

NewPolicyInfo returns a new policy info

func (*PolicyInfo) AddRuleInfos

func (pi *PolicyInfo) AddRuleInfos(rules []RuleInfo)

AddRuleInfos sets the rule information

func (*PolicyInfo) ErrorRules

func (pi *PolicyInfo) ErrorRules() string

ErrorRules returns error msgs from all rule

func (*PolicyInfo) FailedRules added in v0.6.0

func (pi *PolicyInfo) FailedRules() []string

FailedRules returns list of failed rule names

func (*PolicyInfo) GetRuleNames added in v0.6.0

func (pi *PolicyInfo) GetRuleNames(onSuccess bool) string

GetRuleNames gets the name of successful rules

func (*PolicyInfo) IsSuccessful

func (pi *PolicyInfo) IsSuccessful() bool

IsSuccessful checks if policy is succesful the policy is set to fail, if any of the rules have failed

func (*PolicyInfo) SuccessfulRules added in v0.6.0

func (pi *PolicyInfo) SuccessfulRules() []string

SuccessfulRules returns list of successful rule names

type RuleInfo

type RuleInfo struct {
	Name     string
	RuleType RuleType
	Msgs     []string
	Patches  [][]byte // this will store the mutation patch being applied by the rule
	// contains filtered or unexported fields
}

RuleInfo defines rule struct

func NewRuleInfo

func NewRuleInfo(ruleName string, ruleType RuleType) RuleInfo

NewRuleInfo creates a new RuleInfo

func (*RuleInfo) Add

func (ri *RuleInfo) Add(msg string)

Add add msg

func (*RuleInfo) Addf

func (ri *RuleInfo) Addf(msg string, args ...interface{})

Addf add msg with args

func (*RuleInfo) Fail

func (ri *RuleInfo) Fail()

Fail set the rule as failed

func (*RuleInfo) GetErrorString added in v0.6.0

func (ri *RuleInfo) GetErrorString() string

GetErrorString returns the error message for a rule

func (*RuleInfo) IsSuccessful

func (ri *RuleInfo) IsSuccessful() bool

IsSuccessful checks if rule is succesful

func (*RuleInfo) ToString

func (ri *RuleInfo) ToString() string

ToString reule information TODO: check if this is needed

type RuleType

type RuleType int
const (
	Mutation RuleType = iota
	Validation
	Generation
	All
)

func (RuleType) String

func (ri RuleType) String() string

Jump to

Keyboard shortcuts

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