utils

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: Apache-2.0 Imports: 27 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 ContainsOwners added in v0.5.0

func ContainsOwners(owners []metav1.OwnerReference, dataset *datav1alpha1.Dataset) bool

func ContainsSelector added in v0.5.0

func ContainsSelector(labels map[string]string, selector map[string]string) bool

ContainsSelector Determine whether the labels contain the selector

func ContainsString

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

ContainsString Determine whether the string array contains a specific string, return true if contains the string and return false if not.

func FillSliceWithString added in v0.5.0

func FillSliceWithString(str string, num int) *[]string

FillSliceWithString fills a slice with repeated given string

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 GetAccessModesOfDataset added in v0.5.0

func GetAccessModesOfDataset(client client.Client, name, namespace string) (accessModes []v1.PersistentVolumeAccessMode, err error)

func GetAddressOfMaster added in v0.5.0

func GetAddressOfMaster(pod *v1.Pod) (nodeName string, ip string, rpcPort int32)

GetAddressOfMaster return the ip and port of alluxio-master

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

* * // GetChartsDirectory gets the directory of the charts *

func GetDataBackup added in v0.5.0

func GetDataBackup(client client.Client, name, namespace string) (*datav1alpha1.DataBackup, error)

GetDataBackup gets the DataBackup given its name and namespace

func GetDataBackupPodName added in v0.5.0

func GetDataBackupPodName(name string) string

GetDataBackupPodName returns DataBackup pod's name given the DataBackup's name

func GetDataBackupRef added in v0.5.0

func GetDataBackupRef(name, namespace string) string

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

func GetDataBackupReleaseName added in v0.5.0

func GetDataBackupReleaseName(name string) string

GetDataBackupReleaseName returns DataBackup helm release's name given the DataBackup's name

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)

GetDatasetCondition returns dataset condition according to a given 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 GetExclusiveKey added in v0.5.0

func GetExclusiveKey() string

GetExclusiveKey gets exclusive key

func GetExclusiveValue added in v0.5.0

func GetExclusiveValue(namespace, name string) string

GetExclusiveValue gets exclusive value

func GetMountRoot added in v0.4.0

func GetMountRoot() (string, error)

GetMountRoot gets the value of the env variable named MOUNT_ROOT

func GetOrDefault

func GetOrDefault(str *string, defaultValue string) string

GetOrDefault returns the default value unless there is a specified value.

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 GetSecret added in v0.5.0

func GetSecret(client client.Client, name, namespace string) (*v1.Secret, error)

GetSecret gets the secret. It returns a pointer to the secret if successful.

func HasDeletionTimestamp

func HasDeletionTimestamp(obj metav1.ObjectMeta) bool

HasDeletionTimestamp method that makes logic easier to read.

func Home

func Home() (string, error)

Home returns the home directory for the executing user. This uses an OS-specific method for discovering the home directory. An error is returned if a home directory cannot be detected.

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

Now returns the current time

func ParseBackupRestorePath added in v0.5.0

func ParseBackupRestorePath(backupRestorePath string) (pvcName string, path string, err error)

ParseBackupRestorePath parse the BackupPath in spec of DataBackup or the RestorePath in spec of Dataset

func PathExists

func PathExists(path string) bool

PathExists returns the specified path is exists or not

func RandomAlphaNumberString

func RandomAlphaNumberString(l int32) string

RandomAlphaNumberString returns 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)

RemoveString removes strings in a array, which is equal to a given 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 TranformQuantityToAlluxioUnit added in v0.5.0

func TranformQuantityToAlluxioUnit(q *resource.Quantity) (value string)

func TranformQuantityToJindoUnit added in v0.5.0

func TranformQuantityToJindoUnit(q *resource.Quantity) (value string)

func TranformQuantityToUnits added in v0.5.0

func TranformQuantityToUnits(q *resource.Quantity) (value string)

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
dataset

Jump to

Keyboard shortcuts

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