service

package
v0.0.0-...-a5c132e Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateOrUpdate

func CreateOrUpdate(ctx context.Context, c client.Client, svc *corev1.Service, equal EqualityFunc, mutate MutateFunc) error

CreateOrUpdate attempts first to get the given service. If the service does not exist, the service will be created. Otherwise, if the service exists and the provided comparison func detects any changes an update is attempted. Updates are retried with backoff (See retry.DefaultRetry). Returns on failure an non-nil error.

func Equal

func Equal(current, desired *corev1.Service) bool

Equal return only true if the service are equal

func Mutate

func Mutate(current, desired *corev1.Service)

Mutate is a default mutation function for services that copies only mutable fields from desired to current.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder represents the struct to build k8s services

func New

func New(serviceName, namespace string, labels map[string]string) *Builder

New returns a new Builder instance with a default initialized service.

func (*Builder) Build

func (b *Builder) Build() *corev1.Service

Build returns the final service.

func (*Builder) WithAnnotations

func (b *Builder) WithAnnotations(a map[string]string) *Builder

WithAnnotations set the object meta annotations.

func (*Builder) WithPublishNotReady

func (b *Builder) WithPublishNotReady(val bool) *Builder

WithPublishNotReady sets the spec PublishNotReadyAddresses flag.

func (*Builder) WithSelector

func (b *Builder) WithSelector(s map[string]string) *Builder

WithSelector sets the service selector.

func (*Builder) WithServicePorts

func (b *Builder) WithServicePorts(sp ...corev1.ServicePort) *Builder

WithServicePorts appends service ports to the service spec.

type EqualityFunc

type EqualityFunc func(current, desired *corev1.Service) bool

EqualityFunc is the type for functions that compare two services. Return true if two services are equal.

type MutateFunc

type MutateFunc func(current, desired *corev1.Service)

MutateFunc is the type for functions that mutate the current service by applying the values from the desired service.

Jump to

Keyboard shortcuts

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