common

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Default = "Default"

	NodeStatusReady int = iota
	NodeStatusError
	NodeStatusFreeze
)

Variables

View Source
var (
	ResourceNormal  UsageStatusEnum = "normal"
	ResourceSuccess UsageStatusEnum = "Success"
	ResourceError   UsageStatusEnum = "error"
	ResourceWarning UsageStatusEnum = "warning"
	ResourceDanger  UsageStatusEnum = "danger"

	Asc  OrderEnum = "ascend"
	Desc OrderEnum = "descend"

	Deployments  WorkflowEnum = "Deployments"
	StatefulSets WorkflowEnum = "StatefulSets"
	DaemonSets   WorkflowEnum = "DaemonSets"
	Jobs         WorkflowEnum = "Jobs"
	CronJobs     WorkflowEnum = "CronJobs"

	// cmp bashboard table
	CMPDashboardChangePageNoOperationKey   cptype.OperationKey = "changePageNo"
	CMPDashboardChangePageSizeOperationKey cptype.OperationKey = "changePageSize"
	CMPDashboardSortByColumnOperationKey   cptype.OperationKey = "changeSort"

	// cmp bashboard clusterFilter
	CMPDashboardFilterOperationKey cptype.OperationKey = "filter"

	// Freeze Button
	CMPDashboardDeleteNode   cptype.OperationKey = "delete"
	CMPDashboardUnfreezeNode cptype.OperationKey = "unfreeze"
	CMPDashboardFreezeNode   cptype.OperationKey = "freeze"
)
View Source
var (
	PodNotFoundErr            = errors.New("pod not found")
	OperationsEmptyErr        = errors.New("operation is empty")
	ResourceEmptyErr          = errors.New("node resource is empty")
	ProtocolComponentEmptyErr = errors.New("component is nil or property empty")
	BundleEmptyErr            = errors.New("bundle is empty")
	NothingToBeDoneErr        = errors.New("nothing to be done")

	TypeNotAvailableErr = errors.New("type not available")
	ResourceNotFoundErr = errors.New("resource type not available")

	//util error
	PtrRequiredErr = errors.New("ptr is required")
)

Functions

func ConvertToMap

func ConvertToMap(obj interface{}) (map[string]interface{}, error)

ConvertToMap transfer any struct to map

func GetInt64Len

func GetInt64Len(a int64) int

func GetPercent

func GetPercent(a, b float64) int

func ResetNumberBase

func ResetNumberBase(a, b float64) (float64, float64)
ResetNumberBase

* e.g. : 20 100 to 2 10 , 0.1 1000 to 1 10000

func SortByDistribution

func SortByDistribution(data []interface{}, sortColumn string, order OrderEnum)

SortByDistribution sort by percent

func SortByNode

func SortByNode(data []interface{}, sortColumn string, order OrderEnum)

SortByNode sort by node struct

func SortByString

func SortByString(data []interface{}, sortColumn string, order OrderEnum)

SortByString sort by string value

func SurviveTime

func SurviveTime(startTime string) (string, error)

func Transfer

func Transfer(a, b interface{}) error

Transfer transfer a to b with json, kind of b must be pointer

Types

type ChartDataItem

type ChartDataItem struct {
	Value float64 `json:"value"`
	Time  int64   `json:"time"`
}

type OrderEnum

type OrderEnum string

type SteveStatus

type SteveStatus struct {
	Value      SteveStatusEnum `json:"value,omitempty"`
	RenderType string          `json:"renderType"`
	Status     SteveStatusEnum `json:"status"`
	Tip        string          `json:"tip"`
}

type SteveStatusEnum

type SteveStatusEnum string

type UsageStatusEnum

type UsageStatusEnum string

type WorkflowEnum

type WorkflowEnum string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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