core

package
v0.0.0-...-f0fce53 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AnnotationPrefix                   = "pcitech.io/"
	AnnotationJobPrefix                = AnnotationPrefix + "job/"
	AnnotationAlgorithmPluginPrefix    = AnnotationPrefix + "algorithm-plugin/"
	AnnotationLastAppliedConfiguration = AnnotationPrefix + "last-applied-configuration"

	Group        = "core"
	ApiVersionV1 = "v1"

	AppCategoryCustomize       = "customize"
	AppCategoryThirdParty      = "thirdParty"
	AppCategoryHostPlugin      = "hostPlugin"
	AppCategoryAlgorithmPlugin = "algorithmPlugin"

	AppPlatformBareMetal = "bareMetal"
	AppPlatformK8s       = "k8s"

	AppActionInstall     = "install"
	AppActionConfigure   = "configure"
	AppActionHealthcheck = "healthcheck"
	AppActionUninstall   = "uninstall"
	AppActionUpdate      = "update"
	AppActionUpgrade     = "upgrade"
	AppActionRevert      = "revert"

	AuditActionCreate = "create"
	AuditActionUpdate = "update"
	AuditActionDelete = "delete"

	DefaultEtcdEndpoint = "localhost:2379"

	DefaultNamespace = "default"

	RegistryPrefix = "/prophet"

	KindApp         = "app"
	KindAppInstance = "appInstance"
	KindAudit       = "audit"
	KindEvent       = "event"
	KindHost        = "host"
	KindJob         = "job"
	KindConfigMap   = "configMap"
	KindK8sConfig   = "k8sconfig"
	KindK8sLabel    = "k8slabel"
	KindNamespace   = "namespace"
	KindPkg         = "pkg"
	KindGPU         = "gpu"
	KindProject     = "project"
	KindRevision    = "revision"

	ConditionTypeConnected   = "Connected"
	ConditionTypeInitialized = "Initialized"
	ConditionTypeInstalled   = "Installed"
	ConditionTypeHealthy     = "Healthy"
	ConditionTypeReady       = "Ready"
	ConditionTypeConfigured  = "Configured"
	ConditionTypeRun         = "Run"

	ConditionStatusTrue  = "True"
	ConditionStatusFalse = "False"

	EventActionInstall       = "Install"
	EventActionConfigure     = "Configure"
	EventActionUninstall     = "Uninstall"
	EventActionHealthCheck   = "HealthCheck"
	EventActionUpgrade       = "Upgrade"
	EventActionRevert        = "Revert"
	EventActionLabel         = "Label"
	EventActionUnLabel       = "UnLabel"
	EventActionConnect       = "Connect"
	EventActionInitial       = "Initial"
	EventActionUninstallNode = "UninstallNode"
	EventActionInstallNode   = "InstallNode"

	FinalizerCleanRefJob       = "CleanRefJob"
	FinalizerCleanJobWorkDir   = "CleanJobWorkDir"
	FinalizerCleanRefGPU       = "CleanRefGPU"
	FinalizerReleaseRefGPU     = "ReleaseRefGPU"
	FinalizerCleanRefEvent     = "CleanRefEvent"
	FinalizerCleanRefConfigMap = "CleanRefConfigMap"
	FinalizerCleanRevision     = "CleanRevision"
	FinalizerCleanHostPlugin   = "CleanHostPlugin"

	JobExecTypeAnsible         = "ansible"
	JobDefaultFailureThreshold = 1
	JobDefaultTimeoutSeconds   = 3600

	PhaseRunning       = "Running"
	PhaseInitialing    = "Initialing"
	PhaseInstalling    = "Installing"
	PhaseUninstalling  = "Uninstalling"
	PhaseWaiting       = "Waiting"
	PhaseFailed        = "Failed"
	PhaseDeleting      = "Deleting"
	PhaseBound         = "Bound"
	PhaseCompleted     = "Completed"
	PhaseConfiguring   = "Configuring"
	PhaseUpgrading     = "Upgrading"
	PhaseReverting     = "Reverting"
	PhaseConnecting    = "Connecting"
	PhaseCrashing      = "Crashing"
	PhaseReady         = "Ready"
	PhaseNotReady      = "NotReady"
	PhaseInstalled     = "Installed"
	PhaseUninstalled   = "Uninstalled"
	PhaseLabel         = "Label"
	PhaseUnLabel       = "UnLabel"
	PhaseUninstallNode = "UninstallNode"
	PhaseInCompleted   = "InstallCompleted"
	PhaseUnCompleted   = "UninstallCompleted"

	PkgProvisionFull = "full"
	PkgProvisionThin = "thin"

	ValidNameRegex = `^[a-zA-Z0-9_\-\.]{1,256}$`
)

Variables

This section is empty.

Functions

func DeepCopy

func DeepCopy(src, dest interface{}) error

DeepCopy 深度复制两个对象,src和dest必须是引用传递类型如指针,切片或字典

func GetActionMsg

func GetActionMsg(action string) string

GetActionMsg 根据行为类型获取其简称,在行为类型不存在的情况下返回行为描述

func GetCategoryMsg

func GetCategoryMsg(category string) string

GetCategoryMsg 根据应用分类获取其简称

func GetKindMsg

func GetKindMsg(kind string) string

GetKindMsg 根据资源类型获取其简称,在资源类型不存在的情况下返回类型描述

func GetPlural

func GetPlural(kind string) string

func GetSingular

func GetSingular(kind string) string

func SearchKind

func SearchKind(keyword string) string

SearchKind 根据字符串查询资源类型

Types

type ApiObject

type ApiObject interface {
	JSONMarshaler
	YAMLMarshaler

	MetadataGetter
	MetadataSetter
	MetaTypeGetter
	SpecHasher
	ConditionResetter
	Versioner

	GetKey() string
	SetNamespace(string)
	SetName(string)
	GetGVK() GVK
	SetGVK(gvk GVK)
	GetStatus() Status
	SetStatus(Status)
	SetStatusPhase(string)
	GetStatusPhase() string

	Sha256() string
	DeepCopyApiObject() ApiObject
}

type ApiObjectAction

type ApiObjectAction struct {
	Type string
	Obj  ApiObject
}

type ApiObjectList

type ApiObjectList []ApiObject

type BaseApiObj

type BaseApiObj struct {
	MetaType `json:",inline" yaml:",inline"`
	BaseObj  `json:",inline" yaml:",inline"`
}

func (BaseApiObj) GetGVK

func (o BaseApiObj) GetGVK() GVK

func (BaseApiObj) GetKey

func (o BaseApiObj) GetKey() string

func (BaseApiObj) GetMetaType

func (o BaseApiObj) GetMetaType() MetaType

func (*BaseApiObj) Init

func (o *BaseApiObj) Init(apiVersion string, kind string)

func (*BaseApiObj) SetGVK

func (o *BaseApiObj) SetGVK(gvk GVK)

type BaseObj

type BaseObj struct {
	Metadata Metadata
	Status   Status
}

func (BaseObj) GetMetadata

func (o BaseObj) GetMetadata() Metadata

func (*BaseObj) GetStatus

func (o *BaseObj) GetStatus() Status

func (BaseObj) GetStatusPhase

func (o BaseObj) GetStatusPhase() string

func (*BaseObj) Init

func (o *BaseObj) Init()

Init 初始化基础对象

func (*BaseObj) RaiseVersion

func (o *BaseObj) RaiseVersion()

func (*BaseObj) ResetConditions

func (o *BaseObj) ResetConditions()

func (*BaseObj) SetCreateTime

func (o *BaseObj) SetCreateTime(time time.Time)

func (*BaseObj) SetMetadata

func (o *BaseObj) SetMetadata(m Metadata)

func (*BaseObj) SetName

func (o *BaseObj) SetName(name string)

func (*BaseObj) SetNamespace

func (o *BaseObj) SetNamespace(namespace string)

func (*BaseObj) SetStatus

func (o *BaseObj) SetStatus(status Status)

func (*BaseObj) SetStatusPhase

func (o *BaseObj) SetStatusPhase(phase string)

func (*BaseObj) SetUpdateTime

func (o *BaseObj) SetUpdateTime(time time.Time)

type BaseRuntimeObj

type BaseRuntimeObj struct {
	BaseObj `json:",inline" yaml:",inline"`
}

type Condition

type Condition struct {
	Type               string
	Status             string
	LastTransitionTime time.Time
}

type ConditionResetter

type ConditionResetter interface {
	ResetConditions()
}

type ConfigMapKeyRef

type ConfigMapKeyRef struct {
	Name string
	Key  string
}

type Conversion

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

Conversion 结构转换方法注册器

func NewConversion

func NewConversion() Conversion

func (*Conversion) GetConversionFunc

func (c *Conversion) GetConversionFunc(srcGVK GVK, dstGVK GVK) (ConvertFunc, bool)

func (*Conversion) SetConversionFunc

func (c *Conversion) SetConversionFunc(srcGVK GVK, dstGVK GVK, convertFunc ConvertFunc)

type ConvertByBytesFunc

type ConvertByBytesFunc func(srcObjBytes []byte, dstGVK GVK) (ApiObject, error)

type ConvertFunc

type ConvertFunc func(srcObj ApiObject, dstGVK GVK) (ApiObject, error)

type GK

type GK struct {
	Group string
	Kind  string
}

GK Group Kind简称

type GVK

type GVK struct {
	Group      string
	ApiVersion string
	Kind       string
}

GVK Group Version Kind简称

type JSONMarshaler

type JSONMarshaler interface {
	ToJSON() ([]byte, error)
	FromJSON([]byte) error
}

type MetaType

type MetaType struct {
	Kind       string
	ApiVersion string
}

type MetaTypeGetter

type MetaTypeGetter interface {
	GetMetaType() MetaType
}

type Metadata

type Metadata struct {
	Name            string
	Namespace       string `json:",omitempty" yaml:",omitempty"`
	Uid             string
	Labels          map[string]string
	Annotations     map[string]string
	ResourceVersion int
	CreateTime      time.Time
	UpdateTime      time.Time
	Finalizers      []string
}

func (Metadata) CopyTo

func (m Metadata) CopyTo(dest *Metadata)

func (Metadata) GetKey

func (m Metadata) GetKey(kind string, namespaced bool) string

func (*Metadata) Init

func (m *Metadata) Init()

type MetadataGetter

type MetadataGetter interface {
	GetMetadata() Metadata
}

type MetadataSetter

type MetadataSetter interface {
	SetMetadata(Metadata)
	SetCreateTime(time.Time)
	SetUpdateTime(time.Time)
}

type NewByGVKFunc

type NewByGVKFunc func(gvk GVK) (ApiObject, error)

type OpOpt

type OpOpt func(o *Option)

func WhenSpecChanged

func WhenSpecChanged() OpOpt

func WithAllFields

func WithAllFields() OpOpt

func WithFinalizer

func WithFinalizer() OpOpt

func WithSync

func WithSync() OpOpt

type Option

type Option struct {
	WithFinalizer   bool
	WithSync        bool
	WithAllFields   bool
	WhenSpecChanged bool
}

func (*Option) SetupOption

func (o *Option) SetupOption(opts ...OpOpt)

type RuntimeObject

type RuntimeObject interface {
	MetadataGetter
}

type SortByCreateTime

type SortByCreateTime ApiObjectList

func (SortByCreateTime) Len

func (s SortByCreateTime) Len() int

func (SortByCreateTime) Less

func (s SortByCreateTime) Less(i, j int) bool

func (SortByCreateTime) Swap

func (s SortByCreateTime) Swap(i, j int)

type SortByRevision

type SortByRevision ApiObjectList

func (SortByRevision) Len

func (s SortByRevision) Len() int

func (SortByRevision) Less

func (s SortByRevision) Less(i, j int) bool

func (SortByRevision) Swap

func (s SortByRevision) Swap(i, j int)

type SpecHasher

type SpecHasher interface {
	SpecEncode() ([]byte, error)
	SpecDecode([]byte) error
	SpecHash() string
}

type Status

type Status struct {
	Conditions []Condition
	Phase      string
}

func NewStatus

func NewStatus() Status

func (*Status) GetCondition

func (s *Status) GetCondition(condType string) string

GetCondition 获取状态

func (*Status) SetCondition

func (s *Status) SetCondition(condType string, condStatus string)

SetCondition 设置状态

func (*Status) UnsetCondition

func (s *Status) UnsetCondition(condType string)

UnsetCondition 移除状态

type VK

type VK struct {
	ApiVersion string
	Kind       string
}

VK Version Kind简称

type ValueFrom

type ValueFrom struct {
	ConfigMapKeyRef ConfigMapKeyRef
}

type Versioner

type Versioner interface {
	RaiseVersion()
}

type YAMLMarshaler

type YAMLMarshaler interface {
	ToYAML() ([]byte, error)
	FromYAML([]byte) error
}

Jump to

Keyboard shortcuts

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