utils

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KB = 1024
	MB = 1024 * KB
	GB = 1024 * MB
	TB = 1024 * GB
	PB = 1024 * TB
)
View Source
const MountRoot string = "MOUNT_ROOT"

Variables

This section is empty.

Functions

func AddRuntimesIfNotExist

func AddRuntimesIfNotExist(runtimes []data.Runtime, newRuntime data.Runtime) (updatedRuntimes []data.Runtime)

AddRuntimesIfNotExist

func BytesSize added in v0.4.0

func BytesSize(size float64) string

BytesSize returns a human-readable size in bytes, kibibytes, mebibytes, gibibytes, or tebibytes, but with a B, kB, MB unit style. This is to make byte units be in consistent with Alluxio See https://github.com/Alluxio/alluxio/blob/master/core/common/src/main/java/alluxio/util/FormatUtils.java#L135

func ContainsString

func ContainsString(slice []string, s string) bool

func FromHumanSize added in v0.4.0

func FromHumanSize(size string) (int64, error)

FromHumanSize returns an integer from a human-readable specification of a size with 1024 as multiplier (eg. "44kB" = "(44 * 1024)B").

func GetAlluxioRuntime

func GetAlluxioRuntime(client client.Client, name, namespace string) (*data.AlluxioRuntime, error)

GetAlluxioRuntime gets Alluxio Runtime object with the given name and namespace

func GetChartsDirectory

func GetChartsDirectory() string

Get the directory of charts

func GetDataLoad

func GetDataLoad(client client.Client, name, namespace string) (*datav1alpha1.DataLoad, error)

GetDataLoad gets the DataLoad given its name and namespace

func GetDataLoadJob added in v0.4.0

func GetDataLoadJob(client client.Client, name, namespace string) (*batchv1.Job, error)

GetDataLoadJob gets the DataLoad job given its name and namespace

func GetDataLoadJobName added in v0.4.0

func GetDataLoadJobName(releaseName string) string

GetDataLoadJobName returns DataLoad job's name given the DataLoad helm release's name

func GetDataLoadRef added in v0.4.0

func GetDataLoadRef(name, namespace string) string

GetDataLoadRef returns the identity of the DataLoad by combining its namespace and name. The identity is used for identifying current lock holder on the target dataset.

func GetDataLoadReleaseName added in v0.4.0

func GetDataLoadReleaseName(name string) string

GetDataLoadReleaseName returns DataLoad helm release's name given the DataLoad's name

func GetDataset

func GetDataset(client client.Client, name, namespace string) (*datav1alpha1.Dataset, error)

GetDataset gets the dataset. It returns a pointer to the dataset if successful.

func GetDatasetCondition

func GetDatasetCondition(conditions []datav1alpha1.DatasetCondition,
	condType datav1alpha1.DatasetConditionType) (index int, condition *datav1alpha1.DatasetCondition)

get dataset condition given a dataset condition type. If found, return index of the founded condition in the condition array and the founded condition itself, otherwise return -1 and nil.

func GetMountRoot added in v0.4.0

func GetMountRoot() string

GetMountRoot gets the value of the env variable named MOUNT_ROOT

func GetOrDefault

func GetOrDefault(str *string, defaultValue string) string

func GetRuntimeByCategory added in v0.4.0

func GetRuntimeByCategory(runtimes []datav1alpha1.Runtime, category common.Category) (index int, runtime *datav1alpha1.Runtime)

func GetRuntimeCondition

func GetRuntimeCondition(conditions []data.RuntimeCondition,
	condType data.RuntimeConditionType) (index int, condition *data.RuntimeCondition)

GetRuntimeCondition gets a runtime condition given a runtime condition type. If found, return index of the founded condition in the condition array and the founded condition itself, otherwise return -1 and nil.

func HasDeletionTimestamp

func HasDeletionTimestamp(obj metav1.ObjectMeta) bool

HasDeletionTimestamp method that makes logic easier to read.

func Home

func Home() (string, error)

func IgnoreNotFound

func IgnoreNotFound(err error) error

IgnoreNotFound ignores not found

func IsDatasetConditionExist

func IsDatasetConditionExist(conditions []datav1alpha1.DatasetCondition,
	cond datav1alpha1.DatasetCondition) (found bool)

IsDatasetConditionExist checks if the given dataset condition exists in the given dataset condition array.

func IsSetupDone added in v0.4.0

func IsSetupDone(dataset *datav1alpha1.Dataset) (done bool)

checks the setup is done

func NewDatasetCondition

func NewDatasetCondition(conditionType datav1alpha1.DatasetConditionType, reason, message string, status v1.ConditionStatus) datav1alpha1.DatasetCondition

NewDatasetCondition creates a new Cache condition.

func NewRuntime

func NewRuntime(name, namespace string, category common.Category, runtimeType string) data.Runtime

NewRuntimeCondition creates a new Cache condition.

func NewRuntimeCondition

func NewRuntimeCondition(conditionType data.RuntimeConditionType, reason, message string, status v1.ConditionStatus) data.RuntimeCondition

NewRuntimeCondition creates a new Cache condition.

func NoRequeue

func NoRequeue() (ctrl.Result, error)

NoRequeue returns the result of a reconciler invocation and won't requeue.

func Now

func Now() *metav1.Time

func PathExists

func PathExists(path string) bool

func RandomAlphaNumberString

func RandomAlphaNumberString(l int32) string

Return a string of length l which is made up of runes randomly selected from [0-9a-z]

func RandomString

func RandomString(source []rune, l int32) string

RandomString returns a string of length l which is made up of runes randomly selected from `source`.

func RemoveString

func RemoveString(slice []string, s string) (result []string)

func RequeueAfterInterval

func RequeueAfterInterval(interval time.Duration) (ctrl.Result, error)

RequeueAfterInterval returns the result of a reconciler invocation with a given requeue interval.

func RequeueIfError

func RequeueIfError(err error) (ctrl.Result, error)

RequeueIfError returns the result of a reconciler invocation and requeue immediately if err is not nil.

func RequeueImmediately

func RequeueImmediately() (ctrl.Result, error)

RequeueImmediately returns the result of a reconciler invocation and requeue immediately.

func RequeueImmediatelyUnlessGenerationChanged

func RequeueImmediatelyUnlessGenerationChanged(prevGeneration, curGeneration int64) (ctrl.Result, error)

RequeueImmediatelyUnlessGenerationChanged requeues immediately if the object generation has not changed. Otherwise, since the generation change will trigger an immediate update anyways, this will not requeue. This prevents some cases where two reconciliation loops will occur.

func SplitSchemaAddr

func SplitSchemaAddr(addr string) (string, string)

SplitSchemaAddr splits the address string into 2 parts: proto and addr. Proto is set to "tcp" in default. It returns proto and addr separately.

func ToYaml

func ToYaml(values interface{}, file *os.File) error

ToYaml converts values from json format to yaml format and stores the values to the file. It will return err when failed to marshal value or write file.

func TransformRequirementsToResources

func TransformRequirementsToResources(res corev1.ResourceRequirements) (cRes common.Resources)

func UpdateDatasetCondition

func UpdateDatasetCondition(conditions []datav1alpha1.DatasetCondition, condition datav1alpha1.DatasetCondition) []datav1alpha1.DatasetCondition

SetDatasetCondition updates the dataset to include the provided condition. If the condition that we are about to add already exists and has the same status and reason then we are not going to update.

func UpdateRuntimeCondition

func UpdateRuntimeCondition(conditions []data.RuntimeCondition, condition data.RuntimeCondition) []data.RuntimeCondition

UpdateRuntimeCondition updates the runtime to include the provided condition. If the condition that we are about to add already exists and has the same status and reason then we are not going to update.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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