Documentation ¶
Index ¶
- Constants
- Variables
- func BuildForRunnable(ctx context.Context, client client.Client, options Options) []manager.Runnable
- func CheckLicenseExists(dbCol LicenseDB, uid string, token string) (bool, error)
- func ContainsFields(data map[string]interface{}, fields ...string) bool
- func Convert(body []byte, content interface{}) error
- func GetConfigFromConfigMap(expectName string, configMap *corev1.ConfigMap) (map[string]string, error)
- func GetUID(ctx context.Context, client client.Client) (string, error)
- func GetUIDURL(ctx context.Context, client client.Client) (string, map[string]string, error)
- func GetURL(ctx context.Context, client client.Client) (map[string]string, error)
- func GetYesterdayAndTodayMidnight() (time.Time, time.Time)
- func InterfaceToInt64(value interface{}) (int64, error)
- func IsConfigMapChanged(expect map[string]string, cm *corev1.ConfigMap) bool
- func IsLicenseValid(license issuerv1.License) (map[string]interface{}, bool)
- func IsSuccessfulStatusCode(statusCode int) bool
- func LicenseCheckOnExternalNetwork(ctx context.Context, client client.Client, license issuerv1.License) (map[string]interface{}, bool)
- func LicenseCheckOnInternalNetwork(license issuerv1.License) (map[string]interface{}, bool)
- func Once(_ context.Context, _ time.Duration, t Task) error
- func OnceWithProbe(ctx context.Context, period time.Duration, t Task) error
- func Periodic(ctx context.Context, period time.Duration, t Task) error
- func PeriodicWithProbe(ctx context.Context, period time.Duration, t Task) error
- func Push(url string, content interface{}) error
- func RechargeByLicense(ctx context.Context, client client.Client, account accountv1.Account, ...) error
- func RecordLicense(dbCol LicenseDB, license License) error
- type ClusterResource
- type Collect
- type CollectorInfo
- type Config
- type DBOptions
- type DailyClusterUsage
- type DataSycn
- type Date
- type EnvOptions
- type FilterFunc
- type Flag
- type HTTPBody
- type HTTPResponse
- type HashMap
- type InitProbe
- type InitTask
- type License
- type LicenseDB
- type LicenseMonitorRequest
- type LicenseMonitorResponse
- type LicenseResult
- type Map
- type Memory
- type MemoryClean
- type MongoOptions
- type NetWorkOptions
- type NetworkConfig
- type NetworkProbe
- type NoticeCleaner
- type NoticeWork
- type NotificationRequest
- type NotificationResponse
- type OperatorOptions
- func (o *OperatorOptions) GetDBOptions() DBOptions
- func (o *OperatorOptions) GetDefaultPeriod() time.Duration
- func (o *OperatorOptions) GetEnvOptions() EnvOptions
- func (o *OperatorOptions) GetNetWorkOptions() NetWorkOptions
- func (o *OperatorOptions) GetPeriod(tkname task) time.Duration
- func (o *OperatorOptions) GetPolicy(tkname task) string
- func (o *OperatorOptions) GetRunnableOptions() RunnableOptions
- func (o *OperatorOptions) SetNetworkConfig(flag bool)
- type Options
- type OptionsReadOnly
- type OptionsReadWrite
- type Probe
- type Reader
- type RegisterProbe
- type RegisterRequest
- type RegisterWork
- type RunnableOptions
- type SyncRequest
- type SyncResponse
- type Task
- type TaskFunc
- type TaskInstance
- type TaskPool
- type TotalNodesResource
- type TypeInfo
Constants ¶
const ( // SealosNamespace = "sealos-system" ClusterInfo = "cluster-info" URLConfig = "url-config" LicenseHistory = "license-history" LicenseName = "license" )
const ( ContentType = "Content-Type" ContentTypePlain = "text/plain" ContentTypeHTML = "text/html" ContentTypeJSON = "application/json" )
const ( CollectorURL = "CollectorURL" NotificationURL = "NotificationURL" RegisterURL = "RegisterURL" CloudSyncURL = "CloudSyncURL" LicenseMonitorURL = "LicenseMonitorURL" NetworkProbeURL = "NetworkProbeURL" )
const ( Sealos string = "Sealos Cloud" ClusterCapacityNoticeTitle string = "Attention: Cluster Capacity Alert" LicenseNoticeTitle string = "Attention: License Issue" InvalidLicenseMessage string = "The license provided appears to be invalid. Please verify and try again." ExpiredLicenseMessage string = "The license provided has expired. Please renew and try again." ValidLicenseMessage string = "Your license has been successfully activated and is now ready for use. Enjoy your Sealos experience!" DuplicateLicenseMessage string = "The license provided has already been activated. Please use a different license." RechargeFailedMessage string = "License recharge operation failed." )
const ( CreatTimeField = "iat" AmountField = "amt" NodeField = "nod" CPUField = "cpu" DurationField = "tte" AddNodeField = "and" AddCPUField = "adc" )
const ( PeriodicPolicy = "Periodic" PeriodicWithProbePolicy = "PeriodicWithProbe" OncePolicy = "Once" OnceWithProbePolicy = "OnceWithProbe" )
const ( Collector task = "Collector" DataSync task = "DataSync" Init task = "Init" Register task = "Register" Notice task = "Notice" NoticeCleanup task = "NoticeCleanup" NetWorkConfig task = "NetWorkConfig" MemoryCleanup task = "MemoryCleanup" )
const DefaultColForLicense = "license"
const MaxRetryForConnectDB = 5
const NoticeFrom = "Sealos Cloud"
Variables ¶
var Key = "asdhjkwqdaskdjhqjwdakxausdasdajs"
Functions ¶
func BuildForRunnable ¶
func BuildForRunnable(ctx context.Context, client client.Client, options Options) []manager.Runnable
This file provided a framework which can be used to build a runnable task. With this framework, developers can easily build a runnable task and add it to the manager.
func CheckLicenseExists ¶
func ContainsFields ¶
func GetConfigFromConfigMap ¶
func InterfaceToInt64 ¶
func IsConfigMapChanged ¶
func IsSuccessfulStatusCode ¶
func OnceWithProbe ¶
OnceWithProbe func is used to run a task only once.
func PeriodicWithProbe ¶
func Push ¶
The Push method is used to handle one-way interaction, that is, there is no need to obtain information from the cloud, only need to send information to the cloud.
func RechargeByLicense ¶
func RecordLicense ¶
Types ¶
type ClusterResource ¶
type Collect ¶
type Collect struct { ClusterResource ClusterResource DailyClusterUsage DailyClusterUsage CollectorInfo CollectorInfo // contains filtered or unexported fields }
func NewCollect ¶
func NewCollect(o OptionsReadOnly) *Collect
type CollectorInfo ¶
type CollectorInfo struct { UID string `json:"uid"` InfoType TypeInfo `json:"infoType"` DailyUsage DailyClusterUsage `json:"dailyUsage,omitempty"` ClusterResource ClusterResource `json:"clusterResource,omitempty"` }
type DBOptions ¶
type DBOptions struct { // The MongoOptions is used to store options for the MongoDB database. MongoOptions MongoOptions }
type DailyClusterUsage ¶
type EnvOptions ¶
type EnvOptions struct { // The MongoURI is used to connect to the MongoDB database. MongoURI string // The SaltKey is used to encrypt the password for pre-registered users. SaltKey string // Namespace Namespace string }
The EnvOptions is used to store environment variables.
type FilterFunc ¶
type HTTPResponse ¶
func CommunicateWithCloud ¶
func CommunicateWithCloud(method string, url string, content interface{}) (HTTPResponse, error)
func Get ¶
func Get(url string) (HTTPResponse, error)
The Get method is used to handle "GET" request.
func Pull ¶
func Pull(url string, content interface{}) (HTTPResponse, error)
The Pull method is used to handle two-way interaction, that is, there is a need to obtain information from the cloud, and then send information to the cloud.
type HashMap ¶
type HashMap[T comparable] struct { // contains filtered or unexported fields }
type InitProbe ¶
type InitProbe interface { Probe Completed() }
func GetInitProbe ¶
func GetInitProbe() InitProbe
type InitTask ¶
type InitTask struct {
// contains filtered or unexported fields
}
The following code is used to implement the instance of sub-task which is used to initialize the cluster uuid and preset root user for mongoDB
func NewInitTask ¶
func NewInitTask(o OptionsReadOnly) *InitTask
type License ¶
type LicenseDB ¶
type LicenseDB interface { Record(license License) error QueryByUID(ns string, st int64, ed int64) ([]LicenseResult, error) IsExisted(uid string, token string) (bool, error) Disconnect() error }
func NewLicenseDB ¶
type LicenseMonitorRequest ¶
type LicenseMonitorResponse ¶
type LicenseMonitorResponse struct {
Key string `json:"key"`
}
type LicenseResult ¶
type LicenseResult struct {
License License `bson:"license"`
}
type MemoryClean ¶
func NewMemoryCleaner ¶
func NewMemoryCleaner() *MemoryClean
type MongoOptions ¶
type NetWorkOptions ¶
type NetWorkOptions struct { // EnableExternalNetWork is used to distinguish between // external and internal networks. EnableExternalNetWork bool }
type NetworkConfig ¶
type NetworkConfig struct {
// contains filtered or unexported fields
}
func NewNetworkConfig ¶
func NewNetworkConfig() *NetworkConfig
type NetworkProbe ¶
func GetNetworkProbe ¶
func GetNetworkProbe() NetworkProbe
type NoticeCleaner ¶
type NoticeCleaner struct {
// contains filtered or unexported fields
}
the NoticeCleaner task is used to clean the notification in the cluster periodically.
func NewNoticeCleaner ¶
func NewNoticeCleaner() *NoticeCleaner
type NoticeWork ¶
type NoticeWork struct {
// contains filtered or unexported fields
}
the NoticeWork task is used to get the notification from the cloud. And then send the notification to the cluster.
func NewNotice ¶
func NewNotice() *NoticeWork
type NotificationRequest ¶
type NotificationResponse ¶
type OperatorOptions ¶
type OperatorOptions struct { // The EnvOptions is used to store environment variables. EnvOptions EnvOptions // The DBOptions is used to store options for the database. DBOptions DBOptions // The RunnableOptions is used to store options for the Runnable instance RunnableOptions RunnableOptions // The NetWorkOptions is used to store options for the NetWork instance NetWorkOptions NetWorkOptions }
The OperatorOptions struct is used to make configuration options available to licenseissuer operators.
func NewOptions ¶
func NewOptions() *OperatorOptions
func (*OperatorOptions) GetDBOptions ¶
func (o *OperatorOptions) GetDBOptions() DBOptions
func (*OperatorOptions) GetDefaultPeriod ¶
func (o *OperatorOptions) GetDefaultPeriod() time.Duration
func (*OperatorOptions) GetEnvOptions ¶
func (o *OperatorOptions) GetEnvOptions() EnvOptions
func (*OperatorOptions) GetNetWorkOptions ¶
func (o *OperatorOptions) GetNetWorkOptions() NetWorkOptions
func (*OperatorOptions) GetPeriod ¶
func (o *OperatorOptions) GetPeriod(tkname task) time.Duration
func (*OperatorOptions) GetPolicy ¶
func (o *OperatorOptions) GetPolicy(tkname task) string
func (*OperatorOptions) GetRunnableOptions ¶
func (o *OperatorOptions) GetRunnableOptions() RunnableOptions
func (*OperatorOptions) SetNetworkConfig ¶
func (o *OperatorOptions) SetNetworkConfig(flag bool)
type Options ¶
type Options interface { OptionsReadOnly OptionsReadWrite }
A interface for options to implement read-only access.
type OptionsReadOnly ¶
type OptionsReadOnly interface { GetPolicy(name task) string GetPeriod(name task) time.Duration GetDefaultPeriod() time.Duration GetEnvOptions() EnvOptions GetNetWorkOptions() NetWorkOptions GetRunnableOptions() RunnableOptions GetDBOptions() DBOptions }
func GetOptionsReadOnly ¶
func GetOptionsReadOnly() OptionsReadOnly
GetOptionsReadOnly returns the singleton instance of OptionsReadOnly.
type OptionsReadWrite ¶
type OptionsReadWrite interface {
SetNetworkConfig(flag bool)
}
func GetOptionsReadWrite ¶
func GetOptionsReadWrite() OptionsReadWrite
GetOptionsReadWrite returns the singleton instance of OptionsReadWrite.
type Probe ¶
type Probe interface {
Probe() bool
}
Probe is an interface for a probe check
func ProbeFor ¶
func ProbeFor(taskType task) []Probe
ProbeFor return the Probe interface for the given task type
func ProbeForInit ¶
func ProbeForInit() Probe
func ProbeForNetWork ¶
func ProbeForNetWork() Probe
func ProbeForRegister ¶
func ProbeForRegister() Probe
type RegisterProbe ¶
func GetRegisterProbe ¶
func GetRegisterProbe() RegisterProbe
type RegisterRequest ¶
type RegisterRequest struct {
UID string `json:"uid"`
}
type RegisterWork ¶
type RegisterWork struct {
// contains filtered or unexported fields
}
func NewRegister ¶
func NewRegister() *RegisterWork
type RunnableOptions ¶
type RunnableOptions struct { // The Policy is configured the task of framework. // --> Once: The task is executed only once. // --> Periodic: The task is executed periodically. Policy map[task]string // The Period is configured the period of the task // if empty, use the default period. Period map[task]time.Duration DefaultPeriod time.Duration }
type SyncRequest ¶
type SyncRequest struct {
UID string `json:"uid"`
}
type SyncResponse ¶
type SyncResponse struct {
Config `json:",inline"`
}
type TaskInstance ¶
The TaskInstance struct is used to store the task information.
func (*TaskInstance) Log ¶
func (ti *TaskInstance) Log() *logr.Logger
func (*TaskInstance) Probe ¶
func (ti *TaskInstance) Probe() bool
func (*TaskInstance) Run ¶
func (ti *TaskInstance) Run() error