util

package
v0.1.71 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 77 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxCleanupFailures is the maximum number of consecutive connection failures before skipping cleanup
	MaxCleanupFailures = 5
	// MaxCleanupFailureDuration is the maximum duration of connection failures before skipping cleanup
	MaxCleanupFailureDuration = 5 * time.Minute
)
View Source
const (
	KubeconfigKey        = "kubeconfig"
	AWSCloudProviderName = "aws"
)
View Source
const (

	// CPOImageName is the name under which components can find the CPO image in the release image..
	CPOImageName = "controlplane-operator"

	// CPPKIOImageName is the name under which components can find the CP PKI Operator image in the release image..
	CPPKIOImageName = "controlplane-pki-operator"

	// AvailabilityProberImageName is the name under which components can find the availability prober
	// image in the release image.
	AvailabilityProberImageName = "availability-prober"

	// PodTmpDirMountName is a name for a volume created in each pod by the CPO that gives the pods containers a place to mount and write temporary files to.
	PodTmpDirMountName = "tmp-dir"
	// PodTmpDirMountPath is the path that each container created by the CPO will mount the volume PodTmpDirMountName at.
	PodTmpDirMountPath = "/tmp"
)
View Source
const (
	// DebugDeploymentsAnnotation contains a comma separated list of deployment names which should always be scaled to 0
	// for development.
	DebugDeploymentsAnnotation               = "hypershift.openshift.io/debug-deployments"
	EnableHostedClustersAnnotationScopingEnv = "ENABLE_HOSTEDCLUSTERS_ANNOTATION_SCOPING"
	HostedClustersScopeAnnotationEnv         = "HOSTEDCLUSTERS_SCOPE_ANNOTATION"
	HostedClustersScopeAnnotation            = "hypershift.openshift.io/scope"
	HostedClusterAnnotation                  = "hypershift.openshift.io/cluster"
)
View Source
const HCPRouteLabel = "hypershift.openshift.io/hosted-control-plane"
View Source
const InternalRouteLabel = "hypershift.openshift.io/internal-route"

Variables

View Source
var (
	BaseResources = []client.Object{
		&capiv1.Cluster{},
	}

	AWSResources = []client.Object{
		&capiaws.AWSCluster{},
		&hyperv1.AWSEndpointService{},
	}

	AzureResources = []client.Object{
		&capiazure.AzureCluster{},
		&capiazure.AzureClusterIdentity{},
	}

	ManagedAzure = []client.Object{
		&secretsstorev1.SecretProviderClass{},
	}

	IBMCloudResources = []client.Object{
		&capiibmv1.IBMVPCCluster{},
	}

	KubevirtResources = []client.Object{
		&capikubevirt.KubevirtCluster{},
	}

	AgentResources = []client.Object{
		&agentv1.AgentCluster{},
	}

	OpenStackResources = []client.Object{
		&capiopenstackv1beta1.OpenStackCluster{},
	}

	AWSNodePoolResources = []client.Object{
		&capiaws.AWSMachineTemplate{},
	}

	AzureNodePoolResources = []client.Object{
		&capiazure.AzureMachineTemplate{},
	}

	AgentNodePoolResources = []client.Object{
		&agentv1.AgentMachineTemplate{},
	}

	OpenStackNodePoolResources = []client.Object{
		&capiopenstackv1beta1.OpenStackMachineTemplate{},
	}
)

Functions

func APIPortForLocalZone added in v0.1.40

func APIPortForLocalZone(isLBKAS bool) int32

APIPortForLocalZone returns the port used by processes within a private hosted cluster to communicate with the KAS via the api.<hc-name>.hypershift.local host.

func AddHCPRouteLabel

func AddHCPRouteLabel(target crclient.Object)

func AddInternalRouteLabel

func AddInternalRouteLabel(target crclient.Object)

func AdvertiseAddress

func AdvertiseAddress(hcp *hyperv1.HostedControlPlane) *string

func AdvertiseAddressWithDefault

func AdvertiseAddressWithDefault(hcp *hyperv1.HostedControlPlane, defaultValue string) string

func AllowedCIDRBlocks

func AllowedCIDRBlocks(hcp *hyperv1.HostedControlPlane) []string

func ApplyAWSLoadBalancerTargetNodesAnnotation added in v0.1.60

func ApplyAWSLoadBalancerTargetNodesAnnotation(svc *corev1.Service, hcp *hyperv1.HostedControlPlane)

func ApplyCloudProviderCreds

func ApplyCloudProviderCreds(
	podSpec *corev1.PodSpec,
	cloudProvider string,
	cloudProviderCreds *corev1.LocalObjectReference,
	tokenMinterImage string,
	containerName string,
)

func ApplyClusterIDLabel

func ApplyClusterIDLabel(ep *prometheusoperatorv1.Endpoint, clusterID string)

func ApplyClusterIDLabelToPodMonitor

func ApplyClusterIDLabelToPodMonitor(ep *prometheusoperatorv1.PodMetricsEndpoint, clusterID string)

func ApplyClusterIDLabelToRecordingRule

func ApplyClusterIDLabelToRecordingRule(rule *prometheusoperatorv1.Rule, clusterID string)

func AvailabilityProber

func AvailabilityProber(target string, image string, spec *corev1.PodSpec, o ...AvailabilityProberOpt)

func BuildContainer

func BuildContainer(container *corev1.Container, buildFn func(*corev1.Container)) corev1.Container

func BuildProjectedVolume added in v0.1.34

func BuildProjectedVolume(volume *corev1.Volume, volumeProjection []corev1.VolumeProjection, buildFn func(*corev1.Volume, []corev1.VolumeProjection)) corev1.Volume

func BuildVolume

func BuildVolume(volume *corev1.Volume, buildFn func(*corev1.Volume)) corev1.Volume

func ClusterCIDRs

func ClusterCIDRs(clusterNetwork []hyperv1.ClusterNetworkEntry) []string

func CollectLBMessageIfNotProvisioned

func CollectLBMessageIfNotProvisioned(svc *corev1.Service, messageCollector events.MessageCollector) (string, error)

func Compress

func Compress(payload []byte) (*bytes.Buffer, error)

Compress compresses a given byte array.

func CompressAndEncode

func CompressAndEncode(payload []byte) (*bytes.Buffer, error)

CompressAndEncode compresses and base-64 encodes a given byte array. Ideal for loading an arbitrary byte array into a ConfigMap or Secret.

func ComputeHash

func ComputeHash(s string) string

func ConfigOAuthEnabled added in v0.1.16

func ConfigOAuthEnabled(authentication *configv1.AuthenticationSpec) bool

func ConnectsThroughInternetToControlplane

func ConnectsThroughInternetToControlplane(platform hyperv1.PlatformSpec) bool

HasPrivateAPIServerConnectivity determines if workloads running inside the guest cluster can access the apiserver without using the Internet.

func ConvertImageRegistryOverrideStringToMap added in v0.1.10

func ConvertImageRegistryOverrideStringToMap(envVar string) map[string][]string

ConvertImageRegistryOverrideStringToMap translates the environment variable containing registry source to mirror mappings back to a map[string]string structure that can be ingested by the registry image content policies release provider

func ConvertOpenShiftImageRegistryOverridesToCommandLineFlag added in v0.1.10

func ConvertOpenShiftImageRegistryOverridesToCommandLineFlag(registryOverrides map[string][]string) string

ConvertOpenShiftImageRegistryOverridesToCommandLineFlag converts a map of image registry sources and their mirrors into a string

func ConvertRegistryOverridesToCommandLineFlag added in v0.1.10

func ConvertRegistryOverridesToCommandLineFlag(registryOverrides map[string]string) string

ConvertRegistryOverridesToCommandLineFlag converts a map of registry sources and their mirrors into a string

func CopyConfigMap

func CopyConfigMap(cm, source *corev1.ConfigMap)

CopyConfigMap copies the .Data field of configMap `source` into configmap `cm`

func CountAvailableNodes added in v0.1.71

func CountAvailableNodes(ctx context.Context, client client.Client) (int32, error)

CountAvailableNodes counts the number of available nodes in the cluster. Available nodes are defined as Ready nodes that are not cordoned (Unschedulable).

func CreateTokenForServiceAccount added in v0.1.2

func CreateTokenForServiceAccount(ctx context.Context, serviceAccount *corev1.ServiceAccount, client *kubernetes.Clientset) (string, error)

func DecodeAndDecompress

func DecodeAndDecompress(payload []byte) (*bytes.Buffer, error)

DecodeAndDecompress decompresses and base-64 decodes a given byte array. Ideal for consuming a gzipped / base64-encoded byte array from a ConfigMap or Secret.

func DefaultTokenMinterResources added in v0.1.49

func DefaultTokenMinterResources() corev1.ResourceRequirements

func DeleteIfNeeded

func DeleteIfNeeded(ctx context.Context, c client.Client, o client.Object) (exists bool, err error)

func DeleteIfNeededWithOptions added in v0.1.47

func DeleteIfNeededWithOptions(ctx context.Context, c client.Client, o client.Object, opts ...client.DeleteOption) (exists bool, err error)

func DeleteIfNeededWithPredicate added in v0.1.68

func DeleteIfNeededWithPredicate[T client.Object](ctx context.Context, c client.Client, o T, predicate func(T) bool) (exists bool, err error)

func DeploymentAddKubevirtInfraCredentials added in v0.1.10

func DeploymentAddKubevirtInfraCredentials(deployment *appsv1.Deployment)

func DeploymentAddOpenShiftTrustedCABundleConfigMap added in v0.1.13

func DeploymentAddOpenShiftTrustedCABundleConfigMap(deployment *appsv1.Deployment)

func DeploymentAddTrustBundleVolume

func DeploymentAddTrustBundleVolume(trustBundleConfigMap *corev1.LocalObjectReference, deployment *appsv1.Deployment)

func DeserializeResource

func DeserializeResource(data string, resource runtime.Object, objectTyper runtime.ObjectTyper) error

func DetermineHostedClusterPayloadArch added in v0.1.48

func DetermineHostedClusterPayloadArch(ctx context.Context, c client.Client, hc *hyperv1.HostedCluster, imageMetadataProvider ImageMetadataProvider) (hyperv1.PayloadArchType, error)

DetermineHostedClusterPayloadArch returns the HostedCluster payload's CPU architecture type

func EnableIfCustomKubeconfig added in v0.1.58

func EnableIfCustomKubeconfig(hcp *hyperv1.HostedControlPlane) bool

EnableIfCustomKubeconfig returns true if the hosted control plane has a custom kubeconfig defined

func EnforceRestrictedSecurityContextToContainers added in v0.1.71

func EnforceRestrictedSecurityContextToContainers(podSpec *corev1.PodSpec) error

EnforceRestrictedSecurityContextToContainers enforces restricted pod security standards on all containers and init containers in a PodSpec. Only NET_BIND_SERVICE capability is allowed.

func EnsureOwnerRef

func EnsureOwnerRef(resource client.Object, ownerRef *metav1.OwnerReference)

func EnsurePullSecret

func EnsurePullSecret(serviceAccount *corev1.ServiceAccount, secretName string)

func FindContainer

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

func FindJobCondition added in v0.1.58

func FindJobCondition(object *batchv1.Job, conditionType batchv1.JobConditionType) *batchv1.JobCondition

func FirstClusterCIDR

func FirstClusterCIDR(clusterNetwork []hyperv1.ClusterNetworkEntry) string

func FirstServiceCIDR

func FirstServiceCIDR(serviceNetwork []hyperv1.ServiceNetworkEntry) string

func FirstUsableIP added in v0.1.10

func FirstUsableIP(cidr string) (string, error)

FirstUsableIP returns the first usable IP in both, IPv4 and IPv6 stacks.

func GenerateReconciliationActiveCondition

func GenerateReconciliationActiveCondition(pausedUntilField *string, objectGeneration int64) metav1.Condition

GenerateReconciliationActiveCondition will generate the resource condition that reflects the state of reconciliation on the resource.

func GetAdvertiseAddress added in v0.1.10

func GetAdvertiseAddress(hcp *hyperv1.HostedControlPlane, ipv4DefaultAddress, ipv6DefaultAddress string) string

func GetControlPlaneOperatorImage added in v0.1.55

func GetControlPlaneOperatorImage(ctx context.Context, hc *hyperv1.HostedCluster, releaseProvider releaseinfo.Provider, hypershiftOperatorImage string, pullSecret []byte) (string, error)

GetControlPlaneOperatorImage resolves the appropriate control plane operator image based on the following order of precedence (from most to least preferred):

  1. The image specified by the ControlPlaneOperatorImageAnnotation on the HostedCluster resource itself
  2. The hypershift image specified in the release payload indicated by the HostedCluster's release field
  3. The hypershift-operator's own image for release versions 4.9 and 4.10
  4. The registry.ci.openshift.org/hypershift/hypershift:4.8 image for release version 4.8

If no image can be found according to these rules, an error is returned.

func GetControlPlaneOperatorImageLabels added in v0.1.55

func GetControlPlaneOperatorImageLabels(ctx context.Context, hc *hyperv1.HostedCluster, controlPlaneOperatorImage string, pullSecret []byte, imageMetadataProvider ImageMetadataProvider) (map[string]string, error)

GetControlPlaneOperatorImageLabels resolves the appropriate control plane operator image labels based on the following order of precedence (from most to least preferred):

  1. The labels specified by the ControlPlaneOperatorImageLabelsAnnotation on the HostedCluster resource itself
  2. The image labels in the medata of the image as resolved by GetControlPlaneOperatorImage

func GetHostedClusterManagedResources added in v0.1.59

func GetHostedClusterManagedResources(platformsInstalled string) []client.Object

func GetKubeClientSet added in v0.1.48

func GetKubeClientSet() (kubeclient.Interface, error)

func GetMgmtClusterCPUArch added in v0.1.23

func GetMgmtClusterCPUArch(kc kubeclient.Interface) (string, error)

func GetNodePoolManagedResources added in v0.1.59

func GetNodePoolManagedResources(platformsInstalled string) []client.Object

func GetPayloadImage

func GetPayloadImage(ctx context.Context, releaseImageProvider releaseinfo.Provider, hc *hyperv1.HostedCluster, component string, pullSecret []byte) (string, error)

func GetPayloadVersion

func GetPayloadVersion(ctx context.Context, releaseImageProvider releaseinfo.Provider, hc *hyperv1.HostedCluster, pullSecret []byte) (*semver.Version, error)

func GetPullSecretBytes added in v0.1.48

func GetPullSecretBytes(ctx context.Context, c client.Client, hc *hyperv1.HostedCluster) ([]byte, error)

func GetRegistryOverrides added in v0.1.10

func GetRegistryOverrides(ctx context.Context, ref reference.DockerImageReference, source, mirror string) (*reference.DockerImageReference, bool, error)

func GetRepoSetup added in v0.1.53

func GetRepoSetup(ctx context.Context, imageRef string, pullSecret []byte) (distribution.Repository, *reference.DockerImageReference, error)

GetRepoSetup connects to a repo and pulls the imageRef's docker image information from the repo. Returns the repo and the docker image.

func HCControlPlaneReleaseImage added in v0.1.10

func HCControlPlaneReleaseImage(hcluster *hyperv1.HostedCluster) string

func HCOAuthEnabled added in v0.1.16

func HCOAuthEnabled(hc *hyperv1.HostedCluster) bool

func HCPControlPlaneReleaseImage added in v0.1.10

func HCPControlPlaneReleaseImage(hcp *hyperv1.HostedControlPlane) string

func HCPOAuthEnabled added in v0.1.16

func HCPOAuthEnabled(hcp *hyperv1.HostedControlPlane) bool

func HasAnnotationWithValue added in v0.1.66

func HasAnnotationWithValue(obj metav1.Object, key, expectedValue string) bool

HasAnnotationWithValue checks if a Kubernetes object has a specific annotation with a given value.

func HashBytes added in v0.1.55

func HashBytes(data []byte) (string, error)

HashBytes takes a byte array and returns a 32-bit FNV-1a hashed version of the byte array as a string

func HashSimple added in v0.1.23

func HashSimple(o interface{}) string

HashSimple takes a value, typically a string, and returns a 32-bit FNV-1a hashed version of the value as a string

func HashStruct

func HashStruct(data interface{}) (string, error)

HashStruct takes a struct and returns a 32-bit FNV-1a hashed version of the struct as a string The struct is first marshaled to JSON before hashing

func HashStructWithJSONMapper added in v0.1.55

func HashStructWithJSONMapper(data interface{}, mapper JSONMapper) (string, error)

HashStructWithJSONMapper takes a struct and returns a 32-bit FNV-1a hashed version of the struct as a string after The struct is first marshaled to JSON before hashing. You can provide a JSONMapper that transforms the marshaled JSON before computing the hash or nil if no transformation is needed.

func HostFromURL added in v0.1.57

func HostFromURL(addr string) (string, error)

func ImageLabels

func ImageLabels(metadata *dockerv1client.DockerImageConfig) map[string]string

ImageLabels returns labels on a given image metadata

func InsecureHTTPClient added in v0.1.10

func InsecureHTTPClient() *http.Client

InsecureHTTPClient return a http.Client which skips server certificate verification

func IsDeploymentReady

func IsDeploymentReady(_ context.Context, deployment *appsv1.Deployment) bool

func IsDisableMultiNetwork added in v0.1.66

func IsDisableMultiNetwork(hcp *hyperv1.HostedControlPlane) bool

IsDisableMultiNetwork returns true if multus/multi-network is disabled for the hosted control plane. When DisableMultiNetwork is nil, it defaults to false (multus enabled).

func IsIPv4Address added in v0.1.53

func IsIPv4Address(input string) (bool, error)

IsIPv4Address checks if the input string is an IPv4 address.

func IsIPv4CIDR added in v0.1.53

func IsIPv4CIDR(input string) (bool, error)

IsIPv4CIDR checks if the input string is an IPv4 CIDR.

func IsLBKAS added in v0.1.40

func IsLBKAS(hcp *hyperv1.HostedControlPlane) bool

func IsLBKASByHC added in v0.1.40

func IsLBKASByHC(hc *hyperv1.HostedCluster) bool

func IsPrivateHC

func IsPrivateHC(hc *hyperv1.HostedCluster) bool

func IsPrivateHCP

func IsPrivateHCP(hcp *hyperv1.HostedControlPlane) bool

func IsPublicHC added in v0.1.10

func IsPublicHC(hc *hyperv1.HostedCluster) bool

func IsPublicHCP

func IsPublicHCP(hcp *hyperv1.HostedControlPlane) bool

func IsPublicWithDNS added in v0.1.67

func IsPublicWithDNS(hcp *hyperv1.HostedControlPlane) bool

func IsPublicWithDNSByHC added in v0.1.67

func IsPublicWithDNSByHC(hc *hyperv1.HostedCluster) bool

func IsReconciliationPaused

func IsReconciliationPaused(logr logr.Logger, pausedUntilField *string) (bool, time.Duration)

IsReconciliationPaused checks the pauseUntil field to see if reconciliation on the resource should be paused and for how long.

func IsRoute added in v0.1.67

func IsRoute(hcp *hyperv1.HostedControlPlane, svcType hyperv1.ServiceType) bool

func IsRouteByHC added in v0.1.67

func IsRouteByHC(hc *hyperv1.HostedCluster, svcType hyperv1.ServiceType) bool

func IsRouteKAS

func IsRouteKAS(hcp *hyperv1.HostedControlPlane) bool

func IsStatefulSetReady added in v0.1.9

func IsStatefulSetReady(_ context.Context, statefulSet *appsv1.StatefulSet) bool

func KASPodPort added in v0.1.16

func KASPodPort(hcp *hyperv1.HostedControlPlane) int32

KASPodPort will retrieve the port the kube-apiserver binds on locally in the pod. This comes from hcp.Spec.Networking.APIServer.Port if set and != 443 or defaults to 6443.

func KASPodPortFromHostedCluster added in v0.1.16

func KASPodPortFromHostedCluster(hc *hyperv1.HostedCluster) int32

KASPodPortFromHostedCluster will retrieve the port the kube-apiserver binds on locally in the pod. This comes from hcp.Spec.Networking.APIServer.Port if set and != 443 or defaults to 6443.

func LookupMappedImage added in v0.1.70

func LookupMappedImage(ctx context.Context, ocpOverrides map[string][]string, image string, pullSecretBytes []byte, getMetadataFn GetMetadataFn) (string, error)

LookupMappedImage looks up a mapped image based on OCP overrides by allowing tests to control the image availability check without reaching out to actual registries

func MachineCIDRs

func MachineCIDRs(machineNetwork []hyperv1.MachineNetworkEntry) []string

func MachineNetworksToList added in v0.1.52

func MachineNetworksToList(machineNetwork []hyperv1.MachineNetworkEntry) string

MachineNetworksToList converts a list of MachineNetworkEntry to a comma separated list of CIDRs.

func MapsDiff added in v0.1.64

func MapsDiff(current, input map[string]string) (changed map[string]string, deleted map[string]string, different bool)

MapsDiff compares two maps and returns a map of changed/created keys with their new values, a map of deleted keys, and a boolean indicating if there are any differences.

func ParseNamespacedName

func ParseNamespacedName(name string) types.NamespacedName

ParseNamespacedName expects a string with the format "namespace/name" and returns the proper types.NamespacedName. This is useful when watching a CR annotated with the format above to requeue the CR described in the annotation.

func ParseNodeSelector added in v0.1.22

func ParseNodeSelector(str string) map[string]string

ParseNodeSelector parses a comma separated string of key=value pairs into a map

func PredicatesForHostedClusterAnnotationScoping added in v0.1.24

func PredicatesForHostedClusterAnnotationScoping(r client.Reader) predicate.Predicate

PredicatesForHostedClusterAnnotationScoping returns predicate filters for all event types that will ignore incoming event requests for resources in which the parent hostedcluster does not match the "scope" annotation specified in the HOSTEDCLUSTERS_SCOPE_ANNOTATION env var. If not defined or empty, the default behavior is to accept all events for hostedclusters that do not have the annotation. The ENABLE_HOSTEDCLUSTERS_ANNOTATION_SCOPING env var must also be set to "true" to enable the scoping feature.

func ProcessPausedUntilField

func ProcessPausedUntilField(pausedUntilField *string, now time.Time) (isPaused bool, duration time.Duration, err error)

ProcessPausedUntilField checks the pauseUntil field to see if reconciliation on the resource should be paused. Input can either be a date in RFC3339 format, or a Boolean. It returns a Boolean isPaused, a duration and an error. If the input is a date, a duration!=0 is returned so consumers can choose to requeueAfter it.

func ReconcileExternalRoute

func ReconcileExternalRoute(route *routev1.Route, hostname string, defaultIngressDomain string, serviceName string, labelHCPRoutes bool) error

func ReconcileInternalRoute

func ReconcileInternalRoute(route *routev1.Route, hcName string, serviceName string) error

func ReconcilePodDisruptionBudget added in v0.1.23

func ReconcilePodDisruptionBudget(pdb *policyv1.PodDisruptionBudget, availability hyperv1.AvailabilityPolicy)

func RemoveContainer added in v0.1.51

func RemoveContainer(name string, podSpec *corev1.PodSpec)

func RemoveEmptyJSONField added in v0.1.55

func RemoveEmptyJSONField(stringData string, field string) string

RemoveEmptyJSONField removes a field from a given JSON if it's empty regardless of its position

func RemoveInitContainer added in v0.1.51

func RemoveInitContainer(name string, podSpec *corev1.PodSpec)

func ResolveDNSHostname

func ResolveDNSHostname(ctx context.Context, hostName string) error

ResolveDNSHostname receives a hostname string and tries to resolve it. Returns error if the host can't be resolved.

func SanitizeIgnitionPayload added in v0.1.48

func SanitizeIgnitionPayload(payload []byte) error

SanitizeIgnitionPayload make sure the IgnitionPayload is valid and does not contain inconsistencies.

func SeekOverride added in v0.1.69

func SeekOverride(ctx context.Context, openshiftImageRegistryOverrides map[string][]string, parsedImageReference reference.DockerImageReference, pullSecret []byte) *reference.DockerImageReference

func SerializeResource

func SerializeResource(resource runtime.Object, objectTyper runtime.ObjectTyper) (string, error)

func ServiceCIDRs

func ServiceCIDRs(serviceNetwork []hyperv1.ServiceNetworkEntry) []string

func ServiceExternalDNSHostname

func ServiceExternalDNSHostname(hcp *hyperv1.HostedControlPlane, serviceType hyperv1.ServiceType) string

func ServiceExternalDNSHostnameByHC added in v0.1.10

func ServiceExternalDNSHostnameByHC(hc *hyperv1.HostedCluster, serviceType hyperv1.ServiceType) string

func ShortenName added in v0.1.40

func ShortenName(base, suffix string, maxLength int) string

ShortenName returns a name given a base ("deployment-5") and a suffix ("deploy") It will first attempt to join them with a dash. If the resulting name is longer than maxLength: if the suffix is too long, it will truncate the base name and add an 8-character hash of the [base]-[suffix] string. If the suffix is not too long, it will truncate the base, add the hash of the base and return [base]-hash-[suffix] Source: openshift/origin v3.9.0 pkg/api/apihelpers/namer.go

func ShortenRouteHostnameIfNeeded

func ShortenRouteHostnameIfNeeded(name, namespace string, baseDomain string) string

ShortenRouteHostnameIfNeeded will return a shortened hostname if the route hostname will exceed the allowed DNS name size. If the hostname is not too long, an empty string is returned so that the default can be used.

func StringListContains

func StringListContains(list string, s string) bool

Contains checks if a comma-delimited string contains a specific string.

func UpdateContainer added in v0.1.49

func UpdateContainer(name string, containers []corev1.Container, update func(c *corev1.Container))

func UpdateObject added in v0.1.66

func UpdateObject[T client.Object](ctx context.Context, c client.Client, obj T, mutate func() error) error

func UpdateVolume added in v0.1.49

func UpdateVolume(name string, volumes []corev1.Volume, update func(v *corev1.Volume))

func UpsertEnvVar added in v0.1.51

func UpsertEnvVar(c *corev1.Container, envVar corev1.EnvVar)

func UpsertEnvVars added in v0.1.56

func UpsertEnvVars(c *corev1.Container, envVars []corev1.EnvVar)

func UseDedicatedDNS added in v0.1.67

func UseDedicatedDNS(hcp *hyperv1.HostedControlPlane, svcType hyperv1.ServiceType) bool

func UseDedicatedDNSByHC added in v0.1.67

func UseDedicatedDNSByHC(hc *hyperv1.HostedCluster, svcType hyperv1.ServiceType) bool

func UseDedicatedDNSForIgnition added in v0.1.67

func UseDedicatedDNSForIgnition(hcp *hyperv1.HostedControlPlane) bool

func UseDedicatedDNSForKAS added in v0.1.67

func UseDedicatedDNSForKAS(hcp *hyperv1.HostedControlPlane) bool

func UseDedicatedDNSForKASByHC

func UseDedicatedDNSForKASByHC(hc *hyperv1.HostedCluster) bool

func UseDedicatedDNSForKonnectivity added in v0.1.67

func UseDedicatedDNSForKonnectivity(hcp *hyperv1.HostedControlPlane) bool

func UseDedicatedDNSForOAuth added in v0.1.67

func UseDedicatedDNSForOAuth(hcp *hyperv1.HostedControlPlane) bool

Types

type AvailabilityProberOpt

type AvailabilityProberOpt func(*AvailabilityProberOpts)

func WithOptions added in v0.1.49

type AvailabilityProberOpts

type AvailabilityProberOpts struct {
	KubeconfigVolumeName          string
	RequiredAPIs                  []schema.GroupVersionKind
	WaitForInfrastructureResource bool
	WaitForLabeledPodsGone        string
	WaitForClusterRolebinding     string
}

type CleanupTracker added in v0.1.70

type CleanupTracker struct {
	// contains filtered or unexported fields
}

CleanupTracker manages cleanup failure tracking for multiple HCPs

func NewCleanupTracker added in v0.1.70

func NewCleanupTracker() *CleanupTracker

NewCleanupTracker creates a new CleanupTracker

func (*CleanupTracker) GetFailureCount added in v0.1.70

func (t *CleanupTracker) GetFailureCount(hcpKey string) int

GetFailureCount returns the current failure count for a given HCP

func (*CleanupTracker) GetFirstFailureTime added in v0.1.70

func (t *CleanupTracker) GetFirstFailureTime(hcpKey string) time.Time

GetFirstFailureTime returns the first failure time for a given HCP

func (*CleanupTracker) RecordFailure added in v0.1.70

func (t *CleanupTracker) RecordFailure(hcpKey string)

RecordFailure increments the failure count for a given HCP

func (*CleanupTracker) ResetFailures added in v0.1.70

func (t *CleanupTracker) ResetFailures(hcpKey string)

ResetFailures resets the failure tracking for a given HCP

func (*CleanupTracker) ShouldSkipCleanup added in v0.1.70

func (t *CleanupTracker) ShouldSkipCleanup(ctx context.Context, hcp *hyperv1.HostedControlPlane, cpClient client.Client) (bool, string, error)

ShouldSkipCleanup checks if cleanup should be skipped based on failure count, duration, or KAS availability

type ContainerVolumeMounts

type ContainerVolumeMounts map[string]string

type GetMetadataFn added in v0.1.70

GetMetadataFn is a function type for checking image availability It takes a context, image reference, and pull secret, and returns image metadata or an error

type ImageMetadataProvider

type ImageMetadataProvider interface {
	ImageMetadata(ctx context.Context, imageRef string, pullSecret []byte) (*dockerv1client.DockerImageConfig, error)
	GetManifest(ctx context.Context, imageRef string, pullSecret []byte) (distribution.Manifest, error)
	GetDigest(ctx context.Context, imageRef string, pullSecret []byte) (digest.Digest, *reference.DockerImageReference, error)
	GetMetadata(ctx context.Context, imageRef string, pullSecret []byte) (*dockerv1client.DockerImageConfig, []distribution.Descriptor, distribution.BlobStore, error)
	GetOverride(ctx context.Context, imageRef string, pullSecret []byte) (*reference.DockerImageReference, error)
}

type JSONMapper added in v0.1.55

type JSONMapper func(jsonData []byte) []byte

func NewOmitFieldIfEmptyJSONMapper added in v0.1.55

func NewOmitFieldIfEmptyJSONMapper(field string) JSONMapper

NewOmitFieldIfEmptyJSONMapper is a JSONMapper that omits the given field in case it was empty.

type MirrorAvailabilityCache added in v0.1.71

type MirrorAvailabilityCache struct {
	// contains filtered or unexported fields
}

MirrorAvailabilityCache caches mirror availability results to prevent flapping

type PodVolumeMounts

type PodVolumeMounts map[string]ContainerVolumeMounts

func (PodVolumeMounts) ContainerMounts

func (m PodVolumeMounts) ContainerMounts(container string) []corev1.VolumeMount

func (PodVolumeMounts) Path

func (m PodVolumeMounts) Path(container, volume string) string

type RegistryClientImageMetadataProvider

type RegistryClientImageMetadataProvider struct {
	OpenShiftImageRegistryOverrides map[string][]string
}

func (*RegistryClientImageMetadataProvider) GetDigest added in v0.1.53

func (*RegistryClientImageMetadataProvider) GetManifest added in v0.1.53

func (r *RegistryClientImageMetadataProvider) GetManifest(ctx context.Context, imageRef string, pullSecret []byte) (distribution.Manifest, error)

GetManifest returns the manifest for a given image using the given pull secret to authenticate. The ICSPs/IDMSs are checked first for overrides and then the cache is checked using the image pull spec. If not found in the cache, the manifest is looked up and added to the cache.

func (*RegistryClientImageMetadataProvider) GetMetadata added in v0.1.53

func (*RegistryClientImageMetadataProvider) GetOverride added in v0.1.53

func (r *RegistryClientImageMetadataProvider) GetOverride(ctx context.Context, imageRef string, pullSecret []byte) (*reference.DockerImageReference, error)

GetOverride returns the image reference override based on the source/mirrors in the ICSPs/IDMSs

func (*RegistryClientImageMetadataProvider) ImageMetadata

func (r *RegistryClientImageMetadataProvider) ImageMetadata(ctx context.Context, imageRef string, pullSecret []byte) (*dockerv1client.DockerImageConfig, error)

ImageMetadata returns metadata for a given image using the given pull secret to authenticate. The ICSPs/IDMSs are checked first for overrides and then the cache is checked using the image pull spec. If not found in the cache, the manifest is looked up and added to the cache.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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