Documentation ¶
Overview ¶
Package types implements common types used in the implementaton of the constraint policcy.
Index ¶
Constants ¶
const ( ComplianceNone = ComplianceLevel("") CompliancePending = "Pending" ComplianceCompliant = "Compliant" ComplianceLimit = "Limit" ComplianceViolation = "Violation" ComplianceError = "Error" )
String constants for the policy compliance.
const ( IndexCluster = 3 IndexNamespace = 4 IndexAPIVersion = 5 IndexKind = 6 IndexName = 7 )
Indexes into the regexp results to get the various parts.
Variables ¶
var ErrConvertReference = errors.New("convert-unstructured-to-reference")
ErrConvertReference return when an unstructured object does not have complete information to be converted to a Reference instance.
var ErrParseReference = errors.New("parse-reference")
ErrParseReference returned when a given string cannot be parsed as a Reference.
Functions ¶
func CompareComplianceSeverity ¶
CompareComplianceSeverity compares two compliance level and return an integer value where if the returned value is < 0 then the first parameter has a higher severity level, > 0 then the second parameter has a higher severity level, or 0 if the the values are equal.
Types ¶
type ComplianceLevel ¶
type ComplianceLevel string
ComplianceLevel constrained string type for value checking.
func (ComplianceLevel) String ¶
func (cl ComplianceLevel) String() string
String returns the string representation of the compliance level.
type Reference ¶
type Reference struct { // Cluster represents the resolved reference to a cluster ID Cluster string `json:"cluster"` // APIVersion represents the resolved APIVersion of the reference //+kubernetes:validate:Required //+kubebuilder:validation:Pattern:=`^[a-zA-Z_][a-zA-Z0-9_-]*$` APIVersion string `json:"apiVersion"` // Kind represents the resolved Kind of the reference //+kubernetes:validate:Required //+kubebuilder:validation:Pattern:=`^[a-zA-Z_][a-zA-Z0-9_-]*$` Kind string `json:"kind"` // Namespace represents the resolved Namespace of the reference //+kubernetes:validate:Required //+kubebuilder:validation:Pattern:=`^[a-zA-Z_][a-zA-Z0-9_-]*$` Namespace string `json:"namespace"` // Name represents the resolved Name of the reference //+kubernetes:validate:Required //+kubebuilder:validation:Pattern:=`^[a-zA-Z_][a-zA-Z0-9_-]*$` Name string `json:"name"` }
Reference defines a cluster specific reference to a resource.
func NewReferenceFromUnstructured ¶
func NewReferenceFromUnstructured(in uv1.Unstructured) *Reference
NewReferenceFromUnstructured creates and returns a new Reference instance from the given unstructured resource information.
func ParseReference ¶
ParseReference attempts to parse the given string as a Reference and returns the value or an error if it cannot be parsed as a Reference.
type ReferenceList ¶
type ReferenceList []*Reference
ReferenceList defines a slice of References.
func (ReferenceList) AsBindingName ¶
func (r ReferenceList) AsBindingName(offerName string) string
AsBindingName creates a name that can be used for a policy binding based on the given offer compined with the Reference instances in the list.
func (ReferenceList) Contains ¶
func (r ReferenceList) Contains(ref *Reference) bool
Contains returns true if the given reference is in the ReferenceList else false.
type ReferenceListMap ¶
type ReferenceListMap map[string]ReferenceList
ReferenceListMap defines a map from a string (target name) to a ReferenceList.
func (ReferenceListMap) Permutations ¶
func (m ReferenceListMap) Permutations() ([]string, []ReferenceList)
Permutations generates all the permutations of the ReferenceListMap where the map key name represents a set. The generated permutations contain an entry from each set and are added to permutation in alphabetical order base on the map key that represents that set.