kubeapplierhelpers

package
v0.0.0-...-28a1ae5 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const ReadDesireNameServingCA = "systemadmincredential-serving-ca"

Variables

ReadDesireNameReadonlyHostedCluster is the well-known ReadDesire name the backend writes the per-cluster HostedCluster mirror under. Consumers look this up via a ReadDesireLister.GetForCluster call.

The value is the lowercased form of coreapi.MaestroBundleInternalNameReadonlyHypershiftHostedCluster — the same derivation the writer (create_cluster_scoped_read_desires_controller.go) uses for its desired ReadDesire name. Lowercased so the resourceID path reduces to a stable Cosmos key regardless of case.

View Source
var ReadDesireNameReadonlyHypershiftControlPlaneComponentClusterAutoscaler = strings.ToLower(string(coreapi.ReadonlyHypershiftControlPlaneComponentClusterAutoscaler))

ReadDesireNameReadonlyHypershiftControlPlaneComponentClusterAutoscaler is the well-known ReadDesire name the backend writes the per-cluster cluster-autoscaler ControlPlaneComponent mirror under.

ReadDesireNameReadonlyNodePool is the well-known ReadDesire name the backend writes the per-node-pool NodePool mirror under. Consumers look this up via a ReadDesireLister.GetForNodePool call.

The value is the lowercased form of coreapi.MaestroBundleInternalNameReadonlyHypershiftNodePool — the same derivation the writer (create_nodepool_scoped_read_desires_controller.go) uses for its desired ReadDesire name.

Functions

func DeleteAllChildDesires

func DeleteAllChildDesires(
	ctx context.Context,
	kubeApplierClient kubeappliercosmosstorage.KubeApplierDBClient,
	parent DesireParent,
	subscriptionID, resourceGroupName, hcpClusterName string,
) ([]string, error)

DeleteAllChildDesires tears down every ApplyDesire and ReadDesire under parent. Each ApplyDesire is flipped to Type=Delete so the kube-applier removes the applied object from the management cluster and, once the delete reports success, the desire document is removed; ReadDesires are deleted directly.

It returns a slice of human-readable reasons describing what teardown is still waiting for — one entry per desire that has not finished deleting yet. An empty slice means teardown is complete.

func EnsureApplyDesire

EnsureApplyDesire creates desire, or replaces the stored one when its spec or tags have drifted. It consults the ApplyDesire lister first — keyed by the desire's own resource ID — so an already-correct desire is never rewritten, and logs whenever it writes. The caller constructs the full desire in its own package (each controller builds the ApplyDesire it wants), so this function stays a pure, scope-agnostic create-or-update. It is shared by the desires-creator, revocation-desires, and backup-schedule controllers.

func EnsureApplyDesireRemoved

func EnsureApplyDesireRemoved(
	ctx context.Context,
	desireName string,
	applyCRUD cosmosstorageutils.ResourceCRUD[kubeapplierapi.ApplyDesire, *kubeapplierapi.ApplyDesire],
) (bool, error)

EnsureApplyDesireRemoved tears down a single ApplyDesire by converting it to a Type=Delete desire (so the kube-applier deletes spec.targetItem from the management cluster) and, once that delete reports success, removing the desire document. It returns true once the ApplyDesire is gone — either purged after a successful delete or already absent.

func EnsureReadDesire

EnsureReadDesire creates desire, or replaces the stored one when its spec or tags have drifted. Like EnsureApplyDesire it consults the lister (keyed by the desire's resource ID) and leaves construction to the caller, which builds the ReadDesire in its own package. It is shared by the desires-creator, revocation-desires, backup-schedule, and read-desire creator controllers.

func GetCachedCSRForSystemAdminCredentialRequest

func GetCachedCSRForSystemAdminCredentialRequest(
	ctx context.Context,
	readDesireLister dblisters.ReadDesireLister,
	subscriptionName, resourceGroupName, clusterName, credName string,
) (*certificatesv1.CertificateSigningRequest, error)

GetCachedCSRForSystemAdminCredentialRequest reads the CSR mirror from the per-credential ReadDesire. The ReadDesire's Status.KubeContent.Raw carries the observed CertificateSigningRequest JSON; we decode it directly and return the typed object.

Returns (nil, nil) when:

  • the ReadDesire has not been created yet (NotFound),
  • the ReadDesire exists but the kube-applier has not yet observed the target (Status.KubeContent is nil or empty).

Returns a non-nil error only for hard failures: a non-NotFound lister error, or unmarshal failure.

func GetCachedCertificateRevocationRequestForSystemAdminCredentialRevocation

func GetCachedCertificateRevocationRequestForSystemAdminCredentialRevocation(
	ctx context.Context,
	readDesireLister dblisters.ReadDesireLister,
	subscriptionName, resourceGroupName, clusterName, revocationName string,
) (*certificatesv1alpha1.CertificateRevocationRequest, error)

GetCachedCertificateRevocationRequestForSystemAdminCredentialRevocation reads the CRR mirror from the revocation-scoped ReadDesire. The ReadDesire's Status.KubeContent.Raw carries the observed CertificateRevocationRequest JSON; we decode it directly and return the typed object.

Returns (nil, nil) when:

  • the ReadDesire has not been created yet (NotFound),
  • the ReadDesire exists but the kube-applier has not yet observed the target (Status.KubeContent is nil or empty).

Returns a non-nil error only for hard failures: a non-NotFound lister error, or unmarshal failure.

func GetCachedControlPlaneClusterAutoscalerForCluster

func GetCachedControlPlaneClusterAutoscalerForCluster(
	ctx context.Context,
	readDesireLister kubeapplierlisters.ReadDesireLister,
	subscriptionName, resourceGroupName, clusterName string,
) (*v1beta1.ControlPlaneComponent, error)

GetCachedControlPlaneClusterAutoscalerForCluster reads the cluster-autoscaler ControlPlaneComponent mirror from the per-cluster ReadDesire.

func GetCachedHostedClusterForCluster

func GetCachedHostedClusterForCluster(
	ctx context.Context,
	readDesireLister kubeapplierlisters.ReadDesireLister,
	subscriptionName, resourceGroupName, clusterName string,
) (*v1beta1.HostedCluster, error)

GetCachedHostedClusterForCluster reads the HostedCluster mirror from the per-cluster ReadDesire. The ReadDesire's Status.KubeContent.Raw carries the observed HostedCluster JSON; we decode it directly and return the typed object.

Returns (nil, nil) when:

  • the ReadDesire has not been created yet (NotFound),
  • the ReadDesire exists but the kube-applier has not yet observed the target (Status.KubeContent is nil or empty).

Returns a non-nil error only for hard failures: a non-NotFound lister error, or unmarshal failure.

func GetCachedHostedClusterUUIDForCluster

func GetCachedHostedClusterUUIDForCluster(
	ctx context.Context,
	readDesireLister kubeapplierlisters.ReadDesireLister,
	subscriptionName, resourceGroupName, clusterName string,
) (uuid.UUID, bool, error)

GetCachedHostedClusterUUIDForCluster resolves the cluster UUID parsed from the cached HostedCluster's Spec.ClusterID for the given cluster.

Returns (uuid, true, nil) on success.

Returns (uuid.Nil, false, nil) for transient situations the caller should treat as a silent skip: the ReadDesire has not been observed yet, the kubeContent does not yet hold the HostedCluster, or the HostedCluster's Spec.ClusterID is empty. The reason is logged via the context logger so callers don't need to.

Returns a non-nil error only for hard failures: a non-NotFound lister error, malformed kubecontent, or an unparseable UUID.

func GetCachedNodePoolForNodePool

func GetCachedNodePoolForNodePool(
	ctx context.Context,
	readDesireLister kubeapplierlisters.ReadDesireLister,
	subscriptionName, resourceGroupName, clusterName, nodePoolName string,
) (*v1beta1.NodePool, error)

GetCachedNodePoolForNodePool reads the Hypershift NodePool mirror from the per-node-pool ReadDesire. The ReadDesire's Status.KubeContent.Raw carries the observed NodePool JSON; we decode it directly and return the typed object.

Returns (nil, nil) when:

  • the ReadDesire has not been created yet (NotFound),
  • the ReadDesire exists but the kube-applier has not yet observed the target (Status.KubeContent is nil or empty).

Returns a non-nil error only for hard failures: a non-NotFound lister error, or unmarshal failure.

func GetCachedServingCASecretForCluster

func GetCachedServingCASecretForCluster(
	ctx context.Context,
	readDesireLister kubeapplierlisters.ReadDesireLister,
	subscriptionName, resourceGroupName, clusterName string,
) (*corev1.Secret, error)

GetCachedServingCASecretForCluster reads the serving CA Secret mirror from the per-cluster ReadDesire.

Returns (nil, nil) when:

  • the ReadDesire has not been created yet (NotFound),
  • the ReadDesire exists but the kube-applier has not yet observed the target (Status.KubeContent is nil or empty).

func ReadDesireNameForSystemAdminCredentialRequestCSR

func ReadDesireNameForSystemAdminCredentialRequestCSR() string

ReadDesireNameForSystemAdminCredentialRequestCSR returns the ReadDesire name for the per-credential CSR mirror.

func ReadDesireNameForSystemAdminCredentialRequestRevocation

func ReadDesireNameForSystemAdminCredentialRequestRevocation() string

ReadDesireNameForSystemAdminCredentialRequestRevocation returns the ReadDesire name for the per-revocation CRR mirror.

func ReadDesireNameForSystemAdminCredentialRequestServingCA

func ReadDesireNameForSystemAdminCredentialRequestServingCA() string

ReadDesireNameForSystemAdminCredentialRequestServingCA returns the ReadDesire name for the per-cluster serving CA mirror.

Types

type DesireParent

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

DesireParent identifies the resource a *Desire is nested under. It is built via one of the scope constructors below, each of which captures how to derive the parent resource's ARM resource ID from the enclosing cluster's coordinates. Resource-ID, CRUD, and lister-key construction are then derived generically from that parent resource ID (via the kube-applier DesireScope abstraction), so the ensure*/delete helpers stay scope-agnostic and any new parent level (node pool today, management-cluster-scoped in the future) is a one-line constructor rather than a new case in a fan of switch statements.

The zero value (DesireParent{}) has no scope: every accessor on it returns an error rather than silently guessing a scope, because a desire with no declared parent is a programming error, not a cluster-scoped desire.

func ClusterDesireParent

func ClusterDesireParent() DesireParent

ClusterDesireParent returns a DesireParent that nests desires directly under the cluster.

func CredentialRequestDesireParent

func CredentialRequestDesireParent(credentialRequestName string) DesireParent

CredentialRequestDesireParent returns a DesireParent that nests desires under the named SystemAdminCredentialRequest.

func NodePoolDesireParent

func NodePoolDesireParent(nodePoolName string) DesireParent

NodePoolDesireParent returns a DesireParent that nests desires under the named node pool.

func RevocationDesireParent

func RevocationDesireParent(revocationName string) DesireParent

RevocationDesireParent returns a DesireParent that nests desires under the named SystemAdminCredentialRevocation.

Jump to

Keyboard shortcuts

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