helpers

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DashboardConfigName          = "opensearch_dashboards.yml"
	DashboardChecksumName        = "checksum/dashboards.yml"
	ClusterLabel                 = "opster.io/opensearch-cluster"
	NodePoolLabel                = "opster.io/opensearch-nodepool"
	OsUserNameAnnotation         = "opensearchuser/name"
	OsUserNamespaceAnnotation    = "opensearchuser/namespace"
	DnsBaseEnvVariable           = "DNS_BASE"
	ParallelRecoveryEnabled      = "PARALLEL_RECOVERY_ENABLED"
	SkipInitContainerEnvVariable = "SKIP_INIT_CONTAINER"
)

Variables

This section is empty.

Functions

func BuildMainCommand

func BuildMainCommand(installerBinary string, pluginsList []string, batchMode bool, entrypoint string) []string

func BuildMainCommandOSD

func BuildMainCommandOSD(installerBinary string, pluginsList []string, entrypoint string) []string

func CalculateJvmHeapSize

func CalculateJvmHeapSize(nodePool *opsterv1.NodePool) string

func CheckVolumeExists

func CheckVolumeExists(volumes []corev1.Volume, volumeMounts []corev1.VolumeMount, secretName string, volumeName string) bool

func ClusterDnsBase

func ClusterDnsBase() string

func CompareVersions

func CompareVersions(v1 string, v2 string) bool

Compares whether v1 is LessThan v2

func ContainsString

func ContainsString(slice []string, s string) bool

func CountPVCsForNodePool

func CountPVCsForNodePool(ctx context.Context, k8sClient client.Client, cr *opsterv1.OpenSearchCluster, nodePool *opsterv1.NodePool) (int, error)

Count the number of PVCs created for the given NodePool

func CountRunningPodsForNodePool

func CountRunningPodsForNodePool(ctx context.Context, k8sClient client.Client, cr *opsterv1.OpenSearchCluster, nodePool *opsterv1.NodePool) (int, error)

Count the number of pods running and ready and not terminating for a given nodePool

func DeleteSTSForNodePool

func DeleteSTSForNodePool(ctx context.Context, k8sClient client.Client, nodePool opsterv1.NodePool, clusterName, clusterNamespace string) error

DeleteSTSForNodePool deletes the sts for the corresponding nodePool

func DeleteSecurityUpdateJob

func DeleteSecurityUpdateJob(ctx context.Context, k8sClient client.Client, clusterName, clusterNamespace string) error

DeleteSecurityUpdateJob deletes the securityconfig update job

func DiffSlice

func DiffSlice(leftSlice, rightSlice []string) []string

Get leftSlice strings not in rightSlice

func FindByPath

func FindByPath(obj interface{}, keys []string) (interface{}, bool)

func GetField

func GetField(v *appsv1.StatefulSetSpec, field string) interface{}

func GetSTSForNodePool

func GetSTSForNodePool(ctx context.Context, k8sClient client.Client, nodePool opsterv1.NodePool, clusterName, clusterNamespace string) (*appsv1.StatefulSet, error)

GetSTSForNodePool returns the corresponding sts for a given nodePool and cluster name

func HasDataRole

func HasDataRole(nodePool *opsterv1.NodePool) bool

func HasKeyWithBytes

func HasKeyWithBytes(data map[string][]byte, key string) bool

func HasManagerRole

func HasManagerRole(nodePool *opsterv1.NodePool) bool

func MapClusterRole

func MapClusterRole(role string, ver string) string

Map any cluster roles that have changed between major OpenSearch versions

func MapClusterRoles

func MapClusterRoles(roles []string, version string) []string

func MergeConfigs

func MergeConfigs(left map[string]string, right map[string]string) map[string]string

func NewMockPKI

func NewMockPKI() tls.PKI

func ParallelRecoveryMode

func ParallelRecoveryMode() bool

func RemoveDuplicateStrings

func RemoveDuplicateStrings(strSlice []string) []string

func ResolveClusterManagerRole

func ResolveClusterManagerRole(ver string) string

func ResolveDashboardsImage

func ResolveDashboardsImage(cr *opsterv1.OpenSearchCluster) (result opsterv1.ImageSpec)

func ResolveImage

func ResolveImage(cr *opsterv1.OpenSearchCluster, nodePool *opsterv1.NodePool) (result opsterv1.ImageSpec)

func ResolveInitHelperImage

func ResolveInitHelperImage(cr *opsterv1.OpenSearchCluster) (result opsterv1.ImageSpec)

func SkipInitContainer

func SkipInitContainer() bool

func SortedKeys

func SortedKeys(input map[string]string) []string

Return the keys of the input map in sorted order Can be used if you want to iterate over a map but have a stable order

func UsernameAndPassword

func UsernameAndPassword(ctx context.Context, k8sClient client.Client, cr *opsterv1.OpenSearchCluster) (string, string, error)

func VersionCheck

func VersionCheck(instance *opsterv1.OpenSearchCluster) (int32, string)

Function to help identify httpPort and securityconfigPath for 1.x and 2.x OpenSearch Operator.

func WaitForSTSDelete

func WaitForSTSDelete(ctx context.Context, k8sClient client.Client, obj *appsv1.StatefulSet) error

Delete a STS with cascade=orphan and wait until it is actually deleted from the kubernetes API

func WaitForSTSReplicas

func WaitForSTSReplicas(ctx context.Context, k8sClient client.Client, obj *appsv1.StatefulSet, replicas int32) error

Wait for max 30s until a STS has at least the given number of replicas

func WaitForSTSStatus

func WaitForSTSStatus(ctx context.Context, k8sClient client.Client, obj *appsv1.StatefulSet) (*appsv1.StatefulSet, error)

Wait for max 30s until a STS has a normal status (CurrentRevision != "")

Types

type CertMock

type CertMock struct {
}

func (*CertMock) CertData

func (cert *CertMock) CertData() []byte

func (*CertMock) CreateAndSignCertificate

func (ca *CertMock) CreateAndSignCertificate(commonName string, orgUnit string, dnsnames []string) (cert tls.Cert, err error)

func (*CertMock) KeyData

func (cert *CertMock) KeyData() []byte

func (*CertMock) SecretData

func (cert *CertMock) SecretData(ca tls.Cert) map[string][]byte

func (*CertMock) SecretDataCA

func (cert *CertMock) SecretDataCA() map[string][]byte

type MockEventRecorder

type MockEventRecorder struct {
}

A simple mock to use whenever a record.EventRecorder is needed for a test

func (*MockEventRecorder) AnnotatedEventf

func (r *MockEventRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})

func (*MockEventRecorder) Event

func (r *MockEventRecorder) Event(object runtime.Object, eventtype, reason, message string)

func (*MockEventRecorder) Eventf

func (r *MockEventRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

type PkiMock

type PkiMock struct {
}

func (*PkiMock) CAFromSecret

func (pki *PkiMock) CAFromSecret(data map[string][]byte) tls.Cert

func (*PkiMock) GenerateCA

func (pki *PkiMock) GenerateCA(name string) (ca tls.Cert, err error)

Jump to

Keyboard shortcuts

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