cputil

package
v1.3.0-rc.0...-d217119 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProjectsDisplayNameCache = "projectDisplayName"
	NamespacesCache          = "allNamespaces"
)

Variables

View Source
var PodStatus = map[string]string{
	"Completed":         "success",
	"ContainerCreating": "processing",
	"CrashLoopBackOff":  "error",
	"Error":             "error",
	"Evicted":           "default",
	"ImagePullBackOff":  "error",
	"ErrImagePull":      "error",
	"Pending":           "processing",
	"Running":           "success",
	"Terminating":       "processing",
	"OOMKilled":         "error",
}

PodStatus is a map of pod status to normal status

Functions

func CalculateNodeRes

func CalculateNodeRes(node data.Object, allocatedCPU, allocatedMem, allocatedPods int64) (unallocatedCPU, unallocatedMem, leftCPU, leftMem, leftPods int64)

CalculateNodeRes calculate unallocated cpu, memory and left cpu, mem, pods for given node and its allocated cpu, memory

func CheckPermission

func CheckPermission(ctx context.Context) error

func GetAllNamespacesFromCache

func GetAllNamespacesFromCache(ctx context.Context, steveServer cmp.SteveServer, userID, orgID, clusterName string) ([]string, error)

GetAllNamespacesFromCache get all namespaces name list by k8s client with cache

func GetAllProjectsDisplayNameFromCache

func GetAllProjectsDisplayNameFromCache(bdl *bundle.Bundle, orgID string) (map[uint64]string, error)

GetAllProjectsDisplayNameFromCache get all projects in org and return a project id to project display name map with cache

func GetImpersonateClient

func GetImpersonateClient(steveServer cmp.SteveServer, userID, orgID, clusterName string) (*k8sclient.K8sClient, error)

GetImpersonateClient authenticate user by steve server and return an impersonate k8s client

func GetWorkloadAgeAndImage

func GetWorkloadAgeAndImage(obj data.Object) (string, string, error)

GetWorkloadAgeAndImage get age and image for workloads from .metadata.fields

func IsDeepEqual

func IsDeepEqual(objA, objB interface{}) (bool, error)

IsDeepEqual return true if objA and objB is deep equal. Used for unit testing.

func IsJsonEqual

func IsJsonEqual(objA, objB interface{}) (bool, error)

IsJsonEqual return true if objA and objB is same after marshal by json. Used for unit testing.

func IsProjectNamespace

func IsProjectNamespace(namespace string) bool

func ParsePodStatus

func ParsePodStatus(state string) (string, bool)

func ParseWorkloadID

func ParseWorkloadID(id string) (apistructs.K8SResType, string, string, error)

ParseWorkloadID get workloadKind, namespace and name from id

func ParseWorkloadStatus

func ParseWorkloadStatus(obj data.Object) (string, string, bool, error)

ParseWorkloadStatus get status for workloads from .metadata.fields

func ResourceToString

func ResourceToString(sdk *cptype.SDK, res float64, format resource.Format) string

ResourceToString return resource with unit Only support resource.DecimalSI and resource.BinarySI format Original unit is m (for DecimalSI) or B (for resource.BinarySI) Accurate to 1 decimal places. Zero in suffix will be removed

Types

This section is empty.

Jump to

Keyboard shortcuts

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