utils

package
v0.0.0-...-f0c79c3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const EncryptionKeyMountXMLFileName = "encryptionKeyMount.xml"
View Source
const EncryptionKeyXMLFileName = "encryptionKey.xml"
View Source
const LTPAConfigCreationScriptFileName = "create_ltpa_config.sh"
View Source
const LTPAKeysCreationScriptFileName = "create_ltpa_keys.sh"
View Source
const LTPAKeysFileName = "ltpa.keys"
View Source
const LTPAKeysMountXMLFileName = "managedLTPAMount.xml"
View Source
const LTPAKeysXMLFileName = "managedLTPA.xml"
View Source
const LTPAServerXMLMountSuffix = "-managed-ltpa-mount-server-xml"
View Source
const LTPAServerXMLSuffix = "-managed-ltpa-server-xml"
View Source
const LeaderVersionLabel = LibertyURI + "/leader-version"
View Source
const LibertyURI = "webspherelibertyapplications.liberty.websphere.ibm.com"
View Source
const LocalPasswordEncryptionKeyRootName = "wlo-wlp-password-encryption-key"
View Source
const ManagedEncryptionMountServerXML = "-managed-encryption-mount-server-xml"
View Source
const ManagedEncryptionServerXML = "-managed-encryption-server-xml"

Password encryption constants

View Source
const OperandVersion = "1.4.1"
View Source
const PasswordEncryptionKeyRootName = "wlp-password-encryption-key"
View Source
const ResourceOwnersKey = "owners"
View Source
const ResourcePathIndexLabel = LibertyURI + "/resource-path-index"
View Source
const ResourcePathIndicesKey = "pathIndices"
View Source
const ResourcePathsKey = "paths"
View Source
const ResourceSuffixLength = 5
View Source
const ResourcesKey = "names"

Leader tracking constants

View Source
const SecureMountPath = "/output/resources/liberty-operator"

Mount constants

Variables

This section is empty.

Functions

func AddPodTemplateSpecAnnotation

func AddPodTemplateSpecAnnotation(pts *corev1.PodTemplateSpec, annotation map[string]string)

func AddSecretResourceVersionAsEnvVar

func AddSecretResourceVersionAsEnvVar(pts *corev1.PodTemplateSpec, la *wlv1.WebSphereLibertyApplication, client client.Client, secretName string, envNamePrefix string) error

func CommaSeparatedStringContains

func CommaSeparatedStringContains(stringList string, value string) int

returns the index of the contained value in stringList or else -1

func CompareOperandVersion

func CompareOperandVersion(a string, b string) int

func CompareStringTimeGreaterThanOrEqual

func CompareStringTimeGreaterThanOrEqual(time1 string, time2 string) (bool, error)

if time1 >= time2 then return true, otherwise false

func ConfigureLTPAConfig

func ConfigureLTPAConfig(pts *corev1.PodTemplateSpec, la *wlv1.WebSphereLibertyApplication, operatorShortName string, ltpaSecretName string, ltpaSuffixName string)

ConfigureLTPA setups the shared-storage for LTPA keys file generation

func ConfigurePasswordEncryption

func ConfigurePasswordEncryption(pts *corev1.PodTemplateSpec, la *wlv1.WebSphereLibertyApplication, operatorShortName string, passwordEncryptionMetadata *PasswordEncryptionMetadata)

func ConfigureServiceability

func ConfigureServiceability(pts *corev1.PodTemplateSpec, la *wlv1.WebSphereLibertyApplication)

ConfigureServiceability setups the shared-storage for serviceability

func Contains

func Contains(list []string, s string) bool

func CreateServiceabilityPVC

func CreateServiceabilityPVC(instance *wlv1.WebSphereLibertyApplication) *corev1.PersistentVolumeClaim

CreateServiceabilityPVC creates PersistentVolumeClaim for Serviceability

func CreateUnstructuredResourceFromSignature

func CreateUnstructuredResourceFromSignature(leaderTrackerType string, assetsFolder *string, args ...string) (*unstructured.Unstructured, string, error)

func CreateUnstructuredResourceListFromSignature

func CreateUnstructuredResourceListFromSignature(leaderTrackerType string, assetsFolder *string, args ...string) (*unstructured.UnstructuredList, string, error)

func CreateVolumeMount

func CreateVolumeMount(mountPath string, fileName string) corev1.VolumeMount

func CustomizeEncryptionKeyXML

func CustomizeEncryptionKeyXML(managedEncryptionXMLSecret *corev1.Secret, encryptionKey string) error

func CustomizeEnvSSO

func CustomizeEnvSSO(pts *corev1.PodTemplateSpec, instance *wlv1.WebSphereLibertyApplication, client client.Client, isOpenShift bool) error

CustomizeEnvSSO Process the configuration for SSO login providers

func CustomizeLTPAConfigJob

func CustomizeLTPAConfigJob(job *v1.Job, jobRootName string, la *wlv1.WebSphereLibertyApplication, ltpaConfig *LTPAConfig, client client.Client)

func CustomizeLTPAKeysJob

func CustomizeLTPAKeysJob(job *v1.Job, jobRootName string, la *wlv1.WebSphereLibertyApplication, ltpaConfig *LTPAConfig, client client.Client)

func CustomizeLTPAServerXML

func CustomizeLTPAServerXML(xmlSecret *corev1.Secret, la *wlv1.WebSphereLibertyApplication, encryptedPassword string) error

func CustomizeLeaderTracker

func CustomizeLeaderTracker(leaderTracker *corev1.Secret, trackerList *[]LeaderTracker)

func CustomizeLibertyAnnotations

func CustomizeLibertyAnnotations(pts *corev1.PodTemplateSpec, la *wlv1.WebSphereLibertyApplication)

func CustomizeLibertyEnv

func CustomizeLibertyEnv(pts *corev1.PodTemplateSpec, la *wlv1.WebSphereLibertyApplication, client client.Client) error

CustomizeLibertyEnv adds configured env variables appending configured liberty settings

func CustomizeLibertyFileMountXML

func CustomizeLibertyFileMountXML(mountingPasswordKeySecret *corev1.Secret, mountXMLFileName string, fileLocation string) error

func CustomizeLicenseAnnotations

func CustomizeLicenseAnnotations(pts *corev1.PodTemplateSpec, la *wlv1.WebSphereLibertyApplication)

func ExecuteCommandInContainer

func ExecuteCommandInContainer(config *rest.Config, podName, podNamespace, containerName string, command []string) (string, error)

ExecuteCommandInContainer Execute command inside a container in a pod through API

func GetCommaSeparatedArray

func GetCommaSeparatedArray(stringList string) []string

func GetCommaSeparatedString

func GetCommaSeparatedString(stringList string, index int) (string, error)

func GetFirstNumberFromString

func GetFirstNumberFromString(target string) string

func GetLastRotationLabelKey

func GetLastRotationLabelKey(sharedResourceName string) string

func GetLeaderTracker

func GetLeaderTracker(instance *wlv1.WebSphereLibertyApplication, operatorShortName string, leaderTrackerType string, client client.Client) (*corev1.Secret, *[]LeaderTracker, error)

func GetMaxTime

func GetMaxTime(args ...string) (string, error)

func GetOperandVersionString

func GetOperandVersionString() (string, error)

Converts semantic version string "a.b.c" to format "va_b_c"

func GetRandomLowerAlphanumericSuffix

func GetRandomLowerAlphanumericSuffix(length int) string

func GetRequiredLabels

func GetRequiredLabels(name string, instance string) map[string]string

func GetSecretLastRotationAsLabelMap

func GetSecretLastRotationAsLabelMap(la *wlv1.WebSphereLibertyApplication, client client.Client, secretName string, sharedResourceName string) (map[string]string, error)

func GetSecretLastRotationLabel

func GetSecretLastRotationLabel(la *wlv1.WebSphereLibertyApplication, client client.Client, secretName string, sharedResourceName string) (map[string]string, error)

func GetTrackedResourceName

func GetTrackedResourceName(sharedResourceName string) string

func GetWLOLicenseAnnotations

func GetWLOLicenseAnnotations() map[string]string

func InsertIntoSortedLeaderTrackers

func InsertIntoSortedLeaderTrackers(leaderTrackers *[]LeaderTracker, newLeader *LeaderTracker)

func IsLTPAJobConfigurationOutdated

func IsLTPAJobConfigurationOutdated(job *v1.Job, appLeaderInstance *wlv1.WebSphereLibertyApplication, client client.Client) bool

Returns true if the WebSphereLibertyApplication leader's state has changed, causing existing LTPA Jobs to need a configuration update, otherwise return false

func IsLowerAlphanumericSuffix

func IsLowerAlphanumericSuffix(suffix string) bool

func IsOperandVersionString

func IsOperandVersionString(version string) bool

func IsValidOperandVersion

func IsValidOperandVersion(version string) bool

func LocalObjectReferenceContainsName

func LocalObjectReferenceContainsName(list []corev1.LocalObjectReference, name string) bool

func MountSecretAsVolume

func MountSecretAsVolume(pts *corev1.PodTemplateSpec, secretName string, volumeMount corev1.VolumeMount)

func RegisterWithOidcProvider

func RegisterWithOidcProvider(regData RegisterData) (string, string, error)

func Remove

func Remove(list []string, s string) []string

func RemoveLeaderTracker

func RemoveLeaderTracker(leaderTracker *[]LeaderTracker, i int) bool

func RemoveMapElementByKey

func RemoveMapElementByKey(refMap map[string]string, labelKey string)

func RemovePodTemplateSpecAnnotationByKey

func RemovePodTemplateSpecAnnotationByKey(pts *corev1.PodTemplateSpec, annotationKey string)

func Validate

func Validate(wlapp *wlv1.WebSphereLibertyApplication) (bool, error)

Validate if the WebSphereLibertyApplication is valid

Types

type LTPAConfig

type LTPAConfig struct {
	Metadata                    *LTPAMetadata
	SecretName                  string
	SecretInstanceName          string
	ConfigSecretName            string
	ConfigSecretInstanceName    string
	ServiceAccountName          string
	JobRequestConfigMapName     string
	ConfigMapName               string
	FileName                    string
	EncryptionKeySecretName     string
	EncryptionKeySharingEnabled bool // true or false
}

type LTPAMetadata

type LTPAMetadata struct {
	Kind       string
	APIVersion string
	Name       string
	Path       string
	PathIndex  string
}

func (LTPAMetadata) GetAPIVersion

func (m LTPAMetadata) GetAPIVersion() string

func (LTPAMetadata) GetKind

func (m LTPAMetadata) GetKind() string

func (LTPAMetadata) GetName

func (m LTPAMetadata) GetName() string

func (LTPAMetadata) GetPath

func (m LTPAMetadata) GetPath() string

func (LTPAMetadata) GetPathIndex

func (m LTPAMetadata) GetPathIndex() string

type LTPAMetadataList

type LTPAMetadataList struct {
	Items []LeaderTrackerMetadata
}

func (LTPAMetadataList) GetItems

func (ml LTPAMetadataList) GetItems() []LeaderTrackerMetadata

type LeaderTracker

type LeaderTracker struct {
	Name      string
	Owner     string
	PathIndex string
	Path      string
	Sublease  string
}

func (*LeaderTracker) ClearOwnerIfMatching

func (tracker *LeaderTracker) ClearOwnerIfMatching(instance string) bool

Clears the LeaderTracker owner if it matches instance, returning true if the LeaderTracker has changed and false otherwise

func (*LeaderTracker) ClearOwnerIfMatchingAndSharesLastPathParent

func (tracker *LeaderTracker) ClearOwnerIfMatchingAndSharesLastPathParent(instance string, path string) bool

func (*LeaderTracker) EvictOwner

func (tracker *LeaderTracker) EvictOwner() bool

Removes the Owner and Sublease attribute from LeaderTracker to indicate the resource is no longer being tracked

func (*LeaderTracker) EvictOwnerIfSubleaseHasExpired

func (tracker *LeaderTracker) EvictOwnerIfSubleaseHasExpired() bool

func (*LeaderTracker) RenewSublease

func (tracker *LeaderTracker) RenewSublease() bool

func (*LeaderTracker) SetOwner

func (tracker *LeaderTracker) SetOwner(instance string) bool

type LeaderTrackerMetadata

type LeaderTrackerMetadata interface {
	GetKind() string
	GetAPIVersion() string
	GetName() string
	GetPath() string
	GetPathIndex() string
}

type LeaderTrackerMetadataList

type LeaderTrackerMetadataList interface {
	GetItems() []LeaderTrackerMetadata
}

type PasswordEncryptionMetadata

type PasswordEncryptionMetadata struct {
	Kind       string
	APIVersion string
	Name       string
	Path       string
	PathIndex  string
}

func (PasswordEncryptionMetadata) GetAPIVersion

func (m PasswordEncryptionMetadata) GetAPIVersion() string

func (PasswordEncryptionMetadata) GetKind

func (m PasswordEncryptionMetadata) GetKind() string

func (PasswordEncryptionMetadata) GetName

func (m PasswordEncryptionMetadata) GetName() string

func (PasswordEncryptionMetadata) GetPath

func (m PasswordEncryptionMetadata) GetPath() string

func (PasswordEncryptionMetadata) GetPathIndex

func (m PasswordEncryptionMetadata) GetPathIndex() string

type PasswordEncryptionMetadataList

type PasswordEncryptionMetadataList struct {
	Items []LeaderTrackerMetadata
}

func (PasswordEncryptionMetadataList) GetItems

type RegisterData

type RegisterData struct {
	DiscoveryURL            string
	RouteURL                string
	RedirectToRPHostAndPort string
	ProviderId              string
	Scopes                  string
	GrantTypes              string
	InitialAccessToken      string
	InitialClientId         string
	InitialClientSecret     string
	RegistrationURL         string
	InsecureTLS             bool
}

Jump to

Keyboard shortcuts

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