component

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RegisterFormat = "%s/%s"

	TypeStep              = "step"
	TypeTemplate          = "template"
	TypeRegistryConfigure = "registryConfigure"
)
View Source
const (
	JSONSchemaTypeObject = "object"
	JSONSchemaTypeBool   = "boolean"
	JSONSchemaTypeString = "string"
	JSONSchemaTypeArray  = "array"
	JSONSchemaTypeInt    = "number"
)
View Source
const (
	InternalCategoryNodes      = "nodes"
	InternalCategoryKubernetes = "kubernetes"
	InternalCategoryStorage    = "storage"
	InternalCategoryPAAS       = "PAAS"
	InternalCategoryLB         = "LB"
)
View Source
const (
	RegisterTemplateKeyFormat = "%s/%s/%s"
	RegisterStepKeyFormat     = "%s/%s/%s"
)
View Source
const OfflinePackagesKeyFormat = "%s-%s-%s"

Variables

View Source
var (
	ErrExist     = errors.New("component already exist")
	ErrKeyFormat = errors.New("component key must be name/version")
)
View Source
var (
	ErrStepExist     = errors.New("component already exist")
	ErrStepKeyFormat = errors.New("component key must be name/version")
)
View Source
var (
	ErrTemplateExist     = errors.New("component template already exist")
	ErrTemplateKeyFormat = errors.New("component template key must be name/version/templateName")
)

Functions

func AddI18nMessages

func AddI18nMessages(msgs I18nMessages) error

func GetExtraData

func GetExtraData(ctx context.Context) []byte

func GetLocalizer

func GetLocalizer(lang Lang) *i18n.Localizer

func GetOperationID

func GetOperationID(ctx context.Context) string

func GetRepoMirror

func GetRepoMirror(ctx context.Context) string

func GetRetry

func GetRetry(ctx context.Context) bool

func GetStepID

func GetStepID(ctx context.Context) string

func PropsMax

func PropsMax(i int) *int

func Register

func Register(kv string, p Interface) error

Register KV must format at componentName/version

func RegisterAgentStep

func RegisterAgentStep(kv string, p StepRunnable) error

RegisterAgentStep KV must format at componentName/version/stepName

func RegisterTemplate

func RegisterTemplate(kv string, t TemplateRender) error

func WithExtraData

func WithExtraData(ctx context.Context, data []byte) context.Context

func WithExtraMetadata

func WithExtraMetadata(ctx context.Context, metadata ExtraMetadata) context.Context

func WithOperationID

func WithOperationID(ctx context.Context, opID string) context.Context

func WithOplog

func WithOplog(ctx context.Context, ol OperationLogFile) context.Context

func WithRepoMirror

func WithRepoMirror(ctx context.Context, mirror string) context.Context

func WithRetry

func WithRetry(ctx context.Context, retry bool) context.Context

func WithStepID

func WithStepID(ctx context.Context, stepID string) context.Context

Types

type ExtraMetadata

type ExtraMetadata struct {
	Masters                   NodeList
	Workers                   NodeList
	ClusterStatus             v1.ClusterPhase
	Offline                   bool
	LocalRegistry             string
	CRI                       string
	ClusterName               string
	KubeVersion               string
	OperationID               string
	OperationType             string
	KubeletDataDir            string
	ControlPlaneStatus        []v1.ControlPlaneHealth
	Addons                    []v1.Addon
	CNI                       string
	CNINamespace              string
	OnlyInstallKubernetesComp bool
}

func GetExtraMetadata

func GetExtraMetadata(ctx context.Context) ExtraMetadata

func (ExtraMetadata) GetAllNodeIDs

func (e ExtraMetadata) GetAllNodeIDs() []string

func (ExtraMetadata) GetAllNodes

func (e ExtraMetadata) GetAllNodes() (nodes NodeList)

func (ExtraMetadata) GetAvailableMasterNodes added in v1.3.1

func (e ExtraMetadata) GetAvailableMasterNodes() []string

func (ExtraMetadata) GetMasterHostname

func (e ExtraMetadata) GetMasterHostname(id string) string

func (ExtraMetadata) GetMasterNodeClusterIP added in v1.4.0

func (e ExtraMetadata) GetMasterNodeClusterIP() map[string]string

func (ExtraMetadata) GetMasterNodeIDs

func (e ExtraMetadata) GetMasterNodeIDs() []string

GetMasterNodeIDs Deprecated. Use GetAvailableMasterNodes() instead

func (ExtraMetadata) GetMasterNodeIP

func (e ExtraMetadata) GetMasterNodeIP() map[string]string

func (ExtraMetadata) GetWorkerHostname

func (e ExtraMetadata) GetWorkerHostname(id string) string

func (ExtraMetadata) GetWorkerNodeClusterIP added in v1.4.0

func (e ExtraMetadata) GetWorkerNodeClusterIP() map[string]string

func (ExtraMetadata) GetWorkerNodeIDs

func (e ExtraMetadata) GetWorkerNodeIDs() []string

func (ExtraMetadata) GetWorkerNodeIP

func (e ExtraMetadata) GetWorkerNodeIP() map[string]string

func (ExtraMetadata) IsAllMasterAvailable added in v1.3.1

func (e ExtraMetadata) IsAllMasterAvailable() bool

type FuncIndex

type FuncIndex func() (key, value []byte, err error)

type HealthCheck

type HealthCheck interface {
	Ns() string
	Svc() string
	RequestPath() string
	Supported() bool
}

type I18nMessage

type I18nMessage struct {
	ID      string
	English string
	Chinese string
}

type I18nMessages

type I18nMessages []I18nMessage

type Interface

type Interface interface {
	ObjectMeta
	HealthCheck
	GetInstanceName() string
	// Object metadata
	GetComponentMeta(lang Lang) Meta
	// Component method
	GetDependence() []string
	RequireExtraCluster() []string
	CompleteWithExtraCluster(extra map[string]ExtraMetadata) error
	Validate() error
	InitSteps(ctx context.Context) error
	GetInstallSteps() []v1.Step
	GetUninstallSteps() []v1.Step
	GetUpgradeSteps() []v1.Step
	GetImageRepoMirror() string
}

func Load

func Load(kv string) (Interface, bool)

type JSON

type JSON interface{}

JSON represents any valid JSON value. These types are supported: bool, int64, float64, string, []interface{}, map[string]interface{} and nil.

type JSONSchemaProps

type JSONSchemaProps struct {
	Title        string                     `json:"title"`
	Properties   map[string]JSONSchemaProps `json:"properties,omitempty"`
	Type         string                     `json:"type,omitempty"`
	Mask         bool                       `json:"mask,omitempty"`
	Default      JSON                       `json:"default,omitempty"`
	Description  string                     `json:"description,omitempty"`
	Required     []string                   `json:"required,omitempty"`
	Items        *JSONSchemaProps           `json:"items,omitempty"`
	Enum         []JSON                     `json:"enum,omitempty"`
	EnumNames    []string                   `json:"enumNames,omitempty"`
	Dependencies []string                   `json:"dependencies,omitempty"`
	Priority     int                        `json:"priority,omitempty"`
	Props        *Props                     `json:"props,omitempty"`
}

type Lang

type Lang string
const (
	English Lang = "en"
	Chinese Lang = "zh"
)

type Meta

type Meta struct {
	Title          string           `json:"title"`
	Description    string           `json:"description"`
	Icon           string           `json:"icon"`
	Unique         bool             `json:"unique"`
	Template       bool             `json:"template"`
	Category       string           `json:"category"`
	Deprecated     bool             `json:"deprecated"`
	Name           string           `json:"name"`
	Version        string           `json:"version"`
	Dependence     []string         `json:"dependence"`
	TimeoutSeconds int              `json:"timeoutSeconds"`
	Priority       int              `json:"priority,omitempty"`
	Schema         *JSONSchemaProps `json:"schema"`
}

func GetJSONSchemas

func GetJSONSchemas(selector labels.Selector, lang Lang) []Meta

type Node

type Node struct {
	ID       string
	IPv4     string
	NodeIPv4 string
	Region   string
	Hostname string
	Role     string
	Disable  bool
}

type NodeList

type NodeList []Node

func (NodeList) AvailableKubeMasters added in v1.4.0

func (l NodeList) AvailableKubeMasters() (NodeList, error)

func (NodeList) GetNodeIDs

func (l NodeList) GetNodeIDs() (nodes []string)

func (NodeList) ReachableNodes added in v1.4.0

func (l NodeList) ReachableNodes(protocol string, port int, timeout time.Duration) NodeList

type ObjectMeta

type ObjectMeta interface {
	NewInstance() ObjectMeta
}

type OfflinePackages

type OfflinePackages map[string][]string

OfflinePackages key must format as version-osVendor-osArch value is packages eg for docker 19.03, docker-19.03-centos7-x86_64

type OperationLogFile

type OperationLogFile interface {
	GetRootDir() string
	CreateOperationDir(opID string) error
	GetOperationDir(opID string) (path string, err error)
	CreateStepLogFile(opID, stepID string) (file *os.File, err error)
	GetStepLogFile(opID, stepID string) (path string, err error)
	GetStepLogContent(opID, stepID string, offset int64, length int) (content []byte, deliverySize int64, logSize int64, err error)
	CreateStepLogFileAndAppend(opID, stepID string, data []byte) error
	TruncateStepLogFile(opID, stepID string) error
}

func GetOplog

func GetOplog(ctx context.Context) OperationLogFile

type Options

type Options struct {
	DryRun bool
}

type Props

type Props struct {
	Min int  `json:"min"`
	Max *int `json:"max,omitempty"`
}

type Runnable

type Runnable interface {
	Install(ctx context.Context, opts Options) ([]byte, error)
	Uninstall(ctx context.Context, opts Options) ([]byte, error)
}

type StepRunnable

type StepRunnable interface {
	Runnable
	ObjectMeta
}

func LoadAgentStep

func LoadAgentStep(kv string) (StepRunnable, bool)

type TemplateRender

type TemplateRender interface {
	Render(ctx context.Context, opts Options) error
	ObjectMeta
}

func LoadTemplate

func LoadTemplate(kv string) (TemplateRender, bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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