Skip to content
types.go 2.12 KiB
Newer Older
Timothee Gosselin's avatar
Timothee Gosselin committed
package pvc

import (
	"github.com/ankitrgadiya/operatorlib/pkg/interfaces"
	"github.com/ankitrgadiya/operatorlib/pkg/meta"
	"github.com/ankitrgadiya/operatorlib/pkg/operation"

	corev1 "k8s.io/api/core/v1"
)

// GenConfigMapFunc defines a function which generates ConfigMap.
type GenPVCFunc func(Conf) (*corev1.PersistentVolumeClaim, error)
type GenResourcesFunc func(interfaces.Object) (corev1.ResourceRequirements, error)
type GenAccessModesFunc func(interfaces.Object) ([]corev1.PersistentVolumeAccessMode, error)

// Conf is used to pass parameters to functions in this package to
// perform operations on Configmap objects.
type Conf struct {
	// Instance is the Owner object which manages the Configmap
	Instance interfaces.Object
	// Reconcile is the pointer to reconcile struct of owner object
	interfaces.Reconcile
	// Name of the Configmap
	Name string
	// Namespace of the Configmap
	Namespace string
	// GenLalebsFunc is used to generate labels for ObjectMeta
	meta.GenLabelsFunc
	// GenAnnotationsFunc is used to generate annotations for ObjectMeta
	meta.GenAnnotationsFunc
	// GenFinalizers is used to generate finalizers for ObjectMeta
	meta.GenFinalizersFunc
	// AppendLabels is used to determine if labels from Owner object
	// are to be inherited
	AppendLabels bool
	// OwnerReference is used to determine if owner reference needs to
	// be set on Configmap before creating it in cluster
	OwnerReference bool
	// MaybeUpdateFunc defines an update function with custom logic
	// for Configmap update
	operation.MaybeUpdateFunc
	// AfterCreateFunc hook is called after creating the Configmap
	operation.AfterCreateFunc
	// AfterUpdateFunc hook is called after updating the Configmap
	operation.AfterUpdateFunc
	// AfterDeleteFunc hook is called after deleting the Configmap
	operation.AfterDeleteFunc
	// GenConfigMapFunc defines a function to generate the Configmap
	// object. The package comes with default configmap generator
	// function which is used by operation functions. By specifying
	// this field, user can override the default function with a
	// custom one.
	GenPVCFunc
	StorageClassName *string
	GenResourcesFunc
	GenAccessModesFunc
}