v1alpha1

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Overview

Package v1alpha1 contains API Schema definitions for the policy v1alpha1 API group +kubebuilder:object:generate=true +groupName=policy.kcloudlabs.io

Index

Constants

View Source
const (
	// AffectModeReject means reject the operation when policy hit by resource.
	AffectModeReject = "reject"
	// AffectModeAllow means only allow the operation when policy hit by resource.
	AffectModeAllow = "allow"
)
View Source
const (
	// OperationTypeAdd represents add(+) operate
	OperationTypeAdd = "+"
	// OperationTypeSub represents sub(-) operate
	OperationTypeSub = "-"
	// OperationTypeMultiply represents multiply(*) operate
	OperationTypeMultiply = "*"
	// OperationTypeDivide represents divide(/) operate
	OperationTypeDivide = "/"
)
View Source
const (
	// ValidateRuleTypeCondition - general rule type
	ValidateRuleTypeCondition = "condition"
)

Variables

View Source
var (
	// GroupVersion is group version used to register these objects
	SchemeGroupVersion = schema.GroupVersion{Group: "policy.kcloudlabs.io", Version: "v1alpha1"}

	// SchemeBuilder is used to add go types to the GroupVersionKind scheme
	SchemeBuilder = &scheme.Builder{GroupVersion: SchemeGroupVersion}

	// AddToScheme adds the types in this group-version to the given scheme.
	AddToScheme = SchemeBuilder.AddToScheme
)

Functions

func Resource

func Resource(name string) schema.GroupResource

Types

type AffectMode added in v0.4.0

type AffectMode string

AffectMode is defining match affect +kubebuilder:validation:Enum=reject;allow

type ClusterOverridePolicy

type ClusterOverridePolicy struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// Spec represents the desired behavior of ClusterOverridePolicy.
	Spec OverridePolicySpec `json:"spec"`
}

ClusterOverridePolicy represents the cluster-wide policy that overrides a group of resources.

func (*ClusterOverridePolicy) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOverridePolicy.

func (*ClusterOverridePolicy) DeepCopyInto

func (in *ClusterOverridePolicy) DeepCopyInto(out *ClusterOverridePolicy)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ClusterOverridePolicy) DeepCopyObject

func (in *ClusterOverridePolicy) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*ClusterOverridePolicy) GetName

func (p *ClusterOverridePolicy) GetName() string

GetName returns the name of ClusterOverridePolicy

func (*ClusterOverridePolicy) GetNamespace

func (p *ClusterOverridePolicy) GetNamespace() string

GetNamespace returns the namespace of ClusterOverridePolicy

func (*ClusterOverridePolicy) GetOverridePolicySpec

func (p *ClusterOverridePolicy) GetOverridePolicySpec() OverridePolicySpec

GetOverridePolicySpec returns the OverrideSpec of ClusterOverridePolicy

type ClusterOverridePolicyList

type ClusterOverridePolicyList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ClusterOverridePolicy `json:"items"`
}

ClusterOverridePolicyList contains a list of ClusterOverridePolicy

func (*ClusterOverridePolicyList) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterOverridePolicyList.

func (*ClusterOverridePolicyList) DeepCopyInto

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ClusterOverridePolicyList) DeepCopyObject

func (in *ClusterOverridePolicyList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type ClusterValidatePolicy added in v0.2.0

type ClusterValidatePolicy struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec ClusterValidatePolicySpec `json:"spec,omitempty"`
}

ClusterValidatePolicy represents the cluster-wide policy that validate a group of resources.

func (*ClusterValidatePolicy) DeepCopy added in v0.2.0

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterValidatePolicy.

func (*ClusterValidatePolicy) DeepCopyInto added in v0.2.0

func (in *ClusterValidatePolicy) DeepCopyInto(out *ClusterValidatePolicy)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ClusterValidatePolicy) DeepCopyObject added in v0.2.0

func (in *ClusterValidatePolicy) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type ClusterValidatePolicyList added in v0.2.0

type ClusterValidatePolicyList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ClusterValidatePolicy `json:"items"`
}

ClusterValidatePolicyList contains a list of ClusterValidatePolicy

func (*ClusterValidatePolicyList) DeepCopy added in v0.2.0

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterValidatePolicyList.

func (*ClusterValidatePolicyList) DeepCopyInto added in v0.2.0

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ClusterValidatePolicyList) DeepCopyObject added in v0.2.0

func (in *ClusterValidatePolicyList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type ClusterValidatePolicySpec added in v0.2.0

type ClusterValidatePolicySpec struct {
	// ResourceSelectors restricts resource types that this validate policy applies to.
	// nil means matching all resources.
	// +optional
	ResourceSelectors []ResourceSelector `json:"resourceSelectors,omitempty"`

	// ValidateRules defines a collection of validate rules on target operations.
	// +required
	ValidateRules []ValidateRuleWithOperation `json:"validateRules"`
}

ClusterValidatePolicySpec defines the desired behavior of ClusterValidatePolicy.

func (*ClusterValidatePolicySpec) DeepCopy added in v0.2.0

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterValidatePolicySpec.

func (*ClusterValidatePolicySpec) DeepCopyInto added in v0.2.0

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Cond added in v0.4.0

type Cond string

Cond is validation condition for validator +kubebuilder:validation:Enum=Equal;NotEqual;Exist;NotExist;In;NotIn;Gt;Gte;Lt;Lte

const (
	// CondEqual - `Equal`
	CondEqual Cond = "Equal"
	// CondNotEqual - `NotEqual`
	CondNotEqual Cond = "NotEqual"
	// CondExist - `Exist`
	CondExist Cond = "Exist"
	// CondNotExist - `NotExist`
	CondNotExist Cond = "NotExist"
	// CondIn - `In`
	CondIn Cond = "In"
	// CondNotIn - `NotIn`
	CondNotIn Cond = "NotIn"
	// CondGreater - `Gt`
	CondGreater Cond = "Gt"
	// CondGreaterOrEqual - `Gte`
	CondGreaterOrEqual Cond = "Gte"
	// CondLesser - `Lt`
	CondLesser Cond = "Lt"
	// CondLesserOrEqual - `Lte`
	CondLesserOrEqual Cond = "Lte"
	// CondRegex match regex. e.g. `/^\d{1,}$/`
	CondRegex Cond = "Regex"
)

type ConstantValue added in v0.4.0

type ConstantValue struct {
	// String as a string
	// +optional
	String *string `json:"string,omitempty"`
	// Integer as an integer(int64)
	// +optional
	Integer *int64 `json:"integer,omitempty"`
	// Float as float but use string to store, so please provide in comma (e.g. float: "1.2")
	// +optional
	Float *Float64 `json:"float,omitempty"`
	// Boolean only true or false can be recognized.
	// +optional
	Boolean *bool `json:"boolean,omitempty"`
	// StringSlice as a slice of string(e.g. ["a","b"])
	// +optional
	StringSlice []string `json:"stringSlice,omitempty"`
	// IntegerSlice as a slice of integer(int64) (e.g. [1,2,3])
	// +optional
	IntegerSlice []int64 `json:"integerSlice,omitempty"`
	// FloatSlice as a slice of float but using string (e.g. ["1.2", "2.3"])
	// +optional
	FloatSlice []Float64 `json:"floatSlice,omitempty"`
	// StringMap as key-value set and both are string.
	// +optional
	StringMap map[string]string `json:"stringMap,omitempty"`
}

ConstantValue defines exact types. Only one of field can be set.

func (*ConstantValue) DeepCopy added in v0.4.0

func (in *ConstantValue) DeepCopy() *ConstantValue

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConstantValue.

func (*ConstantValue) DeepCopyInto added in v0.4.0

func (in *ConstantValue) DeepCopyInto(out *ConstantValue)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ConstantValue) GetSlice added in v0.4.0

func (t *ConstantValue) GetSlice() []any

func (*ConstantValue) Value added in v0.4.0

func (t *ConstantValue) Value() any

Value return first non-nil value, it returns nil if all fields are empty.

type FieldSelector added in v0.4.3

type FieldSelector struct {
	// matchFields is a map of {key,value} pairs. A single {key,value} in the matchFields
	// map is equivalent to an element of matchExpressions, whose key field is "key", the
	// operator is "In", and the values array contains only "value".
	// +optional
	MatchFields map[string]string `json:"matchFields,omitempty"`
	// matchExpressions is a list of fields selector requirements. The requirements are ANDed.
	// +optional
	MatchExpressions []*FieldSelectorRequirement `json:"matchExpressions,omitempty"`
}

func (*FieldSelector) DeepCopy added in v0.4.3

func (in *FieldSelector) DeepCopy() *FieldSelector

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FieldSelector.

func (*FieldSelector) DeepCopyInto added in v0.4.3

func (in *FieldSelector) DeepCopyInto(out *FieldSelector)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*FieldSelector) MatchObject added in v0.4.3

func (f *FieldSelector) MatchObject(obj *unstructured.Unstructured) (bool, error)

type FieldSelectorRequirement added in v0.4.3

type FieldSelectorRequirement struct {
	// Field is the field key that the selector applies to.
	// Must provide whole path of key, such as `metadata.annotations.uid`
	Field string `json:"field"`
	// operator represents a key's relationship to a set of values.
	// Valid operators are In, NotIn, Exists and DoesNotExist.
	Operator metav1.LabelSelectorOperator `json:"operator"`
	// values is an array of string values. If the operator is In or NotIn,
	// the values array must be non-empty. If the operator is Exists or DoesNotExist,
	// the values array must be empty.
	// +optional
	Value []string `json:"value,omitempty"`
}

func (*FieldSelectorRequirement) DeepCopy added in v0.4.3

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FieldSelectorRequirement.

func (*FieldSelectorRequirement) DeepCopyInto added in v0.4.3

func (in *FieldSelectorRequirement) DeepCopyInto(out *FieldSelectorRequirement)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*FieldSelectorRequirement) MatchObject added in v0.4.3

type Float64 added in v0.4.0

type Float64 string

Float64 is alias for float64 as string

func (Float64) ToFloat64 added in v0.4.0

func (f Float64) ToFloat64() *float64

ToFloat64 converts string to pointer to float64 and return nil if convert got error

func (Float64) ValidFactor added in v0.4.0

func (f Float64) ValidFactor() bool

type HttpDataRef added in v0.4.0

type HttpDataRef struct {
	// URL as whole http url
	// +required
	URL string `json:"url,omitempty"`
	// Method as basic http method(e.g. GET or POST)
	// +required
	// +kubebuilder:validation:Enum=GET;POST
	Method string `json:"method,omitempty"`
	// Header represents the custom header added to http request header.
	// +optional
	Header map[string]string `json:"header,omitempty"`
	// Params represents the query value for http request.
	// +optional
	Params map[string]string `json:"params,omitempty"`
	// Body represents the json body when http method is POST.
	// +optional
	Body apiextensionsv1.JSON `json:"body,omitempty"`
	// Auth defines basic info for get authorization token before do request.
	// Note: it will request authURL with post and `Header.Set("Authorization", "Basic "+basicAuth(username, password))`
	//  and get token from response body. Response Body must be a valid json and contains token like this: `{"token": "xxx"} .
	//	After get the token, the request will add a new key value to header, key is "Authorization" and value is "Bearer xxx".
	Auth *HttpRequestAuth `json:"auth,omitempty"`
}

HttpDataRef defines a http request essential params

func (*HttpDataRef) DeepCopy added in v0.4.0

func (in *HttpDataRef) DeepCopy() *HttpDataRef

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HttpDataRef.

func (*HttpDataRef) DeepCopyInto added in v0.4.0

func (in *HttpDataRef) DeepCopyInto(out *HttpDataRef)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type HttpRequestAuth added in v0.4.0

type HttpRequestAuth struct {
	// StaticToken represents for static token for call api instead of get token from remote api.
	// StaticToken and other fields are mutually exclusive, staticToken is priority to take effect.
	// +optional
	StaticToken string `json:"staticToken,omitempty"`
	// Username represents username for auth.
	// +optional
	Username string `json:"username,omitempty"`
	// Password represents Password for auth.
	// +optional
	Password string `json:"password,omitempty"`
	// AuthURL represents remote url to request and get token.
	// +optional
	AuthURL string `json:"authUrl,omitempty"`
	// ExpireDuration is providing for some auth api won't return exact expire time, so can you this field set
	//  an expiry duration for token
	// +optional
	ExpireDuration metav1.Duration `json:"expireDuration,omitempty"`
	// Token stores the latest token get from AuthURL, and it'll be updated when token expired.
	// This filed is not fill by user, so don't edit it.
	// +optional
	Token string `json:"token,omitempty"`
	// ExpireAt sores the token expire time. Same as above field, this field also updated automatically.
	// This filed is not fill by user, so don't edit it.
	// +optional
	ExpireAt metav1.Time `json:"expireAt,omitempty"`
}

HttpRequestAuth defines basic info for get auth token from remote api

func (*HttpRequestAuth) DeepCopy added in v0.4.0

func (in *HttpRequestAuth) DeepCopy() *HttpRequestAuth

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HttpRequestAuth.

func (*HttpRequestAuth) DeepCopyInto added in v0.4.0

func (in *HttpRequestAuth) DeepCopyInto(out *HttpRequestAuth)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type OperationType added in v0.4.0

type OperationType string

OperationType defines the type of processing value.

type OverridePolicy

type OverridePolicy struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec OverridePolicySpec `json:"spec,omitempty"`
}

OverridePolicy represents the policy that overrides a group of resources.

func (*OverridePolicy) DeepCopy

func (in *OverridePolicy) DeepCopy() *OverridePolicy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverridePolicy.

func (*OverridePolicy) DeepCopyInto

func (in *OverridePolicy) DeepCopyInto(out *OverridePolicy)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*OverridePolicy) DeepCopyObject

func (in *OverridePolicy) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*OverridePolicy) GetName

func (p *OverridePolicy) GetName() string

GetName returns the name of OverridePolicy

func (*OverridePolicy) GetNamespace

func (p *OverridePolicy) GetNamespace() string

GetNamespace returns the namespace of OverridePolicy

func (*OverridePolicy) GetOverridePolicySpec

func (p *OverridePolicy) GetOverridePolicySpec() OverridePolicySpec

GetOverridePolicySpec returns the OverrideSpec of OverridePolicy

type OverridePolicyList

type OverridePolicyList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []OverridePolicy `json:"items"`
}

OverridePolicyList contains a list of OverridePolicy

func (*OverridePolicyList) DeepCopy

func (in *OverridePolicyList) DeepCopy() *OverridePolicyList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverridePolicyList.

func (*OverridePolicyList) DeepCopyInto

func (in *OverridePolicyList) DeepCopyInto(out *OverridePolicyList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*OverridePolicyList) DeepCopyObject

func (in *OverridePolicyList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type OverridePolicySpec

type OverridePolicySpec struct {
	// ResourceSelectors restricts resource types that this override policy applies to.
	// nil means matching all resources.
	// +optional
	ResourceSelectors []ResourceSelector `json:"resourceSelectors,omitempty"`

	// OverrideRules defines a collection of override rules on target operations.
	// +required
	OverrideRules []RuleWithOperation `json:"overrideRules"`
}

OverridePolicySpec defines the desired behavior of OverridePolicy.

func (*OverridePolicySpec) DeepCopy

func (in *OverridePolicySpec) DeepCopy() *OverridePolicySpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverridePolicySpec.

func (*OverridePolicySpec) DeepCopyInto

func (in *OverridePolicySpec) DeepCopyInto(out *OverridePolicySpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type OverrideRuleTemplate added in v0.4.0

type OverrideRuleTemplate struct {
	// Type represents current rule operate field type.
	// +kubebuilder:validation:Enum=annotations;labels;resources;resourcesOversell;tolerations;affinity
	// +required
	Type OverrideRuleType `json:"type,omitempty"`
	// Operation represents current operation type.
	// +kubebuilder:validation:Enum=add;replace;remove
	// +required
	Operation OverriderOperator `json:"operation,omitempty"`
	// Path is field path of current object(e.g. `/spec/affinity`)
	// If current type is annotations or labels, then only need to provide the key, no need whole path.
	// +optional
	Path string `json:"path,omitempty"`
	// Value sets exact value for rule, like enum or numbers
	// Must set value when type is regex.
	// +optional
	Value *ConstantValue `json:"value,omitempty"`
	// ValueRef represents for value reference from current or remote object.
	// Need specify the type of object and how to get it.
	// +optional
	ValueRef *ResourceRefer `json:"valueRef,omitempty"`
	// Resources valid only when the type is `resources`
	// +optional
	Resources *v1.ResourceRequirements `json:"resources,omitempty"`
	// ResourcesOversell valid only when the type is `resourcesOversell`
	// +optional
	ResourcesOversell *ResourcesOversellRule `json:"resourcesOversell,omitempty"`
	// Tolerations valid only when the type is `tolerations`
	// +optional
	Tolerations []*v1.Toleration `json:"tolerations,omitempty"`
	// Affinity valid only when the type is `affinity`
	// +optional
	Affinity *v1.Affinity `json:"affinity,omitempty"`
}

OverrideRuleTemplate represents a single template of rule definition

func (*OverrideRuleTemplate) DeepCopy added in v0.4.0

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OverrideRuleTemplate.

func (*OverrideRuleTemplate) DeepCopyInto added in v0.4.0

func (in *OverrideRuleTemplate) DeepCopyInto(out *OverrideRuleTemplate)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type OverrideRuleType added in v0.4.0

type OverrideRuleType string

OverrideRuleType is definition for type of single override rule template +kubebuilder:validation:Enum=annotations;labels;resourcesOversell;resources;affinity;tolerations

const (
	// OverrideRuleTypeAnnotations - `annotations`
	OverrideRuleTypeAnnotations OverrideRuleType = "annotations"
	// OverrideRuleTypeLabels - `labels`
	OverrideRuleTypeLabels OverrideRuleType = "labels"
	// OverrideRuleTypeResourcesOversell - `resourcesOversell`
	OverrideRuleTypeResourcesOversell OverrideRuleType = "resourcesOversell"
	// OverrideRuleTypeResources - `resources`
	OverrideRuleTypeResources OverrideRuleType = "resources"
	// OverrideRuleTypeAffinity - `affinity`
	OverrideRuleTypeAffinity OverrideRuleType = "affinity"
	// OverrideRuleTypeTolerations - `tolerations`
	OverrideRuleTypeTolerations OverrideRuleType = "tolerations"
)

The valid RuleTypes

type OverriderOperator

type OverriderOperator string

OverriderOperator is the set of operators that can be used in an overrider.

const (
	// OverriderOpAdd - "add" value to object
	OverriderOpAdd OverriderOperator = "add"
	// OverriderOpRemove - remove field form object
	OverriderOpRemove OverriderOperator = "remove"
	// OverriderOpReplace - remove and add value(if specified path doesn't exist, it will add directly)
	OverriderOpReplace OverriderOperator = "replace"
)

These are valid overrider operators.

type Overriders

type Overriders struct {
	// Plaintext represents override rules defined with plaintext overriders.
	// +optional
	Plaintext []PlaintextOverrider `json:"plaintext,omitempty"`

	// Cue represents override rules defined with cue code.
	// +optional
	Cue string `json:"cue,omitempty"`

	// Template of rule which defines override rule, and
	// it will be rendered to CUE and store in RenderedCue field, so
	//if there are any data added manually will be erased.
	// +optional
	Template *OverrideRuleTemplate `json:"template,omitempty"`

	// RenderedCue represents override rule defined by Template.
	// Don't modify the value of this field, modify Rules instead of.
	// +optional
	RenderedCue string `json:"renderedCue,omitempty"`
}

Overriders offers various alternatives to represent the override rules.

If more than one alternative exist, they will be applied with following order: - RenderCue - Cue - Plaintext

func (*Overriders) DeepCopy

func (in *Overriders) DeepCopy() *Overriders

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Overriders.

func (*Overriders) DeepCopyInto

func (in *Overriders) DeepCopyInto(out *Overriders)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type PlaintextOverrider

type PlaintextOverrider struct {
	// Path indicates the path of target field
	Path string `json:"path"`
	// Operator indicates the operation on target field.
	// Available operators are: add, update and remove.
	// +kubebuilder:validation:Enum=add;remove;replace
	Operator OverriderOperator `json:"op"`
	// Value to be applied to target field.
	// Must be empty when operator is Remove.
	// +optional
	Value apiextensionsv1.JSON `json:"value,omitempty"`
}

PlaintextOverrider is a simple overrider that overrides target fields according to path, operator and value.

func (*PlaintextOverrider) DeepCopy

func (in *PlaintextOverrider) DeepCopy() *PlaintextOverrider

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlaintextOverrider.

func (*PlaintextOverrider) DeepCopyInto

func (in *PlaintextOverrider) DeepCopyInto(out *PlaintextOverrider)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ResourceRefer added in v0.4.0

type ResourceRefer struct {
	// From represents where this referenced object are.
	// +kubebuilder:validation:Enum=current;old;k8s;owner;http
	// +required
	From ValueRefFrom `json:"from,omitempty"`
	// Path has different meaning, it represents current object field path like "/spec/replica" when From equals "current"
	// and it also can be format like "data.result.x.y" when From equals "http", it represents the path in http response
	// Only when From is owner(means refer current object owner), the path can be empty.
	// +optional
	Path string `json:"path,omitempty"`
	// K8s means refer another object from current cluster.
	// +optional
	K8s *ResourceSelector `json:"k8s,omitempty"`
	// Http means refer data from remote api.
	// +optional
	Http *HttpDataRef `json:"http,omitempty"`
}

ResourceRefer defines different types of ref data

func (*ResourceRefer) DeepCopy added in v0.4.0

func (in *ResourceRefer) DeepCopy() *ResourceRefer

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceRefer.

func (*ResourceRefer) DeepCopyInto added in v0.4.0

func (in *ResourceRefer) DeepCopyInto(out *ResourceRefer)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ResourceSelector

type ResourceSelector struct {
	// APIVersion represents the API version of the target resources.
	// +required
	APIVersion string `json:"apiVersion"`

	// Kind represents the Kind of the target resources.
	// +required
	Kind string `json:"kind"`

	// Namespace of the target resource.
	// Default is empty, which means inherit from the parent object scope.
	// +optional
	Namespace string `json:"namespace,omitempty"`

	// Name of the target resource.
	// Default is empty, which means selecting all resources.
	// +optional
	Name string `json:"name,omitempty"`

	// A label query over a set of resources.
	// If name is not empty, labelSelector will be ignored.
	// +optional
	LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"`

	// A field query over a set of resources.
	// If name is not empty, fieldSelector wil be ignored.
	// +optional
	FieldSelector *FieldSelector `json:"fieldSelector,omitempty"`
}

ResourceSelector the resources will be selected.

func (*ResourceSelector) DeepCopy

func (in *ResourceSelector) DeepCopy() *ResourceSelector

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceSelector.

func (*ResourceSelector) DeepCopyInto

func (in *ResourceSelector) DeepCopyInto(out *ResourceSelector)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ResourcesOversellRule added in v0.4.0

type ResourcesOversellRule struct {
	// CpuFactor factor of cup oversell, it is float number less than 1, the range of value is (0,1.0)
	// +optional
	CpuFactor Float64 `json:"cpuFactor,omitempty"`
	// MemoryFactor factor of cup oversell, it is float number less than 1, the range of value is (0,1.0)
	// +optional
	MemoryFactor Float64 `json:"memoryFactor,omitempty"`
	// DiskFactor factor of cup oversell, it is float number less than 1, the range of value is (0,1.0)
	// +optional
	DiskFactor Float64 `json:"diskFactor,omitempty"`
}

ResourcesOversellRule defines factor of resource oversell

func (*ResourcesOversellRule) DeepCopy added in v0.4.0

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourcesOversellRule.

func (*ResourcesOversellRule) DeepCopyInto added in v0.4.0

func (in *ResourcesOversellRule) DeepCopyInto(out *ResourcesOversellRule)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type RuleWithOperation

type RuleWithOperation struct {
	// TargetOperations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or *
	// for all of those operations and any future admission operations that are added.
	// If '*' is present, the length of the slice must be one.
	// Required.
	TargetOperations []admissionv1.Operation `json:"targetOperations,omitempty"`

	// Overriders represents the override rules that would apply on resources
	// +required
	Overriders Overriders `json:"overriders"`
}

RuleWithOperation defines the override rules on operations.

func (*RuleWithOperation) DeepCopy

func (in *RuleWithOperation) DeepCopy() *RuleWithOperation

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RuleWithOperation.

func (*RuleWithOperation) DeepCopyInto

func (in *RuleWithOperation) DeepCopyInto(out *RuleWithOperation)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ValidateCondition added in v0.4.0

type ValidateCondition struct {
	// AffectMode represents the mode of policy hit affect, in default case(reject), webhook rejects the operation when
	// policy hit, otherwise it will allow the operation.
	// If mode is `allow`, only allow the operation when policy hit, otherwise reject them all.
	// +kubebuilder:validation:Enum=reject;allow
	// +required
	AffectMode AffectMode `json:"affectMode,omitempty"`
	// Cond represents type of condition (e.g. Equal, Exist)
	// +kubebuilder:validation:Enum=Equal;NotEqual;Exist;NotExist;In;NotIn;Gt;Gte;Lt;Lte
	// +required
	Cond Cond `json:"cond,omitempty"`
	// DataRef represents for data reference from current or remote object.
	// Need specify the type of object and how to get it.
	// +required
	DataRef *ResourceRefer `json:"dataRef,omitempty"`
	// Message specify reject message when policy hit.
	// +required
	Message string `json:"message,omitempty"`
	// Value sets exact value for rule, like enum or numbers
	// +optional
	Value *ConstantValue `json:"value,omitempty"`
	// ValueRef represents for value reference from current or remote object.
	// Need specify the type of object and how to get it.
	// +optional
	ValueRef *ResourceRefer `json:"valueRef,omitempty"`
	// ValueProcess represents handle process for value or valueRef.
	// Currently only support for number value, so make sure value or value from remote is a number.
	// +optional
	ValueProcess *ValueProcess `json:"valueProcess,omitempty"`
}

func (*ValidateCondition) DeepCopy added in v0.4.0

func (in *ValidateCondition) DeepCopy() *ValidateCondition

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValidateCondition.

func (*ValidateCondition) DeepCopyInto added in v0.4.0

func (in *ValidateCondition) DeepCopyInto(out *ValidateCondition)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ValidateRuleTemplate added in v0.4.0

type ValidateRuleTemplate struct {
	// Type represents current rule operate field type.
	// +kubebuilder:validation:Enum=condition
	// +required
	Type ValidateRuleType `json:"type,omitempty"`
	// Condition represents general condition rule for more custom demand.
	// +optional
	Condition *ValidateCondition `json:"condition,omitempty"`
}

ValidateRuleTemplate defines template for validate rule

func (*ValidateRuleTemplate) DeepCopy added in v0.4.0

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValidateRuleTemplate.

func (*ValidateRuleTemplate) DeepCopyInto added in v0.4.0

func (in *ValidateRuleTemplate) DeepCopyInto(out *ValidateRuleTemplate)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ValidateRuleType added in v0.4.0

type ValidateRuleType string

ValidateRuleType is definition for type of single validate rule template +kubebuilder:validation:Enum=condition

type ValidateRuleWithOperation added in v0.2.0

type ValidateRuleWithOperation struct {
	// Operations is the operations the admission hook cares about - CREATE, UPDATE, DELETE, CONNECT or *
	// for all of those operations and any future admission operations that are added.
	// If '*' is present, the length of the slice must be one.
	// Required.
	TargetOperations []admissionv1.Operation `json:"targetOperations,omitempty"`

	// Cue represents validate rules defined with cue code.
	// +optional
	Cue string `json:"cue"`

	// Template of condition which defines validate cond, and
	// it will be rendered to CUE and store in RenderedCue field, so
	// if there are any data added manually will be erased.
	// +optional
	Template *ValidateRuleTemplate `json:"template,omitempty"`

	// RenderedCue represents validate rule defined by Template.
	// Don't modify the value of this field, modify Rules instead of.
	// +optional
	RenderedCue string `json:"renderedCue,omitempty"`
}

ValidateRuleWithOperation defines validate rules on operations.

func (*ValidateRuleWithOperation) DeepCopy added in v0.2.0

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValidateRuleWithOperation.

func (*ValidateRuleWithOperation) DeepCopyInto added in v0.2.0

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ValueProcess added in v0.4.0

type ValueProcess struct {
	// Operation defines the type of operate value, and it should work with operationWith.
	// For example, operation is `*` and operationWith is 0.5 then in cue the value will be multiplied by 0.5.
	// +required
	Operation OperationType `json:"operation,omitempty"` // such as `+ - * /`
	// OperationWith defines value for operate to handle static value or value from remote.
	// +required
	OperationWith *intstr.IntOrString `json:"operationWith,omitempty"`
}

ValueProcess defines operation to handle value to compare. E.g. operation: '*'

operationWith: 50%  # or 0.5

func (*ValueProcess) DeepCopy added in v0.4.0

func (in *ValueProcess) DeepCopy() *ValueProcess

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValueProcess.

func (*ValueProcess) DeepCopyInto added in v0.4.0

func (in *ValueProcess) DeepCopyInto(out *ValueProcess)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type ValueRefFrom added in v0.4.0

type ValueRefFrom string

ValueRefFrom defines where the override value comes from when value is refer other object or http response +kubebuilder:validation:Enum=current;old;k8s;owner;http

const (
	// FromCurrentObject means read data from current k8s object(the newest one when update operate intercept)
	FromCurrentObject ValueRefFrom = "current"
	// FromOldObject means read data from old object, only used when object be updated
	FromOldObject ValueRefFrom = "old"
	// FromK8s - read data from other object in current kubernetes
	FromK8s ValueRefFrom = "k8s"
	// FromOwnerReference - load first owner reference from current object
	FromOwnerReference = "owner"
	// FromHTTP - read data from http response
	FromHTTP ValueRefFrom = "http"
)

Valid ValueRefFrom

type ValueType added in v0.4.0

type ValueType string

ValueType defines whether value is specified by user or refer from other object +kubebuilder:validation:Enum=const;ref

const (
	// ValueTypeConst means value is specified exactly.
	ValueTypeConst ValueType = "const"
	// ValueTypeRefer means value is refer from other object
	ValueTypeRefer ValueType = "ref"
)

Jump to

Keyboard shortcuts

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