Help us shape the future of Go! Take the 2026 Go Developer Survey

argoutil

package
v0.0.0-...-da817c1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RedisAuthVolumeName = "redis-initial-pass"
	RedisAuthMountPath  = "/app/config/redis-auth/"
)
View Source
const OperatorNamespaceFile = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"

Variables

This section is empty.

Functions

func AddTrackedByOperatorLabel

func AddTrackedByOperatorLabel(meta *metav1.ObjectMeta)

AddTrackedByOperatorLabel adds the ArgoCDTrackedByOperator label to the resource

func AgentTLSProtocolVersionString

func AgentTLSProtocolVersionString(v configv1.TLSProtocolVersion) string

func AnnotationsForCluster

func AnnotationsForCluster(cr *argoproj.ArgoCD) map[string]string

AnnotationsForCluster returns the annotations for all cluster resources.

func AppendStringMap

func AppendStringMap(src map[string]string, add map[string]string) map[string]string

AppendStringMap will append the map `add` to the given map `src` and return the result.

func CheckClusterRoleBindingOwnership

func CheckClusterRoleBindingOwnership(clusterRoleBinding *v1.ClusterRoleBinding, cr *argoproj.ArgoCD) bool

func CheckClusterRoleOwnership

func CheckClusterRoleOwnership(clusterRole *v1.ClusterRole, cr *argoproj.ArgoCD) bool

func CombineImageTag

func CombineImageTag(img string, tag string) string

CombineImageTag will return the combined image and tag in the proper format for tags and digests.

func CreateEvent

func CreateEvent(client client.Client, eventType, action, message, reason string, objectMeta metav1.ObjectMeta, typeMeta metav1.TypeMeta) error

CreateEvent will create a new Kubernetes Event with the given action, message, reason and involved uid.

func CreateSecret

func CreateSecret(client client.Client, name string, namespace string, data map[string][]byte) error

func CreateTLSSecret

func CreateTLSSecret(client client.Client, name string, namespace string, data map[string][]byte) error

func DecorateWithFIPSEnv

func DecorateWithFIPSEnv(in []corev1.EnvVar) []corev1.EnvVar

DecorateWithFIPSEnv adds environment variables required to enable FIPS in go runtime. If user has set this value already, this method does not override it. If the environment variable GODEBUG contains fips140=on, it will also set GOLANG_FIPS=0 as these two environments are mutually exclusive.

func DefaultPVCResources

func DefaultPVCResources() corev1.VolumeResourceRequirements

DefaultPVCResources will return the default PVC resources.

func DefaultSecurityContext

func DefaultSecurityContext() *v1.SecurityContext

func EncodeCertificatePEM

func EncodeCertificatePEM(cert *x509.Certificate) []byte

EncodeCertificatePEM encodes the given certificate pem and returns bytes (base64).

func EncodePrivateKeyPEM

func EncodePrivateKeyPEM(key *rsa.PrivateKey) []byte

EncodePrivateKeyPEM encodes the given private key pem and returns bytes (base64).

func EnvGet

func EnvGet(envs []corev1.EnvVar, name string) *corev1.EnvVar

EnvGet returns a pointer to the EnvVar with the given name, or nil if not found. The pointer refers into envs, so callers may update the entry in place.

func EnvMerge

func EnvMerge(existing []corev1.EnvVar, merge []corev1.EnvVar, override bool) []corev1.EnvVar

EnvMerge merges two slices of EnvVar entries into a single one. If existing has an EnvVar with same Name attribute as one in merge, the EnvVar is not merged unless override is set to true.

func EnvRemove

func EnvRemove(envs []corev1.EnvVar, name string) []corev1.EnvVar

EnvRemove returns a copy of envs with any EnvVar named name removed. Order of remaining entries is preserved.

func EnvSet

func EnvSet(envs []corev1.EnvVar, env corev1.EnvVar) []corev1.EnvVar

EnvSet returns a copy of envs with env upserted by Name: existing entry is replaced in place, otherwise env is appended. Order of other entries is preserved.

func FetchObject

func FetchObject(client client.Client, namespace string, name string, obj client.Object) error

FetchObject will retrieve the object with the given namespace and name using the Kubernetes API. The result will be stored in the given object.

func FetchSecret

func FetchSecret(client client.Client, meta metav1.ObjectMeta, name string) (*corev1.Secret, error)

FetchSecret will retrieve the object with the given Name using the provided client. The result will be returned.

func FetchStorageSecretName

func FetchStorageSecretName(export *argoprojv1alpha1.ArgoCDExport) string

FetchStorageSecretName will return the name of the Secret to use for the export process.

func FqdnServiceRef

func FqdnServiceRef(service string, port int, cr *argoproj.ArgoCD) string

FqdnServiceRef will return the FQDN referencing a specific service name, as set up by the operator, with the given port.

func GenerateAgentPrincipalRedisProxyServiceName

func GenerateAgentPrincipalRedisProxyServiceName(crName string) string

GenerateAgentPrincipalRedisProxyServiceName generates a deterministic Service name for the agent's principal Redis proxy. It truncates the Custom Resource (CR) name to ensure the final appended name stays within Kubernetes length limits.

func GetClusterDomain

func GetClusterDomain(cr *argoproj.ArgoCD) string

GetClusterDomain returns the cluster domain suffix for the given ArgoCD instance. If not specified in the CR, defaults to the standard cluster domain.

func GetImagePullPolicy

func GetImagePullPolicy(policy corev1.PullPolicy) corev1.PullPolicy

GetImagePullPolicy returns the effective image pull policy for Argo CD components. It follows this precedence: 1. Instance specific policy defined in the ArgoCD CR 2. Global policy defined via the IMAGE_PULL_POLICY environment variable 3. Default policy (IfNotPresent)

func GetMaxCRNameLength

func GetMaxCRNameLength() int

GetMaxCRNameLength returns the maximum length for ArgoCD CR names to accommodate longest suffix This is exposed for external packages that need to check CR name length

func GetMaxLabelLength

func GetMaxLabelLength() int

GetMaxLabelLength returns the maximum length for Kubernetes labels and names This is exposed for testing purposes

func GetMaxStatefulSetNameLength

func GetMaxStatefulSetNameLength() int

GetMaxStatefulSetNameLength returns the maximum length for StatefulSet names. This is exposed for testing purposes.

func GetOperatorNamespace

func GetOperatorNamespace() (string, error)

func GetRedisAuthEnv

func GetRedisAuthEnv() []corev1.EnvVar

func GetRedisConf

func GetRedisConf(useTLSForRedis bool) string

GetRedisConf will load the redis configuration from a template on disk for the given ArgoCD. If an error occurs, an empty string value will be returned.

func GetRedisContainerImage

func GetRedisContainerImage(cr *argoproj.ArgoCD) string

GetRedisContainerImage will return the container image for the Redis server.

func GetRedisHAContainerImage

func GetRedisHAContainerImage(cr *argoproj.ArgoCD) string

GetRedisHAContainerImage will return the container image for the Redis server in HA mode.

func GetRedisHAProxyConfig

func GetRedisHAProxyConfig(cr *argoproj.ArgoCD, useTLSForRedis bool, centralTLSConfigProfile tlsprofile.TLSConfigProfile) string

GetRedisHAProxyConfig will load the Redis HA Proxy configuration from a template on disk for the given ArgoCD. If an error occurs, an empty string value will be returned.

func GetRedisHAProxyContainerImage

func GetRedisHAProxyContainerImage(cr *argoproj.ArgoCD) string

GetRedisHAProxyContainerImage will return the container image for the Redis HA Proxy.

func GetRedisHAProxyScript

func GetRedisHAProxyScript(cr *argoproj.ArgoCD) string

GetRedisHAProxyScript will load the Redis HA Proxy init script from a template on disk for the given ArgoCD. If an error occurs, an empty string value will be returned.

func GetRedisHAReplicas

func GetRedisHAReplicas() *int32

func GetRedisHAResources

func GetRedisHAResources(cr *argoproj.ArgoCD) corev1.ResourceRequirements

GetRedisHAResources will return the ResourceRequirements for the Redis HA.

func GetRedisInitScript

func GetRedisInitScript(cr *argoproj.ArgoCD, useTLSForRedis bool) string

GetRedisInitScript will load the redis init script from a template on disk for the given ArgoCD. If an error occurs, an empty string value will be returned.

func GetRedisLivenessScript

func GetRedisLivenessScript(useTLSForRedis bool) string

GetRedisLivenessScript will load the redis liveness script from a template on disk for the given ArgoCD. If an error occurs, an empty string value will be returned.

func GetRedisReadinessScript

func GetRedisReadinessScript(useTLSForRedis bool) string

GetRedisReadinessScript will load the redis readiness script from a template on disk for the given ArgoCD. If an error occurs, an empty string value will be returned.

func GetRedisResources

func GetRedisResources(cr *argoproj.ArgoCD) corev1.ResourceRequirements

GetRedisResources will return the ResourceRequirements for the Redis container.

func GetRedisSecretData

func GetRedisSecretData(redisInitialPassword []byte) map[string][]byte

func GetRedisSentinelConf

func GetRedisSentinelConf(useTLSForRedis bool) string

GetRedisSentinelConf will load the redis sentinel configuration from a template on disk for the given ArgoCD. If an error occurs, an empty string value will be returned.

func GetRedisServerAddress

func GetRedisServerAddress(cr *argoproj.ArgoCD) string

GetRedisServerAddress will return the Redis service address for the given ArgoCD.

func GetSecretNameWithSuffix

func GetSecretNameWithSuffix(cr *argoproj.ArgoCD, suffix string) string

GetSecretNameWithSuffix returns the secret name using truncated CR name + full suffix. This function should be used when referencing secret names in other resources.

func GetSentinelLivenessScript

func GetSentinelLivenessScript(useTLSForRedis bool) string

GetSentinelLivenessScript will load the redis liveness script from a template on disk for the given ArgoCD. If an error occurs, an empty string value will be returned.

func GetTruncatedCRName

func GetTruncatedCRName(cr *argoproj.ArgoCD) string

GetTruncatedCRName returns the truncated CR name using the deterministic truncate function

func IsAPIRegistered

func IsAPIRegistered(group string, version string) (bool, error)

IsAPIRegistered returns true if the API is registered irrespective of whether the API status is available or not.

func IsNamespaceClusterConfigNamespace

func IsNamespaceClusterConfigNamespace(ns string) bool

func IsObjectFound

func IsObjectFound(client client.Client, namespace string, name string, obj client.Object) (bool, error)

IsObjectFound will perform a basic check that the given object exists via the Kubernetes API. If an error occurs as part of the check, the function will return false.

func IsRouteAPIAvailable

func IsRouteAPIAvailable() bool

IsRouteAPIAvailable returns true if the Route API is present.

func IsTrackedByOperator

func IsTrackedByOperator(labels map[string]string) bool

IsTrackedByOperator checks if the resource is tracked by the operator

func LabelsForCluster

func LabelsForCluster(cr *argoproj.ArgoCD) map[string]string

LabelsForCluster returns the labels for all cluster resources.

func LogResourceAction

func LogResourceAction(log logr.Logger, action string, object metav1.Object, explanations ...string)

func LogResourceCreation

func LogResourceCreation(log logr.Logger, object metav1.Object, explanations ...string)

func LogResourceDeletion

func LogResourceDeletion(log logr.Logger, object metav1.Object, explanations ...string)

func LogResourceUpdate

func LogResourceUpdate(log logr.Logger, object metav1.Object, explanations ...string)

func MapCipherSuites

func MapCipherSuites(names []string) []string

MapCipherSuites converts OpenSSL-style cipher names to their IANA equivalents (via library-go's canonical mapping), keeping only ciphers that Go's crypto/tls considers secure and can actually negotiate. TLS 1.3 ciphers are always included since Go negotiates them automatically and they aren't independently configurable.

func MapOpenShiftTLSGroupsToGoCurves

func MapOpenShiftTLSGroupsToGoCurves(groups []configv1.TLSGroup, component string) (string, error)

MapOpenShiftTLSGroupsToGoCurves converts OpenShift TLS groups to a colon-separated list of Go crypto/tls curve names (e.g. CurveP256, X25519) for Go-based components (gitops-backend, argocd-agent principal, etc.). Callers that need a different separator (e.g. commas for the agent principal ARGOCD_PRINCIPAL_TLS_CURVE_PREFERENCES) should replace ":" as needed. Unsupported groups are skipped and logged. If groups is non-empty but none are supported by Go, an error is returned so callers do not treat an incompatible profile as an absent preference.

func MapOpenShiftTLSGroupsToOpenSSL

func MapOpenShiftTLSGroupsToOpenSSL(groups []configv1.TLSGroup, component string) string

MapOpenShiftTLSGroupsToOpenSSL converts OpenShift TLS groups to a colon-separated OpenSSL Groups string. Unknown groups are skipped and logged. component is included in the log message to identify the caller (e.g. "Redis HAProxy", "gitops-plugin httpd").

func MountRedisAuthToArgo

func MountRedisAuthToArgo(cr *argoproj.ArgoCD) (volume corev1.Volume, mount corev1.VolumeMount)

MountRedisAuthToArgo mounts subset of redis secret for consumption by argocd components.

func MountRedisAuthToRedis

func MountRedisAuthToRedis(cr *argoproj.ArgoCD) (volume corev1.Volume, mount corev1.VolumeMount)

MountRedisAuthToRedis mounts entire redis secret for consumption by redis components.

func NameWithSuffix

func NameWithSuffix(meta metav1.ObjectMeta, suffix string) string

NameWithSuffix will return a name based on the given resource using the better truncation approach. The object name is truncated first, then the full suffix is appended to preserve suffix readability. Example: Given a long resource name, this ensures suffixes like "redis-initial-password" remain intact.

func NameWithSuffixForStatefulSet

func NameWithSuffixForStatefulSet(meta metav1.ObjectMeta, suffix string) string

NameWithSuffixForStatefulSet returns a StatefulSet name that stays within the Kubernetes label length limit after controller revision hash suffixes are applied. Preserves the original suffix when possible to maintain backward compatibility. Only abbreviates or truncates when the full name would exceed maxStatefulSetNameLength.

func NewPersistentVolumeClaim

func NewPersistentVolumeClaim(meta metav1.ObjectMeta) *corev1.PersistentVolumeClaim

NewPersistentVolumeClaim returns a new PersistentVolumeClaim instance for the ObjectMeta resource.

func NewPersistentVolumeClaimWithName

func NewPersistentVolumeClaimWithName(name string, meta metav1.ObjectMeta) *corev1.PersistentVolumeClaim

NewPersistentVolumeClaimWithName returns a new PersistentVolumeClaim instance with the given name.

func NewPrivateKey

func NewPrivateKey() (*rsa.PrivateKey, error)

NewPrivateKey returns randomly generated RSA private key.

func NewSecret

func NewSecret(cr *argoproj.ArgoCD) *corev1.Secret

NewSecret returns a new Secret based on the given metadata.

func NewSecretWithName

func NewSecretWithName(cr *argoproj.ArgoCD, name string) *corev1.Secret

NewSecretWithName returns a new Secret based on the given metadata with the provided Name.

func NewSecretWithSuffix

func NewSecretWithSuffix(cr *argoproj.ArgoCD, suffix string) *corev1.Secret

NewSecretWithSuffix returns a new Secret based on the given metadata with the provided suffix on the Name. This uses the better truncation approach: truncate CR name first, then append full suffix

func NewSelfSignedCACertificate

func NewSelfSignedCACertificate(name string, key *rsa.PrivateKey) (*x509.Certificate, error)

NewSelfSignedCACertificate returns a self-signed CA certificate based on given configuration and private key. The certificate has one-year lease.

func NewSignedCertificate

func NewSignedCertificate(cfg *certmanagerv1.CertificateSpec, dnsNames []string, key *rsa.PrivateKey, caCert *x509.Certificate, caKey *rsa.PrivateKey) (*x509.Certificate, error)

NewSignedCertificate signs a certificate using the given private key, CA and returns a signed certificate. The certificate could be used for both client and server auth. The certificate has one-year lease.

func NewTLSSecret

func NewTLSSecret(cr *argoproj.ArgoCD, suffix string) *corev1.Secret

NewTLSSecret returns a new TLS Secret based on the given metadata with the provided suffix on the Name.

func ParsePEMEncodedCert

func ParsePEMEncodedCert(pemdata []byte) (*x509.Certificate, error)

ParsePEMEncodedCert parses a certificate from the given pemdata

func ParsePEMEncodedPrivateKey

func ParsePEMEncodedPrivateKey(pemdata []byte) (*rsa.PrivateKey, error)

ParsePEMEncodedPrivateKey parses a private key from given pemdata

func RedisTLSProtocolVersionString

func RedisTLSProtocolVersionString(v configv1.TLSProtocolVersion) string

func SetRouteAPIFound

func SetRouteAPIFound(found bool)

func TLSProtocolVersionString

func TLSProtocolVersionString(v configv1.TLSProtocolVersion) string

func TruncateCRName

func TruncateCRName(crName string) string

TruncateCRName truncates an ArgoCD CR name to allow for the longest possible suffix This ensures that when suffixes like "redis-initial-password" are appended, the total length stays within Kubernetes 63-character limit

func TruncateWithHash

func TruncateWithHash(input string, maxLength int) string

TruncateWithHash truncates a string to a maximum length and adds a hash suffix to ensure uniqueness

func VerifyAPI

func VerifyAPI(group string, version string) (bool, error)

VerifyAPI will verify that the given group/version is present in the cluster.

func VerifyRouteAPI

func VerifyRouteAPI() error

VerifyRouteAPI will verify that the Route API is present.

Types

type FipsConfigChecker

type FipsConfigChecker interface {
	IsFipsEnabled() (bool, error)
}

FipsConfigChecker defines the behavior for reading the FIPS config.

type LinuxFipsConfigChecker

type LinuxFipsConfigChecker struct {
	ConfigFilePath string
}

LinuxFipsConfigChecker implements the config reader for checking if the Linux based host is running in FIPS enabled mode.

func NewLinuxFipsConfigChecker

func NewLinuxFipsConfigChecker() *LinuxFipsConfigChecker

NewLinuxFipsConfigChecker returns a Linux based config checker

func (*LinuxFipsConfigChecker) IsFipsEnabled

func (l *LinuxFipsConfigChecker) IsFipsEnabled() (bool, error)

IsFipsEnabled reads the specified FIPS config file in a Linux based host and returns true FIPS is enabled, false otherwise.

Jump to

Keyboard shortcuts

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