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

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

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

// GenServiceFunc defines a function which generates Service
type GenServiceFunc func(Conf) (*corev1.Service, error)

// GenServicePortsFunc defines a function which generates slice of
// ServicePort for Service
type GenServicePortsFunc func() ([]corev1.ServicePort, error)

// GenSelectorFunc defines a function which generates selectors for
// the Service
type GenServiceSelectorFunc func() (map[string]string, error)
type GenServiceTypeFunc func() (corev1.ServiceType, error)
Timothee Gosselin's avatar
Timothee Gosselin committed

type Conf struct {
	Namespace      string
	Name           string
	Obj            *corev1.Service
	Reconcile      interfaces.Reconcile
	previousObject interfaces.Object
	Owner          interfaces.Object
	OwnerReference bool
	GenFinalizers  meta.GenFinalizers
	GenLabels      meta.GenLabels
	GenAnnotations meta.GenAnnotations
	GenServiceFunc
	// GenServicePortsFunc defines a function to generate ports for
	// the Service
	GenServicePortsFunc
	// GenSelectorFunc defines a function to generate selector for the
	// Service
	GenServiceSelectorFunc
	GenServiceTypeFunc
Timothee Gosselin's avatar
Timothee Gosselin committed
	// Type defines the type of Service object to be created
	Type string
}

type Mutate interface {
	meta.Mutate
	GenServicePorts() ([]corev1.ServicePort, error)
	GenServiceSelector() (map[string]string, error)
	GenServiceType() (corev1.ServiceType, error)
}