result

package
v0.7.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompositeResult

type CompositeResult struct {
	Message  string
	Reason   Reason
	Children []Result
}

CompositeResult is used for result hierarchy

func (*CompositeResult) GetReason

func (e *CompositeResult) GetReason() Reason

GetReason returns reason

func (*CompositeResult) String

func (e *CompositeResult) String() string

String makes result string for writing it to logs

func (*CompositeResult) StringWithIndent

func (e *CompositeResult) StringWithIndent(indent string) string

StringWithIndent makes result string where each line is prepended with specified indent

func (*CompositeResult) ToError

func (e *CompositeResult) ToError() error

ToError returns error if reason is not success

type Indent

type Indent string

Indent acts for indenting in result hierarchy

const (
	// SpaceIndent means 4 spaces
	SpaceIndent Indent = "    "
	// TabIndent is a tab symbol
	TabIndent Indent = "\t"
)

type Reason

type Reason int

Reason types of Result Reasons

const (
	//Success policy applied
	Success Reason = iota
	//Violation there is a violation of policy
	Violation
	//Failed the request to create/update the resource was blocked(generated from admission-controller)
	Failed
)

func (Reason) String

func (r Reason) String() string

type Result

type Result interface {
	String() string
	StringWithIndent(indent string) string
	GetReason() Reason
	ToError() error
}

Result is an interface that is used for result polymorphic behavior

func Append

func Append(target Result, source Result) Result

Append returns CompositeResult with target and source Or appends source to target if it is composite result If the source reason is more important than target reason, target takes the reason of the source.

func NewAdmissionResult

func NewAdmissionResult(requestUID string) Result

NewAdmissionResult creates a new admission result

func NewPolicyApplicationResult

func NewPolicyApplicationResult(policyName string) Result

NewPolicyApplicationResult creates a new policy application result

type RuleApplicationResult

type RuleApplicationResult struct {
	PolicyRule string
	Reason     Reason
	Messages   []string
}

RuleApplicationResult represents elementary result that is produced by PolicyEngine TODO: It can be used to create Kubernetes Results, so make method for this

func NewRuleApplicationResult

func NewRuleApplicationResult(ruleName string) RuleApplicationResult

NewRuleApplicationResult creates a new rule application result

func (*RuleApplicationResult) AddMessagef

func (e *RuleApplicationResult) AddMessagef(message string, a ...interface{})

AddMessagef Adds formatted message to this result

func (*RuleApplicationResult) FailWithMessagef

func (e *RuleApplicationResult) FailWithMessagef(message string, a ...interface{})

FailWithMessagef Sets the Reason Failed and adds formatted message to this result

func (*RuleApplicationResult) GetReason

func (e *RuleApplicationResult) GetReason() Reason

GetReason returns reason

func (*RuleApplicationResult) MergeWith

func (e *RuleApplicationResult) MergeWith(other *RuleApplicationResult)

MergeWith Takes messages and higher reason from another RuleApplicationResult

func (*RuleApplicationResult) String

func (e *RuleApplicationResult) String() string

String makes result string for writing it to logs

func (*RuleApplicationResult) StringWithIndent

func (e *RuleApplicationResult) StringWithIndent(indent string) string

StringWithIndent makes result string where each line is prepended with specified indent

func (*RuleApplicationResult) ToError

func (e *RuleApplicationResult) ToError() error

ToError returns the error if reason is not success

Jump to

Keyboard shortcuts

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