manager

package
v0.0.0-...-db75b6a Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentType      = "Content-Type"
	ContentTypePlain = "text/plain"
	ContentTypeHTML  = "text/html"
	ContentTypeJSON  = "application/json"
)
View Source
const (
	SEALOS                         Source  = "Sealos Cloud"
	ErrorLicenseTitle              Title   = "License Activation Failed"
	InvalidLicenseTitle            Title   = "Invalid License"
	UnKnownErrorOfLicense          Title   = "UnKnown error about license"
	ValidLicenseTitle              Title   = "License Activated"
	RechargeFailedTitle            Title   = "Recharge failed"
	DuplicateLicenseTitle          Title   = "Duplicate License"
	RegistrationSuccessTitle       Title   = "Registration Success"
	InvalidLicenseContent          Message = "The provided license is invalid. Please check and try."
	ErrorLicenseTitleContent       Message = "License delivery encountered an unexpected error. Please ensure your cluster is operating normally..."
	UnKnownErrorOfLicenseCotentent Message = "" /* 144-byte string literal not displayed */
	LicenseTimeOutContent          Message = "The provided license has expired. Please check and try."
	ValidLicenseContent            Message = "Your license has been successfully activated and is ready to use. Enjoy your experience!"
	DuplicateLicenseContent        Message = "The provided license has already been used. Please use a different license."
	RegistrationSuccessContent     Message = "Congratulations! You have successfully registered. Welcome aboard!"
	RechargeFailedContent          Message = "Your license failed to recharge."
)
View Source
const (
	TRUE  = "true"
	FALSE = "false"
)
View Source
const (
	UserPrefix string = "ns-"
	AdmPrefix  string = "adm-"
)
View Source
const BaseCount = 1000000
View Source
const MaxSizeThresholdStr = "800Ki"
View Source
const Memory = "memory"
View Source
const (
	NetWorkEnv string = "CAN_CONNECT_TO_EXTERNAL_NETWORK"
)

Variables

This section is empty.

Functions

func AsyncCloudTask

func AsyncCloudTask(wg *sync.WaitGroup, errChannel chan error, tk Task)

func Convert

func Convert(body []byte, content interface{}) error

func IsConfigMapChanged

func IsConfigMapChanged(expect Config, cm *corev1.ConfigMap) bool

func IsSuccessfulStatusCode

func IsSuccessfulStatusCode(statusCode int) bool

func LicenseCheckOnExternalNetwork

func LicenseCheckOnExternalNetwork(license cloudv1.License, secret corev1.Secret, url string, logger logr.Logger) (map[string]interface{}, bool)

func LicenseCheckOnInternalNetwork

func LicenseCheckOnInternalNetwork(license cloudv1.License) (map[string]interface{}, bool)

func NotificationPackageToNotification

func NotificationPackageToNotification(pack NotificationPackage) ntf.Notification

func NotificationResponseToNotification

func NotificationResponseToNotification(resp NotificationResponse) ntf.Notification

Types

type ClusterInfo

type ClusterInfo struct {
	UID string `json:"uid"`
	Key string `json:"key"`
}

type ClusterResource

type ClusterResource struct {
	Nodes  string `json:"nodes"`
	CPU    string `json:"cpu"`
	GPU    string `json:"gpu"`
	Memory string `json:"memery"`
	Disk   string `json:"disk"`
}

func NewClusterResource

func NewClusterResource() ClusterResource

type CollectorInfo

type CollectorInfo struct {
	UID             string            `json:"uid"`
	InfoType        TypeInfo          `json:"infoType"`
	DailyUsage      DailyClusterUsage `json:"dailyUsage,omitempty"`
	ClusterResource ClusterResource   `json:"clusterResource,omitempty"`
}

type Config

type Config struct {
	CollectorURL      string `json:"CollectorURL"`
	NotificationURL   string `json:"NotificationURL"`
	RegisterURL       string `json:"RegisterURL"`
	CloudSyncURL      string `json:"CloudSyncURL"`
	LicenseMonitorURL string `json:"LicenseMonitorURL"`
}

type ConvertOptions

type ConvertOptions interface {
	// contains filtered or unexported methods
}

type DailyClusterUsage

type DailyClusterUsage struct {
	Date          Date      `json:"date"`
	TotalUsageFee float64   `json:"totalUsageFee"`
	HourlyUsage   []float64 `json:"hourlyUsage"`
}

type Date

type Date string

func (Date) MarshalJSON

func (d Date) MarshalJSON() ([]byte, error)

func (*Date) UnmarshalJSON

func (d *Date) UnmarshalJSON(data []byte) error

type HTTPBody

type HTTPBody struct {
	ContentType string
	StatusCode  int
	Body        []byte
}

type HTTPResponse

type HTTPResponse struct {
	ContentType string
	StatusCode  int
	Body        []byte
}

func CommunicateWithCloud

func CommunicateWithCloud(method string, url string, content interface{}) (HTTPResponse, error)

type Label

type Label string
const (
	ExternalNetworkAccessLabel Label = "external-network-access"
	IsDisabled                 Label = "isDisabled"
	IsRead                     Label = "isRead"
	Enabled                    Label = "enabled"
	Disabled                   Label = "disabled"
)

type License

type License struct {
	Token       string `json:"token"`
	Description string `json:"description"`
}

type LicenseMonitorRequest

type LicenseMonitorRequest struct {
	UID   string `json:"uid"`
	Token string `json:"token"`
}

func NewLicenseMonitorRequest

func NewLicenseMonitorRequest(secret corev1.Secret, license cloudv1.License) LicenseMonitorRequest

type LicenseMonitorResponse

type LicenseMonitorResponse struct {
	Key string `json:"key"`
}

type Message

type Message string

type NotificationManager

type NotificationManager struct {
	TimeLastPull int64
}

func NewNotificationManager

func NewNotificationManager() *NotificationManager

func (*NotificationManager) InitTime

func (nm *NotificationManager) InitTime()

type NotificationPackage

type NotificationPackage struct {
	Name    string
	Title   Title
	From    Source
	Message Message
}

func NewNotificationPackage

func NewNotificationPackage(title Title, from Source, message Message) NotificationPackage

type NotificationRequest

type NotificationRequest struct {
	UID       string `json:"uid"`
	Timestamp int64  `json:"timestamp"`
}

type NotificationResponse

type NotificationResponse struct {
	ID        string `json:"_id"`
	Type      string `json:"msgType"`
	Title     string `json:"title"`
	Message   string `json:"message"`
	Timestamp int64  `json:"timestamp"`
}

type NotificationTask

type NotificationTask struct {
	Target            string
	NotificationCache []ntf.Notification
	// contains filtered or unexported fields
}

func NewNotificationTask

func NewNotificationTask(ctx context.Context, client cl.Client, target string, cache []ntf.Notification) NotificationTask

func (*NotificationTask) Run

func (nt *NotificationTask) Run() error

type PolicyAction

type PolicyAction string

type Resource

type Resource string
const (
	Namespace       Resource = "cloud-system"
	LicenseHistory  Resource = "cloud-license-history"
	LicenseName     Resource = "license"
	SecretName      Resource = "cloud-secret"
	ConfigName      Resource = "cloud-config"
	CloudStartName  Resource = "cloud-start"
	ClientStartName Resource = "client-start"
)

type Set

type Set interface {
	Add(item string)
	Remove(item string)
	Contains(item string) bool
	Iter() <-chan string
}

type Source

type Source string

type StringSet

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

func NewStringSet

func NewStringSet() *StringSet

func (*StringSet) Add

func (s *StringSet) Add(item string)

func (*StringSet) Contains

func (s *StringSet) Contains(item string) bool

func (*StringSet) Iter

func (s *StringSet) Iter() <-chan string

func (*StringSet) Remove

func (s *StringSet) Remove(item string)

type SyncRequest

type SyncRequest struct {
	UID string `json:"uid"`
}

type SyncResponse

type SyncResponse struct {
	Config `json:",inline"`
	Key    string `json:"key"`
}

type Target

type Target string
const (
	ToUser Target = "user"
	ToAdm  Target = "adm"
)

type Task

type Task interface {
	Run() error
}

type Title

type Title string

type TotalNodesResource

type TotalNodesResource struct {
	TotalPVCapacity resource.Quantity
	TotalMemory     resource.Quantity
	TotalCPU        resource.Quantity
	TotalGPU        resource.Quantity
	// contains filtered or unexported fields
}

func NewTotalNodesResource

func NewTotalNodesResource(regexpStr string) TotalNodesResource

func (*TotalNodesResource) GetGPUCPUMemoryResource

func (tnr *TotalNodesResource) GetGPUCPUMemoryResource(node *corev1.Node, wg *sync.WaitGroup)

type TypeInfo

type TypeInfo string
const (
	ResourceOnCluster TypeInfo = "ClusterResource"
	DailyUsage        TypeInfo = "DailyUsage"
)

type UserCategory

type UserCategory map[string]Set

func (UserCategory) Add

func (uc UserCategory) Add(prefix string, nsName string)

func (*UserCategory) GetNameSpace

func (uc *UserCategory) GetNameSpace(ctx context.Context, client cl.Client) error

type Users

type Users interface {
	Add(prefix string, nsName string)
}

Jump to

Keyboard shortcuts

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