utils

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddString

func AddString(slice *[]string, s string) bool

AddString adds a string to the given slice

func AnnotationsToEnv

func AnnotationsToEnv(o metav1.Object, mapping []storageapi.EnvVar) (env []corev1.EnvVar, err error)

func CopyAnnotations

func CopyAnnotations(src, dest metav1.Object, mapping []storageapi.EnvVar)

func DeletePod

func DeletePod(ctx context.Context, client client.Client, name types.NamespacedName, log logr.Logger) (done bool, err error)

func DeleteResource

func DeleteResource(ctx context.Context, client client.Client, o client.Object, log logr.Logger) (done bool, err error)

func GetCondition

func GetCondition(conditions []metav1.Condition, condType string) *metav1.Condition

GetCondition returns the condition of the given type from the list of conditions or nil if it doesn't exist

func HasString

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

HasString returns true if the string exists within the given slice

func NewProvisionerPod

func NewProvisionerPod(src PodSource) (*corev1.Pod, error)

func PodToRequestMapper

func PodToRequestMapper(namespace, annName, annNamespace string) handler.EventHandler

func ReconcilePod

func ReconcilePod(ctx context.Context, client client.Client, name types.NamespacedName, create func() (*corev1.Pod, error)) (done bool, pod *corev1.Pod, err error)

ReconcilePod reconciles a Pod

func RemoveString

func RemoveString(slice *[]string, s string) (removed bool)

RemoveString removes a string from the given slice

func ResourceName

func ResourceName(ownerName, suffix string) string

func SetCondition

func SetCondition(conditions *[]metav1.Condition, newCond metav1.Condition) bool

SetCondition adds or updates a condition

func StorageProvisionerFromJSON

func StorageProvisionerFromJSON(data string) (*storageapi.StorageProvisioner, error)

func StorageProvisionerToJSON

func StorageProvisionerToJSON(provisioner *storageapi.StorageProvisioner) (string, error)

func StorageRootPathForNode

func StorageRootPathForNode(nodeName string, mapping []storageapi.NodePath) (string, error)

func Substitute

func Substitute(o runtime.Object, values *template.Substitution) error

func SubstituteProvisionerPlaceholders

func SubstituteProvisionerPlaceholders(tpl *storageapi.StorageProvisioner, p ProvisionerParams) error

Types

type ContainerParams

type ContainerParams struct {
	Command []string
	Env     []corev1.EnvVar
	Volume  Volume
}

type JobReconciler

type JobReconciler struct {
	Client                   client.Client
	Recorder                 record.EventRecorder
	AnnotationOwnerName      string
	AnnotationOwnerNamespace string
}

TODO: use this in all controllers to run de/provisioner Pods

func (*JobReconciler) ReconcileJob

func (r *JobReconciler) ReconcileJob(req JobRequest) (bool, error)

type JobRequest

type JobRequest struct {
	Context     context.Context
	Name        string
	PodName     types.NamespacedName
	Owner       client.Object
	ShouldRun   bool
	Create      func() (*corev1.Pod, error)
	OnCompleted func(*corev1.Pod) (done bool, err error)
	Log         logr.Logger
}

type PodSource

type PodSource struct {
	PodName                types.NamespacedName
	ContainerName          string
	SubstitutedProvisioner *storageapi.StorageProvisioner
	Container              *storageapi.ProvisionerContainer
	Env                    []corev1.EnvVar
}

type ProvisionerParams

type ProvisionerParams struct {
	NodeName              string
	NodePath              string
	PersistentVolumeName  string
	PersistentVolumeClaim types.NamespacedName
}

type Volume

type Volume struct {
	Name      string
	MountPath string
	Source    corev1.VolumeSource
}

Jump to

Keyboard shortcuts

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