Documentation
¶
Index ¶
- Constants
- func ApplyClusterIDLabel(ep *prometheusoperatorv1.Endpoint, clusterID string)
- func ApplyClusterIDLabelToPodMonitor(ep *prometheusoperatorv1.PodMetricsEndpoint, clusterID string)
- func ApplyClusterIDLabelToRecordingRule(rule *prometheusoperatorv1.Rule, clusterID string)
- func Compress(payload []byte) (*bytes.Buffer, error)
- func CompressAndEncode(payload []byte) (*bytes.Buffer, error)
- func ComputeHash(s string) string
- func ConfigOAuthEnabled(authentication *configv1.AuthenticationSpec) bool
- func ConvertImageRegistryOverrideStringToMap(envVar string) map[string][]string
- func ConvertOpenShiftImageRegistryOverridesToCommandLineFlag(registryOverrides map[string][]string) string
- func ConvertRegistryOverridesToCommandLineFlag(registryOverrides map[string]string) string
- func CountAvailableNodes(ctx context.Context, client client.Client) (int32, error)
- func DecodeAndDecompress(payload []byte) (*bytes.Buffer, error)
- func DetermineHostedClusterPayloadArch(ctx context.Context, c client.Client, hc *hyperv1.HostedCluster, ...) (hyperv1.PayloadArchType, error)
- func EnableIfCustomKubeconfig(hcp *hyperv1.HostedControlPlane) bool
- func GenerateReconciliationActiveCondition(pausedUntilField *string, objectGeneration int64) metav1.Condition
- func GetControlPlaneOperatorImage(ctx context.Context, hc *hyperv1.HostedCluster, ...) (string, error)
- func GetControlPlaneOperatorImageLabels(ctx context.Context, hc *hyperv1.HostedCluster, ...) (map[string]string, error)
- func GetKubeClientSet() (kubeclient.Interface, error)
- func GetMgmtClusterCPUArch(kc kubeclient.Interface) (string, error)
- func GetPayloadImage(ctx context.Context, releaseImageProvider releaseinfo.Provider, ...) (string, error)
- func GetPayloadImageFromRelease(ctx context.Context, releaseImageProvider releaseinfo.Provider, release string, ...) (string, error)
- func GetPayloadVersion(ctx context.Context, releaseImageProvider releaseinfo.Provider, ...) (*semver.Version, error)
- func GetPullSecretBytes(ctx context.Context, c client.Client, hc *hyperv1.HostedCluster) ([]byte, error)
- func GetRegistryOverrides(ctx context.Context, ref reference.DockerImageReference, source, mirror string) (*reference.DockerImageReference, bool, error)
- func GetRepoSetup(ctx context.Context, imageRef string, pullSecret []byte) (distribution.Repository, *reference.DockerImageReference, error)
- func HCControlPlaneReleaseImage(hcluster *hyperv1.HostedCluster) string
- func HCOAuthEnabled(hc *hyperv1.HostedCluster) bool
- func HCPControlPlaneReleaseImage(hcp *hyperv1.HostedControlPlane) string
- func HCPOAuthEnabled(hcp *hyperv1.HostedControlPlane) bool
- func HashBytes(data []byte) (string, error)
- func HashSimple(o interface{}) string
- func HashStruct(data interface{}) (string, error)
- func HashStructWithJSONMapper(data interface{}, mapper JSONMapper) (string, error)
- func ImageLabels(metadata *dockerv1client.DockerImageConfig) map[string]string
- func InsecureHTTPClient() *http.Client
- func IsReconciliationPaused(logr logr.Logger, pausedUntilField *string) (bool, time.Duration)
- func LookupMappedImage(ctx context.Context, ocpOverrides map[string][]string, image string, ...) (string, error)
- func MapsDiff(current, input map[string]string) (changed map[string]string, deleted map[string]string, different bool)
- func ParseNamespacedName(name string) types.NamespacedName
- func PredicatesForHostedClusterAnnotationScoping(r client.Reader) predicate.Predicate
- func ProcessPausedUntilField(pausedUntilField *string, now time.Time) (isPaused bool, duration time.Duration, err error)
- func RemoveEmptyJSONField(stringData string, field string) string
- func SanitizeIgnitionPayload(payload []byte) error
- func StringListContains(list string, s string) bool
- type CleanupTracker
- func (t *CleanupTracker) GetFailureCount(hcpKey string) int
- func (t *CleanupTracker) GetFirstFailureTime(hcpKey string) time.Time
- func (t *CleanupTracker) RecordFailure(hcpKey string)
- func (t *CleanupTracker) ResetFailures(hcpKey string)
- func (t *CleanupTracker) ShouldSkipCleanup(ctx context.Context, hcp *hyperv1.HostedControlPlane, cpClient client.Client) (bool, string, error)
- type GetMetadataFn
- type ImageMetadataProvider
- type JSONMapper
- type MirrorAvailabilityCache
- type RegistryClientImageMetadataProvider
- func (r *RegistryClientImageMetadataProvider) GetDigest(ctx context.Context, imageRef string, pullSecret []byte) (digest.Digest, *reference.DockerImageReference, error)
- func (r *RegistryClientImageMetadataProvider) GetManifest(ctx context.Context, imageRef string, pullSecret []byte) (distribution.Manifest, error)
- func (r *RegistryClientImageMetadataProvider) GetMetadata(ctx context.Context, imageRef string, pullSecret []byte) (*dockerv1client.DockerImageConfig, []distribution.Descriptor, ...)
- func (r *RegistryClientImageMetadataProvider) GetOverride(ctx context.Context, imageRef string, pullSecret []byte) (*reference.DockerImageReference, error)
- func (r *RegistryClientImageMetadataProvider) ImageMetadata(ctx context.Context, imageRef string, pullSecret []byte) (*dockerv1client.DockerImageConfig, error)
Constants ¶
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 )
Variables ¶
This section is empty.
Functions ¶
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 CompressAndEncode ¶
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 ConfigOAuthEnabled ¶ added in v0.1.16
func ConfigOAuthEnabled(authentication *configv1.AuthenticationSpec) bool
func ConvertImageRegistryOverrideStringToMap ¶ added in v0.1.10
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
ConvertRegistryOverridesToCommandLineFlag converts a map of registry sources and their mirrors into a string
func CountAvailableNodes ¶ added in v0.1.71
CountAvailableNodes counts the number of available nodes in the cluster. Available nodes are defined as Ready nodes that are not cordoned (Unschedulable).
func DecodeAndDecompress ¶
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 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 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 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):
- The image specified by the ControlPlaneOperatorImageAnnotation on the HostedCluster resource itself
- The hypershift image specified in the release payload indicated by the HostedCluster's release field
- The hypershift-operator's own image for release versions 4.9 and 4.10
- 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):
- The labels specified by the ControlPlaneOperatorImageLabelsAnnotation on the HostedCluster resource itself
- The image labels in the medata of the image as resolved by GetControlPlaneOperatorImage
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 GetPayloadImage ¶
func GetPayloadImage(ctx context.Context, releaseImageProvider releaseinfo.Provider, hc *hyperv1.HostedCluster, component string, pullSecret []byte) (string, error)
func GetPayloadImageFromRelease ¶ added in v0.1.73
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 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 HashBytes ¶ added in v0.1.55
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 ¶
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 ImageLabels ¶
func ImageLabels(metadata *dockerv1client.DockerImageConfig) map[string]string
ImageLabels returns labels on a given image metadata
func InsecureHTTPClient ¶ added in v0.1.10
InsecureHTTPClient return a http.Client which skips server certificate verification
func IsReconciliationPaused ¶
IsReconciliationPaused checks the pauseUntil field to see if reconciliation on the resource should be paused and for how long.
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 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 PredicatesForHostedClusterAnnotationScoping ¶ added in v0.1.24
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 RemoveEmptyJSONField ¶ added in v0.1.55
RemoveEmptyJSONField removes a field from a given JSON if it's empty regardless of its position
func SanitizeIgnitionPayload ¶ added in v0.1.48
SanitizeIgnitionPayload make sure the IgnitionPayload is valid and does not contain inconsistencies.
func StringListContains ¶
Contains checks if a comma-delimited string contains a specific string.
Types ¶
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 GetMetadataFn ¶ added in v0.1.70
type GetMetadataFn func(context.Context, string, []byte) (*dockerv1client.DockerImageConfig, []distribution.Descriptor, distribution.BlobStore, error)
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
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 RegistryClientImageMetadataProvider ¶
type RegistryClientImageMetadataProvider struct {
OpenShiftImageRegistryOverrides map[string][]string
// contains filtered or unexported fields
}
func (*RegistryClientImageMetadataProvider) GetDigest ¶ added in v0.1.53
func (r *RegistryClientImageMetadataProvider) GetDigest(ctx context.Context, imageRef string, pullSecret []byte) (digest.Digest, *reference.DockerImageReference, error)
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 (r *RegistryClientImageMetadataProvider) GetMetadata(ctx context.Context, imageRef string, pullSecret []byte) (*dockerv1client.DockerImageConfig, []distribution.Descriptor, distribution.BlobStore, error)
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.