testutils

package
v1.0.2 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: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NameFormat                    = "name-%s"
	NamespaceFormat               = "namespace-%s"
	StatefulSetNameFormat         = "%s-nats"
	ConfigMapNameFormat           = "%s-nats-config"
	SecretNameFormat              = "%s-nats-secret" //nolint:gosec // only for test purpose
	ServiceNameFormat             = "%s-nats"
	PodDisruptionBudgetNameFormat = "%s-nats"
	DestinationRuleNameFormat     = "%s-nats"
)

Variables

This section is empty.

Functions

func FindContainer

func FindContainer(containers []apiv1.Container, name string) *apiv1.Container

func GetConfigMapName

func GetConfigMapName(nats v1alpha1.NATS) string

func GetDestinationRuleGVR

func GetDestinationRuleGVR() schema.GroupVersionResource

func GetDestinationRuleName

func GetDestinationRuleName(nats v1alpha1.NATS) string

func GetFreePort

func GetFreePort() (int, error)

GetFreePort determines a free port on the host. It does so by delegating the job to net.ListenTCP. Then providing a port of 0 to net.ListenTCP, it will automatically choose a port for us.

func GetPodDisruptionBudgetName added in v0.1.0

func GetPodDisruptionBudgetName(nats v1alpha1.NATS) string

func GetRandK8sName

func GetRandK8sName(length int) string

GetRandK8sName returns a valid name for K8s objects.

func GetRandString

func GetRandString(length int) string

GetRandString returns a random string of the given length.

func GetSecretName

func GetSecretName(nats v1alpha1.NATS) string

func GetServiceName

func GetServiceName(nats v1alpha1.NATS) string

func GetStatefulSetName

func GetStatefulSetName(nats v1alpha1.NATS) string

func NewLogger

func NewLogger() (*zap.Logger, error)

func NewNATSCR

func NewNATSCR(opts ...NATSOption) *v1alpha1.NATS

func NewNATSStatefulSetUnStruct

func NewNATSStatefulSetUnStruct(opts ...Option) *unstructured.Unstructured

func NewNamespace

func NewNamespace(name string) *apiv1.Namespace

func NewPVC

func NewPVC(name, namespace string, labels map[string]string) *apiv1.PersistentVolumeClaim

NewPVC creates a new PVC object with the given name, namespace, and label.

func NewSecret

func NewSecret(opts ...Option) *apiv1.Secret

func NewSecretUnStruct

func NewSecretUnStruct(opts ...Option) *unstructured.Unstructured

func NewStatefulSet

func NewStatefulSet(name, namespace string, labels map[string]string) *appsv1.StatefulSet

func NewSugaredLogger

func NewSugaredLogger() (*zap.SugaredLogger, error)

Types

type NATSOption

type NATSOption func(*v1alpha1.NATS) error

func WithNATSAnnotations

func WithNATSAnnotations(annotations map[string]string) NATSOption

func WithNATSCRDefaults

func WithNATSCRDefaults() NATSOption

func WithNATSCRFinalizer

func WithNATSCRFinalizer(finalizer string) NATSOption

func WithNATSCRName

func WithNATSCRName(name string) NATSOption

func WithNATSCRNamespace

func WithNATSCRNamespace(namespace string) NATSOption

func WithNATSCRStatusInitialized

func WithNATSCRStatusInitialized() NATSOption

func WithNATSClusterSize

func WithNATSClusterSize(size int) NATSOption

func WithNATSEmptySpec

func WithNATSEmptySpec() NATSOption

func WithNATSFileStorage

func WithNATSFileStorage(fileStorage v1alpha1.FileStorage) NATSOption

func WithNATSLabels

func WithNATSLabels(labels map[string]string) NATSOption

func WithNATSLogging

func WithNATSLogging(debug, trace bool) NATSOption

func WithNATSMemStorage

func WithNATSMemStorage(memStorage v1alpha1.MemStorage) NATSOption

func WithNATSResources

func WithNATSResources(resources corev1.ResourceRequirements) NATSOption

func WithNATSStateError added in v1.0.2

func WithNATSStateError() NATSOption

func WithNATSStateProcessing

func WithNATSStateProcessing() NATSOption

func WithNATSStateReady

func WithNATSStateReady() NATSOption

type Option

type Option func(*unstructured.Unstructured) error

func WithName

func WithName(name string) Option

func WithNamespace

func WithNamespace(namespace string) Option

func WithSpecReplicas

func WithSpecReplicas(replicas int) Option

func WithStatefulSetStatusCurrentReplicas

func WithStatefulSetStatusCurrentReplicas(replicas int) Option

func WithStatefulSetStatusReadyReplicas

func WithStatefulSetStatusReadyReplicas(replicas int) Option

func WithStatefulSetStatusUpdatedReplicas

func WithStatefulSetStatusUpdatedReplicas(replicas int) Option

Directories

Path Synopsis
matchers

Jump to

Keyboard shortcuts

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