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

import (
	"github.com/ankitrgadiya/operatorlib/pkg/container"
	"github.com/ankitrgadiya/operatorlib/pkg/interfaces"
	"github.com/ankitrgadiya/operatorlib/pkg/meta"
Timothee Gosselin's avatar
Timothee Gosselin committed
	"github.com/ankitrgadiya/operatorlib/pkg/pod"
Timothee Gosselin's avatar
Timothee Gosselin committed
	batchv1 "k8s.io/api/batch/v1"
	"k8s.io/apimachinery/pkg/runtime"
Timothee Gosselin's avatar
Timothee Gosselin committed
	"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Timothee Gosselin's avatar
Timothee Gosselin committed
)

// GenConfigMapFunc defines a function which generates ConfigMap.
type GenJobFunc func(Conf) (*batchv1.Job, error)
Timothee Gosselin's avatar
Timothee Gosselin committed
type GenParallelismFunc func() (*int32, error)
type GenCompletionsFunc func() (*int32, error)
type GenActiveDeadlineSecondsFunc func() (*int64, error)
type GenBackoffLimitFunc func() (*int32, error)
Timothee Gosselin's avatar
Timothee Gosselin committed

// type GenSelectorFunc func(interfaces.Object) (*metav1.LabelSelector, error)

// Conf is used to pass parameters to functions in this package to
// perform operations on Configmap objects.
type Conf struct {
Timothee Gosselin's avatar
Timothee Gosselin committed
	Namespace string
	Name      string
	//	Obj            batchv1.Job
	Obj            interfaces.Object
Timothee Gosselin's avatar
Timothee Gosselin committed
	Reconcile      interfaces.Reconcile
	previousObject runtime.Object
	Owner          interfaces.Object
	OwnerReference bool
	GenFinalizers  meta.GenFinalizers
	GenLabels      meta.GenLabels
	GenAnnotations meta.GenAnnotations
	ManualSelector bool
	GenJobFunc
	GenParallelismFunc
	GenCompletionsFunc
	GenActiveDeadlineSecondsFunc
	GenBackoffLimitFunc
	//	GenSelectorFunc
	GenContainers          []container.Mutate
	GenVolumesFunc         pod.GenVolumesFunc
	GenSecurityContextFunc pod.GenSecurityContextFunc
	GenRestartPolicyFunc   pod.GenRestartPolicyFunc
}
Timothee Gosselin's avatar
Timothee Gosselin committed

type Mutate interface {
	// meta.Mutate
	pod.Mutate
	Mutate() controllerutil.MutateFn
	GenParallelism() (*int32, error)
	GenCompletions() (*int32, error)
	GenActiveDeadlineSeconds() (*int64, error)
	GenBackoffLimit() (*int32, error)
	GenManualSelector() (*bool, error)
}