builders

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package builders offers functions for building test objects

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultServicePorts

func DefaultServicePorts() []corev1.ServicePort

DefaultServicePorts returns an array of ServicePort with default values

Types

type ContainerBuilder added in v0.3.2

type ContainerBuilder interface {
	// WithPort adds a port to the container
	WithPort(name string, port int32) ContainerBuilder
	// WithImage sets the container's image
	WithImage(image string) ContainerBuilder
	// WithPullPolicy sets the container's image pull policy (default is IfNotPresent)
	WithPullPolicy(policy corev1.PullPolicy) ContainerBuilder
	// WithCommand sets the container's command
	WithCommand(cmd ...string) ContainerBuilder
	// WithCapabilites adds capabilities to the container's security context
	WithCapabilities(capabilities ...corev1.Capability) ContainerBuilder
	// Build returns a Pod with the attributes defined in the PodBuilder
	Build() *corev1.Container
	// WithEnvVarFromField adds an environment variable to the container
	WithEnvVar(name string, value string) ContainerBuilder
	// WithEnvVarFromField adds an environment variable to the container referencing a field
	// Example: "PodName", "metadata.name"
	WithEnvVarFromField(name string, path string) ContainerBuilder
}

ContainerBuilder defines the methods for building a Container

func NewContainerBuilder added in v0.3.2

func NewContainerBuilder(name string) ContainerBuilder

NewContainerBuilder returns a new ContainerBuilder

type EndpointsBuilder added in v0.2.1

type EndpointsBuilder interface {
	// WithNamespace sets namespace for the pod to be built
	WithNamespace(namespace string) EndpointsBuilder
	// WithSubset adds a subset to the Endpoints
	WithSubset(ports []corev1.EndpointPort, pods []string) EndpointsBuilder
	// Build builds the Endpoints
	Build() *corev1.Endpoints
}

EndpointsBuilder defines the methods for building a service EndPoints

func NewEndPointsBuilder added in v0.2.1

func NewEndPointsBuilder(service string) EndpointsBuilder

NewEndPointsBuilder creates a new EndpointsBuilder for a given service

type IngressBuilder added in v0.3.2

type IngressBuilder interface {
	// WithNamespace sets the namespace for the ingres
	WithNamespace(namespace string) IngressBuilder
	// WithClass sets the ingress class
	WithClass(class string) IngressBuilder
	// WithHost sets the host for the ingress rule
	WithHost(host string) IngressBuilder
	// WithPath sets the path for the ingress
	WithPath(path string) IngressBuilder
	// WithAnnotations add annotations to the Ingress
	WithAnnotation(key, value string) IngressBuilder
	// WithAddress sets the ingress loadbalancer address
	WithAddress(addr string) IngressBuilder
	// Build returns the Ingress
	Build() *networking.Ingress
}

IngressBuilder defines the interface for building Ingresses for a service backend

func NewIngressBuilder added in v0.3.2

func NewIngressBuilder(service string, port intstr.IntOrString) IngressBuilder

NewIngressBuilder creates a new IngressBuilder for a given serviceBackend

type PodBuilder

type PodBuilder interface {
	// Build returns a Pod with the attributes defined in the PodBuilder
	Build() *corev1.Pod
	// WithNamespace sets namespace for the pod to be built
	WithNamespace(namespace string) PodBuilder
	// WithLabels sets the labels for the pod to be built
	WithLabels(labels map[string]string) PodBuilder
	// WithPhase sets the PodPhase for the pod to be built
	WithPhase(status corev1.PodPhase) PodBuilder
	// WithIP sets the IP address for the pod to be built
	WithIP(ip string) PodBuilder
	// WithHostNetwork sets the hostNetwork property of the pod to be built
	WithHostNetwork(hostNetwork bool) PodBuilder
	// WithContainer add a container to the pod
	WithContainer(c corev1.Container) PodBuilder
}

PodBuilder defines the methods for building a Pod

func NewPodBuilder

func NewPodBuilder(name string) PodBuilder

NewPodBuilder creates a new instance of PodBuilder with the given pod name and default attributes such as containers and namespace

type ServiceBuilder

type ServiceBuilder interface {
	// Build returns a Service with the attributes defined in the ServiceBuilder
	Build() *corev1.Service
	// WithNamespace sets namespace for the pod to be built
	WithNamespace(namespace string) ServiceBuilder
	// WithPorts sets the ports exposed by the service
	WithPorts(ports []corev1.ServicePort) ServiceBuilder
	// WithSelector sets the service's selector labels
	WithSelector(labels map[string]string) ServiceBuilder
	// WithServiceType sets the type of the service (default is NodePort)
	WithServiceType(t corev1.ServiceType) ServiceBuilder
	// WithAnnotation adds an annotation to the service
	WithAnnotation(key string, value string) ServiceBuilder
}

ServiceBuilder defines the methods for building a service

func NewServiceBuilder

func NewServiceBuilder(name string) ServiceBuilder

NewServiceBuilder creates a new instance of ServiceBuilder with the given pod name and default attributes

Jump to

Keyboard shortcuts

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