Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateNodeRes(node data.Object, allocatedCPU, allocatedMem, allocatedPods int64) (unallocatedCPU, unallocatedMem, leftCPU, leftMem, leftPods int64)
- func GetAllNamespacesFromCache(ctx context.Context, steveServer cmp.SteveServer, ...) ([]string, error)
- func GetAllProjectsDisplayNameFromCache(bdl *bundle.Bundle, orgID string) (map[uint64]string, error)
- func GetImpersonateClient(steveServer cmp.SteveServer, userID, orgID, clusterName string) (*k8sclient.K8sClient, error)
- func GetWorkloadAgeAndImage(obj data.Object) (string, string, error)
- func IsDeepEqual(objA, objB interface{}) (bool, error)
- func IsJsonEqual(objA, objB interface{}) (bool, error)
- func ParsePodStatus(state string) (string, bool)
- func ParseWorkloadID(id string) (apistructs.K8SResType, string, string, error)
- func ParseWorkloadStatus(obj data.Object) (string, string, bool, error)
- func ResourceToString(sdk *cptype.SDK, res float64, format resource.Format) string
Constants ¶
const ( ProjectsDisplayNameCache = "projectDisplayName" NamespacesCache = "allNamespaces" )
Variables ¶
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 GetAllNamespacesFromCache ¶ added in v1.4.0
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 ¶ added in v1.4.0
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 ¶ added in v1.4.0
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 ¶
GetWorkloadAgeAndImage get age and image for workloads from .metadata.fields
func IsDeepEqual ¶ added in v1.5.0
IsDeepEqual return true if objA and objB is deep equal. Used for unit testing.
func IsJsonEqual ¶ added in v1.4.0
IsJsonEqual return true if objA and objB is same after marshal by json. Used for unit testing.
func ParsePodStatus ¶ added in v1.5.0
func ParseWorkloadID ¶
func ParseWorkloadID(id string) (apistructs.K8SResType, string, string, error)
ParseWorkloadID get workloadKind, namespace and name from id
func ParseWorkloadStatus ¶
ParseWorkloadStatus get status for workloads from .metadata.fields
func ResourceToString ¶
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.