apis

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

+k8s:deepcopy-gen=package

Index

Constants

View Source
const (
	// CreatorAnnotationSuffix is the suffix of the annotation key to describe
	// the user that created the resource.
	CreatorAnnotationSuffix = "/creator"

	// UpdaterAnnotationSuffix is the suffix of the annotation key to describe
	// the user who last modified the resource.
	UpdaterAnnotationSuffix = "/lastModifier"
)
View Source
const CurrentField = ""

CurrentField is a constant to supply as a fieldPath for when there is a problem with the current field itself.

Variables

This section is empty.

Functions

func AllowDifferentNamespace

func AllowDifferentNamespace(ctx context.Context) context.Context

AllowDifferentNamespace notes on the context that further validation should allow different namespaces from the encapsulating object. Mainly used by KReference, since it by default requires namespaces to match.

func ConvertFromViaProxy

func ConvertFromViaProxy(
	ctx context.Context,
	source, proxy, sink Convertible,
) error

ConvertFromViaProxy attempts to convert a specific sink from a source through a proxy

func ConvertToViaProxy

func ConvertToViaProxy(
	ctx context.Context,
	source, proxy, sink Convertible,
) error

ConvertToViaProxy attempts to convert a specific source to a sink through a proxy

func DisallowDeprecated

func DisallowDeprecated(ctx context.Context) context.Context

DisallowDeprecated notes on the context that further validation should disallow the used of deprecated fields. This may be used to ensure that new paths through resources to a common type don't allow the mistakes of old versions to be introduced.

func GetBaseline

func GetBaseline(ctx context.Context) interface{}

GetBaseline returns the baseline of the update, or nil when we are not within an update context.

func GetHTTPRequest

func GetHTTPRequest(ctx context.Context) *http.Request

GetHTTPRequest fetches the raw HTTP request received by the webhook.

func GetUserInfo

func GetUserInfo(ctx context.Context) *authenticationv1.UserInfo

GetUserInfo accesses the UserInfo attached to the webhook context.

func IsDeprecatedAllowed

func IsDeprecatedAllowed(ctx context.Context) bool

IsDeprecatedAllowed checks the context to see whether deprecated fields are allowed.

func IsDifferentNamespaceAllowed

func IsDifferentNamespaceAllowed(ctx context.Context) bool

IsDifferentNamespaceAllowed checks the context to see whether different namespace is allowed from the encapsulating object.

func IsDryRun

func IsDryRun(ctx context.Context) bool

IsDryRun indicates that this request is in DryRun mode.

func IsInCreate

func IsInCreate(ctx context.Context) bool

IsInCreate checks whether the context is a Create.

func IsInDelete

func IsInDelete(ctx context.Context) bool

IsInDelete checks whether the context is a Delete.

func IsInSpec

func IsInSpec(ctx context.Context) bool

IsInSpec returns whether the context of validation or defaulting is the Spec of the parent resource.

func IsInStatus

func IsInStatus(ctx context.Context) bool

IsInStatus returns whether the context of validation or defaulting is the Status of the parent resource.

func IsInStatusUpdate

func IsInStatusUpdate(ctx context.Context) bool

IsInStatusUpdate checks whether the context is an Update.

func IsInUpdate

func IsInUpdate(ctx context.Context) bool

IsInUpdate checks whether the context is an Update.

func IsWithinParent

func IsWithinParent(ctx context.Context) bool

IsWithinParent returns true if we're within parent context.

func KindToResource

KindToResource converts a GroupVersionKind to a GroupVersionResource through the world's simplest (worst) pluralizer.

func ParentMeta

func ParentMeta(ctx context.Context) metav1.ObjectMeta

ParentMeta accesses the ObjectMeta of the enclosing parent resource from the context. See WithinParent for how to attach the parent's ObjectMeta to the context.

func WithDryRun

func WithDryRun(ctx context.Context) context.Context

WithDryRun is used to indicate that this call is in DryRun mode.

func WithHTTPRequest

func WithHTTPRequest(ctx context.Context, r *http.Request) context.Context

WithHTTPRequest associated the HTTP request object the webhook received with the context.

func WithUserInfo

func WithUserInfo(ctx context.Context, ui *authenticationv1.UserInfo) context.Context

WithUserInfo is used to note that the webhook is calling within the context of a Create operation.

func WithinCreate

func WithinCreate(ctx context.Context) context.Context

WithinCreate is used to note that the webhook is calling within the context of a Create operation.

func WithinDelete

func WithinDelete(ctx context.Context) context.Context

WithinDelete is used to note that the webhook is calling within the context of a Delete operation.

func WithinParent

func WithinParent(ctx context.Context, om metav1.ObjectMeta) context.Context

WithinParent attaches the ObjectMeta of the resource enclosing the nested resources we are validating. This is intended for use with interfaces like apis.Defaultable and apis.Validatable.

func WithinSpec

func WithinSpec(ctx context.Context) context.Context

WithinSpec notes on the context that further validation or defaulting is within the context of a Spec. This is intended for use with interfaces like apis.Defaultable and apis.Validatable.

func WithinStatus

func WithinStatus(ctx context.Context) context.Context

WithinStatus notes on the context that further validation or defaulting is within the context of a Status. This is intended for use with interfaces like apis.Defaultable and apis.Validatable.

func WithinSubResourceUpdate

func WithinSubResourceUpdate(ctx context.Context, base interface{}, sr string) context.Context

WithinSubResourceUpdate is used to note that the webhook is calling within the context of a Update operation on a subresource.

func WithinUpdate

func WithinUpdate(ctx context.Context, base interface{}) context.Context

WithinUpdate is used to note that the webhook is calling within the context of a Update operation.

Types

type Annotatable deprecated

type Annotatable interface{}

Annotatable indicates that a particular type applies various annotations.

Deprecated: Use WithUserInfo / GetUserInfo from within SetDefaults instead. The webhook functionality for this has been turned down, which is why this interface is empty.

type Condition

type Condition struct {
	// Type of condition.
	// +required
	Type ConditionType `json:"type" description:"type of status condition"`

	// Status of the condition, one of True, False, Unknown.
	// +required
	Status corev1.ConditionStatus `json:"status" description:"status of the condition, one of True, False, Unknown"`

	// Severity with which to treat failures of this type of condition.
	// When this is not specified, it defaults to Error.
	// +optional
	Severity ConditionSeverity `json:"severity,omitempty" description:"how to interpret failures of this condition, one of Error, Warning, Info"`

	// LastTransitionTime is the last time the condition transitioned from one status to another.
	// We use VolatileTime in place of metav1.Time to exclude this from creating equality.Semantic
	// differences (all other things held constant).
	// +optional
	LastTransitionTime VolatileTime `json:"lastTransitionTime,omitempty" description:"last time the condition transit from one status to another"`

	// The reason for the condition's last transition.
	// +optional
	Reason string `json:"reason,omitempty" description:"one-word CamelCase reason for the condition's last transition"`

	// A human readable message indicating details about the transition.
	// +optional
	Message string `json:"message,omitempty" description:"human-readable message indicating details about last transition"`
}

Condition defines a readiness condition for a Knative resource. See: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties +k8s:deepcopy-gen=true

func (*Condition) DeepCopy

func (in *Condition) DeepCopy() *Condition

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

func (*Condition) DeepCopyInto

func (in *Condition) DeepCopyInto(out *Condition)

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

func (*Condition) GetMessage

func (c *Condition) GetMessage() string

GetMessage returns a nil save string of Message

func (*Condition) GetReason

func (c *Condition) GetReason() string

GetReason returns a nil save string of Reason

func (*Condition) IsFalse

func (c *Condition) IsFalse() bool

IsFalse is true if the condition is False

func (*Condition) IsTrue

func (c *Condition) IsTrue() bool

IsTrue is true if the condition is True

func (*Condition) IsUnknown

func (c *Condition) IsUnknown() bool

IsUnknown is true if the condition is Unknown

type ConditionAccessor

type ConditionAccessor interface {
	// GetCondition finds and returns the Condition that matches the ConditionType
	// It should return nil if the condition type is not present
	GetCondition(t ConditionType) *Condition
}

ConditionAccessor is used to access a condition through it's type

type ConditionManager

type ConditionManager interface {
	ConditionAccessor

	// IsHappy looks at the happy condition and returns true if that condition is
	// set to true.
	IsHappy() bool

	// GetTopLevelCondition finds and returns the top level Condition (happy Condition).
	GetTopLevelCondition() *Condition

	// SetCondition sets or updates the Condition on Conditions for Condition.Type.
	// If there is an update, Conditions are stored back sorted.
	SetCondition(new Condition)

	// ClearCondition removes the non terminal condition that matches the ConditionType
	ClearCondition(t ConditionType) error

	// MarkTrue sets the status of t to true, and then marks the happy condition to
	// true if all dependents are true.
	MarkTrue(t ConditionType)

	// MarkTrueWithReason sets the status of t to true with the reason, and then marks the happy
	// condition to true if all dependents are true.
	MarkTrueWithReason(t ConditionType, reason, messageFormat string, messageA ...interface{})

	// MarkUnknown sets the status of t to Unknown and also sets the happy condition
	// to Unknown if no other dependent condition is in an error state.
	MarkUnknown(t ConditionType, reason, messageFormat string, messageA ...interface{})

	// MarkFalse sets the status of t and the happy condition to False.
	MarkFalse(t ConditionType, reason, messageFormat string, messageA ...interface{})

	// InitializeConditions updates all Conditions in the ConditionSet to Unknown
	// if not set.
	InitializeConditions()
}

ConditionManager allows a resource to operate on its Conditions using higher order operations.

type ConditionSet

type ConditionSet struct {
	// contains filtered or unexported fields
}

ConditionSet is an abstract collection of the possible ConditionType values that a particular resource might expose. It also holds the "happy condition" for that resource, which we define to be one of Ready or Succeeded depending on whether it is a Living or Batch process respectively. +k8s:deepcopy-gen=false

func NewBatchConditionSet

func NewBatchConditionSet(d ...ConditionType) ConditionSet

NewBatchConditionSet returns a ConditionSet to hold the conditions for the batch resource. ConditionSucceeded is used as the happy condition. The set of condition types provided are those of the terminal subconditions.

func NewLivingConditionSet

func NewLivingConditionSet(d ...ConditionType) ConditionSet

NewLivingConditionSet returns a ConditionSet to hold the conditions for the living resource. ConditionReady is used as the happy condition. The set of condition types provided are those of the terminal subconditions.

func (ConditionSet) GetTopLevelConditionType

func (r ConditionSet) GetTopLevelConditionType() ConditionType

GetTopLevelConditionType is an accessor for the top-level happy condition.

func (ConditionSet) Manage

Manage creates a ConditionManager from an accessor object using the original ConditionSet as a reference. Status must be a pointer to a struct.

type ConditionSeverity

type ConditionSeverity string

ConditionSeverity expresses the severity of a Condition Type failing.

const (
	// ConditionSeverityError specifies that a failure of a condition type
	// should be viewed as an error.  As "Error" is the default for conditions
	// we use the empty string (coupled with omitempty) to avoid confusion in
	// the case where the condition is in state "True" (aka nothing is wrong).
	ConditionSeverityError ConditionSeverity = ""
	// ConditionSeverityWarning specifies that a failure of a condition type
	// should be viewed as a warning, but that things could still work.
	ConditionSeverityWarning ConditionSeverity = "Warning"
	// ConditionSeverityInfo specifies that a failure of a condition type
	// should be viewed as purely informational, and that things could still work.
	ConditionSeverityInfo ConditionSeverity = "Info"
)

type ConditionType

type ConditionType string

ConditionType is a camel-cased condition type.

const (
	// ConditionReady specifies that the resource is ready.
	// For long-running resources.
	ConditionReady ConditionType = "Ready"
	// ConditionSucceeded specifies that the resource has finished.
	// For resource which run to completion.
	ConditionSucceeded ConditionType = "Succeeded"
)

type Conditions

type Conditions []Condition

Conditions is the schema for the conditions portion of the payload

func (Conditions) DeepCopy

func (in Conditions) DeepCopy() Conditions

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

func (Conditions) DeepCopyInto

func (in Conditions) DeepCopyInto(out *Conditions)

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

type ConditionsAccessor

type ConditionsAccessor interface {
	GetConditions() Conditions
	SetConditions(Conditions)
}

ConditionsAccessor is the interface for a Resource that implements the getter and setter for accessing a Condition collection. +k8s:deepcopy-gen=true

type Convertible

type Convertible interface {
	// ConvertTo converts the receiver into `to`.
	ConvertTo(ctx context.Context, to Convertible) error

	// ConvertFrom converts `from` into the receiver.
	ConvertFrom(ctx context.Context, from Convertible) error
}

Convertible indicates that a particular type supports conversions to/from "higher" versions of the same type.

type Defaultable

type Defaultable interface {
	SetDefaults(context.Context)
}

Defaultable defines an interface for setting the defaults for the uninitialized fields of this instance.

type FieldError

type FieldError struct {
	Message string
	Paths   []string
	// Details contains an optional longer payload.
	// +optional
	Details string
	// contains filtered or unexported fields
}

FieldError is used to propagate the context of errors pertaining to specific fields in a manner suitable for use in a recursive walk, so that errors contain the appropriate field context. FieldError methods are non-mutating. +k8s:deepcopy-gen=true

func CheckDeprecated

func CheckDeprecated(ctx context.Context, obj interface{}) *FieldError

CheckDeprecated checks whether the provided named deprecated fields are set in a context where deprecation is disallowed. This is a shallow check.

func CheckDeprecatedUpdate

func CheckDeprecatedUpdate(ctx context.Context, obj, original interface{}) *FieldError

CheckDeprecatedUpdate checks whether the provided named deprecated fields are set in a context where deprecation is disallowed. This is a json shallow check. We will recursively check inlined structs.

func CheckDisallowedFields

func CheckDisallowedFields(request, maskedRequest interface{}) *FieldError

CheckDisallowedFields compares the request object against a masked request object. Fields that are set in the request object that are unset in the mask are reported back as disallowed fields. If there is an error comparing the two objects FieldError of "Internal Error" is returned.

func ErrDisallowedFields

func ErrDisallowedFields(fieldPaths ...string) *FieldError

ErrDisallowedFields is a variadic helper method for constructing a FieldError for a set of disallowed fields.

func ErrDisallowedUpdateDeprecatedFields

func ErrDisallowedUpdateDeprecatedFields(fieldPaths ...string) *FieldError

ErrDisallowedUpdateDeprecatedFields is a variadic helper method for constructing a FieldError for updating of deprecated fields.

func ErrGeneric

func ErrGeneric(diagnostic string, fieldPaths ...string) *FieldError

ErrGeneric constructs a FieldError to allow for the different error strings for the the different cases.

func ErrInvalidArrayValue

func ErrInvalidArrayValue(value interface{}, field string, index int) *FieldError

ErrInvalidArrayValue constructs a FieldError for a repetitive `field` at `index` that has received an invalid value.

func ErrInvalidKeyName

func ErrInvalidKeyName(key, fieldPath string, details ...string) *FieldError

ErrInvalidKeyName is a variadic helper method for constructing a FieldError that specifies a key name that is invalid.

func ErrInvalidValue

func ErrInvalidValue(value interface{}, fieldPath string, details ...string) *FieldError

ErrInvalidValue is a variadic helper method for constructing a FieldError for a field that has received an invalid value.

func ErrMissingField

func ErrMissingField(fieldPaths ...string) *FieldError

ErrMissingField is a variadic helper method for constructing a FieldError for a set of missing fields.

func ErrMissingOneOf

func ErrMissingOneOf(fieldPaths ...string) *FieldError

ErrMissingOneOf is a variadic helper method for constructing a FieldError for not having at least one field in a mutually exclusive field group.

func ErrMultipleOneOf

func ErrMultipleOneOf(fieldPaths ...string) *FieldError

ErrMultipleOneOf is a variadic helper method for constructing a FieldError for having more than one field set in a mutually exclusive field group.

func ErrOutOfBoundsValue

func ErrOutOfBoundsValue(value, lower, upper interface{}, fieldPath string) *FieldError

ErrOutOfBoundsValue constructs a FieldError for a field that has received an out of bound value.

func ValidateCreatorAndModifier

func ValidateCreatorAndModifier(oldSpec, newSpec interface{}, oldAnnotation, newAnnotation map[string]string, groupName string) *FieldError

ValidateCreatorAndModifier validates `metadata.annotation`

func ValidateObjectMetadata

func ValidateObjectMetadata(meta metav1.Object) *FieldError

ValidateObjectMetadata validates that `metadata` stanza of the resources is correct.

func (*FieldError) Also

func (fe *FieldError) Also(errs ...*FieldError) *FieldError

Also collects errors, returns a new collection of existing errors and new errors.

func (*FieldError) DeepCopy

func (in *FieldError) DeepCopy() *FieldError

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

func (*FieldError) DeepCopyInto

func (in *FieldError) DeepCopyInto(out *FieldError)

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

func (*FieldError) Error

func (fe *FieldError) Error() string

Error implements error

func (*FieldError) ViaField

func (fe *FieldError) ViaField(prefix ...string) *FieldError

ViaField is used to propagate a validation error along a field access. For example, if a type recursively validates its "spec" via:

if err := foo.Spec.Validate(); err != nil {
  // Augment any field paths with the context that they were accessed
  // via "spec".
  return err.ViaField("spec")
}

func (*FieldError) ViaFieldIndex

func (fe *FieldError) ViaFieldIndex(field string, index int) *FieldError

ViaFieldIndex is the short way to chain: err.ViaIndex(bar).ViaField(foo)

func (*FieldError) ViaFieldKey

func (fe *FieldError) ViaFieldKey(field, key string) *FieldError

ViaFieldKey is the short way to chain: err.ViaKey(bar).ViaField(foo)

func (*FieldError) ViaIndex

func (fe *FieldError) ViaIndex(index int) *FieldError

ViaIndex is used to attach an index to the next ViaField provided. For example, if a type recursively validates a parameter that has a collection:

for i, c := range spec.Collection {
  if err := doValidation(c); err != nil {
    return err.ViaIndex(i).ViaField("collection")
  }
}

func (*FieldError) ViaKey

func (fe *FieldError) ViaKey(key string) *FieldError

ViaKey is used to attach a key to the next ViaField provided. For example, if a type recursively validates a parameter that has a collection:

for k, v := range spec.Bag {
  if err := doValidation(v); err != nil {
    return err.ViaKey(k).ViaField("bag")
  }
}

type HasSpec

type HasSpec interface {
	// GetUntypedSpec returns the spec of the resource.
	GetUntypedSpec() interface{}
}

HasSpec indicates that a particular type has a specification information and that information is retrievable.

type Listable

type Listable interface {
	runtime.Object

	GetListType() runtime.Object
}

Listable indicates that a particular type can be returned via the returned list type by the API server.

type URL

type URL url.URL

URL is an alias of url.URL. It has custom json marshal methods that enable it to be used in K8s CRDs such that the CRD resource will have the URL but operator code can can work with url.URL struct +kubebuilder:validation:Type=string

func HTTP

func HTTP(domain string) *URL

HTTP creates an http:// URL pointing to a known domain.

func HTTPS

func HTTPS(domain string) *URL

HTTPS creates an https:// URL pointing to a known domain.

func ParseURL

func ParseURL(u string) (*URL, error)

ParseURL attempts to parse the given string as a URL. Compatible with net/url.Parse except in the case of an empty string, where the resulting *URL will be nil with no error.

func (*URL) DeepCopy

func (in *URL) DeepCopy() *URL

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

func (*URL) DeepCopyInto

func (in *URL) DeepCopyInto(out *URL)

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

func (*URL) IsEmpty

func (u *URL) IsEmpty() bool

IsEmpty returns true if the URL is `nil` or represents an empty URL.

func (URL) MarshalJSON

func (u URL) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom json marshal method used when this type is marshaled using json.Marshal. json.Marshaler impl

func (*URL) ResolveReference

func (u *URL) ResolveReference(ref *URL) *URL

ResolveReference calls the underlying ResolveReference method and returns an apis.URL

func (*URL) String

func (u *URL) String() string

String returns the full string representation of the URL.

func (*URL) URL

func (u *URL) URL() *url.URL

URL returns the URL as a url.URL.

func (*URL) UnmarshalJSON

func (u *URL) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json unmarshal method used when this type is unmarsheled using json.Unmarshal. json.Unmarshaler impl

type Validatable

type Validatable interface {
	// Validate checks the validity of this types fields.
	Validate(context.Context) *FieldError
}

Validatable indicates that a particular type may have its fields validated.

type VolatileTime

type VolatileTime struct {
	Inner metav1.Time `json:",inline"`
}

VolatileTime wraps metav1.Time

Unlike metav1.Time, VolatileTimes are considered semantically equal when using kubernetes semantic equality checks. Thus differing VolatileTime values are not considered different. Note, go-cmp will still return inequality, see unit test if you need this behavior for go-cmp.

+kubebuilder:validation:Type=string

func (*VolatileTime) DeepCopy

func (in *VolatileTime) DeepCopy() *VolatileTime

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

func (*VolatileTime) DeepCopyInto

func (in *VolatileTime) DeepCopyInto(out *VolatileTime)

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

func (VolatileTime) MarshalJSON

func (t VolatileTime) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*VolatileTime) UnmarshalJSON

func (t *VolatileTime) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaller interface.

Directories

Path Synopsis
Package duck defines logic for defining and consuming "duck typed" Kubernetes resources.
Package duck defines logic for defining and consuming "duck typed" Kubernetes resources.
v1
+k8s:deepcopy-gen=package +groupName=duck.knative.dev
+k8s:deepcopy-gen=package +groupName=duck.knative.dev
v1alpha1
+k8s:deepcopy-gen=package +groupName=duck.knative.dev
+k8s:deepcopy-gen=package +groupName=duck.knative.dev
v1beta1
+k8s:deepcopy-gen=package +groupName=duck.knative.dev
+k8s:deepcopy-gen=package +groupName=duck.knative.dev
authentication/v1alpha1
Api versions allow the api contract for a resource to be changed while keeping backward compatibility by support multiple concurrent versions of the same resource +k8s:deepcopy-gen=package +groupName=authentication.istio.io
Api versions allow the api contract for a resource to be changed while keeping backward compatibility by support multiple concurrent versions of the same resource +k8s:deepcopy-gen=package +groupName=authentication.istio.io
v1alpha3
+k8s:deepcopy-gen=package +groupName=networking.istio.io
+k8s:deepcopy-gen=package +groupName=networking.istio.io
test
example/v1alpha1
+k8s:deepcopy-gen=package +groupName=sample.knative.dev
+k8s:deepcopy-gen=package +groupName=sample.knative.dev
pub
pub/v1alpha1
+k8s:deepcopy-gen=package +groupName=sample.knative.dev
+k8s:deepcopy-gen=package +groupName=sample.knative.dev

Jump to

Keyboard shortcuts

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