v1alpha1

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package v1alpha1 contains API Schema definitions for the types v1alpha1 API group this group is a duck type only package that hosts common objects and interfaces in alauda devops very similar to knative.dev/pkg/apis/duck/v1 or k8s.io/apimachinery/pkg/apis/meta/v1 +kubebuilder:object:generate=true +k8s:deepcopy-gen=package +groupName=meta.alauda.io

Index

Constants

View Source
const (
	// DisplayNameAnnotationKey display name for objects
	DisplayNameAnnotationKey = "cpaas.io/displayName"
	// CreatedTimeAnnotationKey creation time for objects
	CreatedTimeAnnotationKey = "cpaas.io/creationTime"
	// UpdatedTimeAnnotationKey update time for objects
	UpdatedTimeAnnotationKey = "cpaas.io/updateTime"
	// DeletedTimeAnnotationKey deletion time for objects
	DeletedTimeAnnotationKey = "cpaas.io/deletionTime"

	// NamespaceAnnotationKey namespace of objects
	NamespaceAnnotationKey = "cpaas.io/namespace"

	// CreatedByAnnotationKey annotation key to store resource creation username
	CreatedByAnnotationKey = "cpaas.io/createdBy"
	// UpdatedByAnnotationKey annotation key to store resource update username
	UpdatedByAnnotationKey = "cpaas.io/updatedBy"
	// DeletedByAnnotationKey annotation key to store resource update username
	DeletedByAnnotationKey = "cpaas.io/deletedBy"

	// TriggeredByAnnotationKey annotation key to store resource update username
	TriggeredByAnnotationKey = "cpaas.io/triggeredBy"

	// UIDescriptorsAnnotationKey annotation for storing ui descriptors in resources
	UIDescriptorsAnnotationKey = "ui.cpaas.io/descriptors"
)

Common Annotations

View Source
const (
	ConditionReasonNotSet = "NotSet"
)
View Source
const (
	// MaxConditionMessageLength indicates max message field length in condition
	MaxConditionMessageLength = 1000
)

Variables

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

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

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

AllParamTypes can be used for ParamType validation.

Functions

func CopyAnnotations

func CopyAnnotations(object, dest metav1.Object)

CopyAnnotations from the left side object to the right side will override any existing values

func CopyLabels

func CopyLabels(object, dest metav1.Object)

CopyLabels from the left side object to the right side will override any existing labels

func CopyMapStringString

func CopyMapStringString(object, dest map[string]string) map[string]string

CopyMapStringString copies content from a map to another

func FilterMapKeys

func FilterMapKeys(mapObj map[string]string, ignorePrefixes ...string) map[string]string

FilterMapKeys filters a map[string]string by a list of keys

func GetCondition

func GetCondition(conditions apis.Conditions, t apis.ConditionType) *apis.Condition

GetCondition will return the first condition pointer filter by type in conditions

func GetNamespacedNameFromObject

func GetNamespacedNameFromObject(obj metav1.Object) (named types.NamespacedName)

GetNamespacedNameFromObject returns a types.NamespacedName from an object

func HasAnnotation

func HasAnnotation(obj metav1.Object, key, value string) bool

HasAnnotation returns true if the object has the annotation and the values matches

func HasAnnotationKey

func HasAnnotationKey(obj metav1.Object, key string) bool

HasAnnotationKey returns true if the object has the annotation key

func HasLabel

func HasLabel(obj metav1.Object, key, value string) bool

HasLabel returns true if the object has the label and the values matches

func HasLabelKey

func HasLabelKey(obj metav1.Object, key string) bool

HasLabelKey returns true if the object has the label key

func IsConditionChanged

func IsConditionChanged(current, old apis.ConditionAccessor, conditionType apis.ConditionType) bool

IsConditionChanged given two condition accessors and a condition type will check if conditions changed

func MapContainsKey

func MapContainsKey(mapObj map[string]string, key string) bool

MapContainsKey checks if a map[string]string has a key

func MapContainsKeyValue

func MapContainsKeyValue(mapObj map[string]string, key, value string) bool

MapContainsKeyValue checks if a map[string]string has a key with a specific value

func PropagateCondition

func PropagateCondition(conditionManager apis.ConditionManager, conditionType apis.ConditionType, condition *apis.Condition)

PropagateCondition propagates a condition based on an external conditions used mainly when a resource depends on another and its conditions needs to be synced

func ReasonForError

func ReasonForError(err error) string

ReasonForError returns a string for Reason from an error. If the error is a apimachinery.StatusError will return its reason, otherwise will return unknown

func SetConditionByError

func SetConditionByError(conditionManager apis.ConditionManager, condition apis.ConditionType, err error)

SetConditionByError sets a condition using an error to determine if it is True or False. If the given error is not nil will examine its reason and mark the condition as False otherwise will set condition to True

func SetConditionByErrorReason

func SetConditionByErrorReason(conditionManager apis.ConditionManager, condition apis.ConditionType, err error, reason string)

SetConditionByErrorReason sets a condition with error and reason If the given error is not nil will examine its reason and mark the condition as False otherwise will set condition to True If the given reason is empty, it will parse a string for reason from the error

Types

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"
	// ConditionPending specifies that the resource is pending.
	// For resource which run is waiting to be executed.
	ConditionPending ConditionType = "Pending"
	// ConditionRunning specifies that the resource is running.
	// For resource which run is running.
	ConditionRunning ConditionType = "Running"
	// ConditionFailed specifies that the resource is failed.
	// For resource which run to failed.
	ConditionFailed ConditionType = "Failed"
	// ConditionDisabled specifies that the resource is disabled.
	// For resource which can't be run.
	ConditionDisabled ConditionType = "Disabled"
	// ConditionCanceled specifies that the resource is canceled.
	// For resource which run to canceled.
	ConditionCanceled ConditionType = "Canceled"
)

type CreatedBy

type CreatedBy struct {
	// Reference to the user that created the object. Any Kubernetes `Subject` is accepted.
	// +optional
	User *rbacv1.Subject `json:"user,omitempty"`
}

CreatedBy stores a list of created information.

func (*CreatedBy) DeepCopy

func (in *CreatedBy) DeepCopy() *CreatedBy

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

func (*CreatedBy) DeepCopyInto

func (in *CreatedBy) DeepCopyInto(out *CreatedBy)

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

func (*CreatedBy) FromAnnotation

func (by *CreatedBy) FromAnnotation(annotations map[string]string) (*CreatedBy, error)

FromAnnotation will set `by` from annotations it will find CreatedByAnnotationKey and unmarshl content into struct type *CreatedBy if not found CreatedByAnnotationKey, error would be nil, and *CreatedBy would be nil also. if some errors happened, error will not be nil and *CreatedBy will be nil

func (*CreatedBy) IsZero

func (by *CreatedBy) IsZero() bool

IsZero basic function returns true when all attributes of the object are empty

func (*CreatedBy) SetIntoAnnotation

func (by *CreatedBy) SetIntoAnnotation(annotations map[string]string) (map[string]string, error)

SetIntoAnnotation will set CreatedBy into annotations return annotations that with CreatedBy.

type DataMap

type DataMap map[string]string

DataMap describe a map[string]string struct

func (DataMap) BoolVal

func (c DataMap) BoolVal(key string) (*bool, error)

BoolVal return bool value with specified key, if not found return nil

func (DataMap) DeepCopy

func (in DataMap) DeepCopy() DataMap

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

func (DataMap) DeepCopyInto

func (in DataMap) DeepCopyInto(out *DataMap)

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

func (DataMap) IntVal

func (c DataMap) IntVal(key string) (*int, error)

IntVal return int value with specified key, if not found return nil

func (DataMap) MustBoolVal

func (c DataMap) MustBoolVal(key string, dft bool) bool

MustBoolVal return bool value with specified key

func (DataMap) MustIntVal

func (c DataMap) MustIntVal(key string, dft int) int

MustIntVal return int value with specified key

func (DataMap) MustStringVal

func (c DataMap) MustStringVal(key string, dft string) string

MustStringVal return string value with specified key

func (DataMap) MustTimeDurationVal

func (c DataMap) MustTimeDurationVal(key string, dft time.Duration) time.Duration

MustTimeDurationVal return time.Duration value with specified key

func (DataMap) StringVal

func (c DataMap) StringVal(key string) *string

StringVal return string value with specified key, if not found return nil

func (DataMap) TimeDurationVal

func (c DataMap) TimeDurationVal(key string) (*time.Duration, error)

TimeDurationVal return time.Duration value with specified key, if not found return nil

type DeletedBy

type DeletedBy struct {
	// Reference to the user that created the object. Any Kubernetes `Subject` is accepted.
	// +optional
	User *rbacv1.Subject `json:"user,omitempty"`
}

DeletedBy stores deleted user information.

func (*DeletedBy) DeepCopy

func (in *DeletedBy) DeepCopy() *DeletedBy

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

func (*DeletedBy) DeepCopyInto

func (in *DeletedBy) DeepCopyInto(out *DeletedBy)

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

func (*DeletedBy) FromAnnotation

func (by *DeletedBy) FromAnnotation(annotations map[string]string) (*DeletedBy, error)

FromAnnotation will set `by` from annotations it will find DeletedByAnnotationKey and unmarshl content into struct type *DeletedBy if not found DeletedByAnnotationKey, error would be nil, and *DeletedBy would be nil also. if some errors happened, error will not be nil and *DeletedBy will be nil

func (*DeletedBy) IsZero

func (by *DeletedBy) IsZero() bool

IsZero basic function returns true when all attributes of the object are empty

func (*DeletedBy) SetIntoAnnotation

func (by *DeletedBy) SetIntoAnnotation(annotations map[string]string) (map[string]string, error)

SetIntoAnnotation will set DeletedBy into annotations return annotations that with DeletedBy.

type ListMeta

type ListMeta struct {
	metav1.ListMeta `json:",inline"`

	// TotalItems returned in the list
	TotalItems int `json:"totalItems"`

	// Current page number
	// +optional
	Page *int `json:"page,omitempty"`

	// Current items per page
	// +optional
	ItemsPerPage *int `json:"itemsPerPage,omitempty"`

	// Total number of pages
	// +optional
	TotalPages *int `json:"totalPages,omitempty"`
}

ListMeta extension of the metav1.ListMeta with paging related data

func (*ListMeta) DeepCopy

func (in *ListMeta) DeepCopy() *ListMeta

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

func (*ListMeta) DeepCopyInto

func (in *ListMeta) DeepCopyInto(out *ListMeta)

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

type ListOptions

type ListOptions struct {

	// ItemsPerPage desired number of items to be returned in each page
	ItemsPerPage int `json:"itemsPerPage"`

	// Page desired to be returned
	Page int `json:"page"`
}

ListOptions options for list

func (*ListOptions) DeepCopy

func (in *ListOptions) DeepCopy() *ListOptions

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

func (*ListOptions) DeepCopyInto

func (in *ListOptions) DeepCopyInto(out *ListOptions)

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

type Pager

type Pager struct {
	// ItemsPerPage desired number of items to be returned in each page
	ItemsPerPage int `json:"itemsPerPage"`

	// Page desired to be returned
	Page int `json:"page"`
}

Pager describe the paging params

func (*Pager) DeepCopy

func (in *Pager) DeepCopy() *Pager

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

func (*Pager) DeepCopyInto

func (in *Pager) DeepCopyInto(out *Pager)

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

func (*Pager) GetOffset

func (p *Pager) GetOffset() int

GetOffset get the offset for next query

func (*Pager) GetPage

func (p *Pager) GetPage() int

GetPage get the current page

func (*Pager) GetPageLimit

func (p *Pager) GetPageLimit() int

GetPageLimit get the limit returned by a single page

type Param

type Param struct {
	Name  string     `json:"name"`
	Value ParamValue `json:"value"`
}

Param declares an ParamValues to use for the parameter called name.

func (*Param) DeepCopy

func (in *Param) DeepCopy() *Param

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

func (*Param) DeepCopyInto

func (in *Param) DeepCopyInto(out *Param)

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

type ParamSpec

type ParamSpec struct {
	// Name declares the name by which a parameter is referenced.
	Name string `json:"name"`
	// Type is the user-specified type of the parameter. The possible types
	// are currently "string", "array" and "object", and "string" is the default.
	// +optional
	Type ParamType `json:"type,omitempty"`
	// Description is a user-facing description of the parameter that may be
	// used to populate a UI.
	// +optional
	Description string `json:"description,omitempty"`
	// Properties is the JSON Schema properties to support key-value pairs parameter.
	// +optional
	Properties map[string]PropertySpec `json:"properties,omitempty"`
	// Default is the value a parameter takes if no input value is supplied.
	// +optional
	Default *ParamValue `json:"default,omitempty"`
	// Enum declares a set of allowed param input values.
	// If Enum is not set, no input validation is performed for the param.
	// +optional
	Enum []string `json:"enum,omitempty"`
}

ParamSpec defines arbitrary parameters needed beyond typed inputs (such as resources).

func (*ParamSpec) DeepCopy

func (in *ParamSpec) DeepCopy() *ParamSpec

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

func (*ParamSpec) DeepCopyInto

func (in *ParamSpec) DeepCopyInto(out *ParamSpec)

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

func (*ParamSpec) SetDefaults

func (pp *ParamSpec) SetDefaults(context.Context)

SetDefaults set the default type

type ParamSpecs

type ParamSpecs []ParamSpec

ParamSpecs is a list of ParamSpec +listType=atomic

func (ParamSpecs) DeepCopy

func (in ParamSpecs) DeepCopy() ParamSpecs

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

func (ParamSpecs) DeepCopyInto

func (in ParamSpecs) DeepCopyInto(out *ParamSpecs)

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

func (ParamSpecs) GetNames

func (ps ParamSpecs) GetNames() []string

GetNames returns all the names of the declared parameters

func (ParamSpecs) SortByType

func (ps ParamSpecs) SortByType() (ParamSpecs, ParamSpecs, ParamSpecs)

SortByType splits the input params into string params, array params, and object params, in that order

func (ParamSpecs) ValidateNoDuplicateNames

func (ps ParamSpecs) ValidateNoDuplicateNames() *apis.FieldError

ValidateNoDuplicateNames returns an error if any of the params have the same name

type ParamType

type ParamType string

ParamType indicates the type of an input parameter; Used to distinguish between a single string and an array of strings.

const (
	ParamTypeString ParamType = "string"
	ParamTypeArray  ParamType = "array"
	ParamTypeObject ParamType = "object"
)

Valid ParamTypes:

type ParamValue

type ParamValue struct {
	Type      ParamType `json:"type"` // Represents the stored type of ParamValues.
	StringVal string    `json:"stringVal"`
	// +listType=atomic
	ArrayVal  []string          `json:"arrayVal"`
	ObjectVal map[string]string `json:"objectVal"`
}

ParamValue is a type that can hold a single string, string array, or string map. Used in JSON unmarshalling so that a single JSON field can accept either an individual string or an array of strings.

func NewObject

func NewObject(pairs map[string]string) *ParamValue

NewObject creates an ParamValues of type ParamTypeObject using the provided key-value pairs

func NewStructuredValues

func NewStructuredValues(value string, values ...string) *ParamValue

NewStructuredValues creates an ParamValues of type ParamTypeString or ParamTypeArray, based on how many inputs are given (>1 input will create an array, not string).

func (*ParamValue) DeepCopy

func (in *ParamValue) DeepCopy() *ParamValue

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

func (*ParamValue) DeepCopyInto

func (in *ParamValue) DeepCopyInto(out *ParamValue)

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

func (ParamValue) MarshalJSON

func (paramValues ParamValue) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaller interface.

func (*ParamValue) UnmarshalJSON

func (paramValues *ParamValue) UnmarshalJSON(value []byte) error

UnmarshalJSON implements the json.Unmarshaller interface.

type Params

type Params []Param

Params is a list of Param +listType=atomic

func (Params) DeepCopy

func (in Params) DeepCopy() Params

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

func (Params) DeepCopyInto

func (in Params) DeepCopyInto(out *Params)

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

func (Params) ExtractNames

func (ps Params) ExtractNames() sets.Set[string]

ExtractNames returns a set of unique names

type PropertySpec

type PropertySpec struct {
	Type ParamType `json:"type,omitempty"`
}

PropertySpec defines the struct for object keys

func (*PropertySpec) DeepCopy

func (in *PropertySpec) DeepCopy() *PropertySpec

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

func (*PropertySpec) DeepCopyInto

func (in *PropertySpec) DeepCopyInto(out *PropertySpec)

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

type TopLevelConditionObject

type TopLevelConditionObject interface {
	metav1.Object
	// GetTopLevelCondition finds and returns the top level Condition (happy Condition).
	GetTopLevelCondition() *apis.Condition
}

TopLevelConditionObject shoule be an metav1.Object that implement func GetTopLevelCondition() *apis.Condition +k8s:deepcopy-gen=false

type UpdatedBy

type UpdatedBy struct {
	// Reference to the user that created the object. Any Kubernetes `Subject` is accepted.
	// +optional
	User *rbacv1.Subject `json:"user,omitempty"`
}

UpdatedBy stores updated user information.

func (*UpdatedBy) DeepCopy

func (in *UpdatedBy) DeepCopy() *UpdatedBy

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

func (*UpdatedBy) DeepCopyInto

func (in *UpdatedBy) DeepCopyInto(out *UpdatedBy)

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

func (*UpdatedBy) FromAnnotation

func (by *UpdatedBy) FromAnnotation(annotations map[string]string) (*UpdatedBy, error)

FromAnnotation will set `by` from annotations it will find UpdatedByAnnotationKey and unmarshl content into struct type *UpdatedBy if not found UpdatedByAnnotationKey, error would be nil, and *UpdatedBy would be nil also. if some errors happened, error will not be nil and *UpdatedBy will be nil

func (*UpdatedBy) IsZero

func (by *UpdatedBy) IsZero() bool

IsZero basic function returns true when all attributes of the object are empty

func (*UpdatedBy) SetIntoAnnotation

func (by *UpdatedBy) SetIntoAnnotation(annotations map[string]string) (map[string]string, error)

SetIntoAnnotation will set UpdatedBy into annotations return annotations that with UpdatedBy.

Jump to

Keyboard shortcuts

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