util

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package util provides various helper routines.

Index

Constants

View Source
const (
	// JobCreatedReason is added in a job when it is created.
	JobCreatedReason = "JobCreated"
	// JobSucceededReason is added in a job when it is succeeded.
	JobSucceededReason = "JobSucceeded"
	// JobRunningReason is added in a job when it is running.
	JobRunningReason = "JobRunning"
	// JobFailedReason is added in a job when it is failed.
	JobFailedReason = "JobFailed"
	// JobRestarting is added in a job when it is restarting.
	JobRestartingReason = "JobRestarting"
	// JobEvicted is added in a job when it is evicted.
	JobEvictedReason = "JobEvicted"
)

Variables

This section is empty.

Functions

func GenGeneralName added in v0.2.0

func GenGeneralName(jobName, rtype, index string) string

GenGeneralName generate a name from the given jobName rtype and index.

func GetClientReaderFromClient

func GetClientReaderFromClient(c client.Client) (client.Reader, error)

getClientReaderFromClient try to extract client reader from client, client reader reads cluster info from api client.

func GetCondition

func GetCondition(status apiv1.JobStatus, condType apiv1.JobConditionType) *apiv1.JobCondition

GetCondition returns the condition with the provided type.

func GetControllerOwnerReference

func GetControllerOwnerReference(owners []v1.OwnerReference) v1.OwnerReference

func HasCondition

func HasCondition(status apiv1.JobStatus, condType apiv1.JobConditionType) bool

func IntPtr

func IntPtr(i int) *int

IntPtr returns a pointer to integer.

func IsCreated

func IsCreated(status apiv1.JobStatus) bool

IsCreated checks if the job has created.

func IsEvicted added in v0.2.0

func IsEvicted(status apiv1.JobStatus) bool

IsEvicted checks if the job is evicted.

func IsFailed

func IsFailed(status apiv1.JobStatus) bool

IsFailed checks if the job is failed.

func IsRestarting

func IsRestarting(status apiv1.JobStatus) bool

IsRestarting checks if the job is restarting.

func IsRunning

func IsRunning(status apiv1.JobStatus) bool

IsRunning checks if the job is running.

func IsSucceeded

func IsSucceeded(status apiv1.JobStatus) bool

IsSucceeded checks if the job is succeeded.

func LoggerForJob

func LoggerForJob(job metav1.Object) *log.Entry

func LoggerForKey

func LoggerForKey(key string) *log.Entry

func LoggerForPod

func LoggerForPod(pod *v1.Pod, kind string) *log.Entry

func LoggerForReplica

func LoggerForReplica(job metav1.Object, rtype string) *log.Entry

func LoggerForUnstructured

func LoggerForUnstructured(obj *metav1unstructured.Unstructured, kind string) *log.Entry

func MergeMap added in v0.2.0

func MergeMap(a, b map[string]string) map[string]string

MergeMap merge b to a and return a

func Pformat

func Pformat(value interface{}) string

Pformat returns a pretty format output of any value that can be marshaled to JSON.

func RandString

func RandString(n int) string

RandString generates a random string of the desired length.

The string is DNS-1035 label compliant; i.e. its only alphanumeric lowercase. From: https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-golang

func Time

func Time(s *time.Time) time.Time

Time returns a Time object from a Time pointer.

func TimePtr

func TimePtr(t time.Time) *time.Time

TimePtr returns a pointer to a Time.

func ToPodPointerList

func ToPodPointerList(list []corev1.Pod) []*corev1.Pod

ToPodPointerList convert pod list to pod pointer list

func ToServicePointerList

func ToServicePointerList(list []corev1.Service) []*corev1.Service

ToServicePointerList convert service list to service point list

func UInt32Ptr

func UInt32Ptr(i uint32) *uint32

UInt32Ptr returns a pointer to uint32.

func UpdateJobConditions

func UpdateJobConditions(jobStatus *apiv1.JobStatus, conditionType apiv1.JobConditionType, reason, message string) error

UpdateJobConditions adds to the jobStatus a new condition if needed, with the conditionType, reason, and message.

Types

This section is empty.

Directories

Path Synopsis
Package that various helper routines for training.
Package that various helper routines for training.

Jump to

Keyboard shortcuts

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