gcputil

package
v0.1.88 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const LBResourceLabelsAnnotation = "cloud.google.com/load-balancer-resource-labels"

LBResourceLabelsAnnotation is the Service annotation read by the GCP cloud-controller-manager (openshift/cloud-provider-gcp) to apply labels to the GCP forwarding rules created for that Service. Format: comma-separated "key=value" pairs, e.g. "goog-partner-solution=foo,env=prod".

View Source
const ManagedLBResourceLabelsAnnotation = "hypershift.openshift.io/managed-gcp-lb-resource-label-keys"

ManagedLBResourceLabelsAnnotation records the resource-label keys in LBResourceLabelsAnnotation that HyperShift manages. When an HCP label overlaps an existing Service-owned key, HyperShift takes ownership of that key and its HCP value takes precedence. Removing that HCP label later removes the key; the previous Service value is not restored.

View Source
const MaxResourceLabels = 64

MaxResourceLabels is the maximum number of labels GCP permits on a resource.

Variables

This section is empty.

Functions

func BuildWorkloadIdentityCredentials

func BuildWorkloadIdentityCredentials(wif hyperv1.GCPWorkloadIdentityConfig, serviceAccountEmail string) (string, error)

BuildWorkloadIdentityCredentials creates the credential configuration JSON for Google Cloud SDK to use Workload Identity Federation with a specific service account email.

func HypershiftLocalZoneName added in v0.1.88

func HypershiftLocalZoneName(clusterName string) (string, error)

HypershiftLocalZoneName returns the GCP Cloud DNS managed-zone NAME of the per-cluster hypershift.local private zone for the given cluster name.

func LBResourceLabelsAnnotationValue added in v0.1.87

func LBResourceLabelsAnnotationValue(labels map[string]string) string

LBResourceLabelsAnnotationValue serializes a GCP resource-label map into the comma-separated "key=value" string expected by LBResourceLabelsAnnotation. Returns an empty string when labels is nil or empty.

func ManagedResourceLabelKeys added in v0.1.87

func ManagedResourceLabelKeys(annotations map[string]string, annotation string) map[string]struct{}

ManagedResourceLabelKeys returns the resource-label keys previously managed by HyperShift, stored as a comma-separated object annotation.

func MergeResourceLabels added in v0.1.87

func MergeResourceLabels(existing, desired map[string]string, previouslyManagedLabelKeys map[string]struct{}) (map[string]string, error)

MergeResourceLabels preserves labels that are not managed by HyperShift, removes withdrawn managed labels, and applies the desired labels. GCP permits at most 64 labels per resource.

func ParseLBResourceLabelsAnnotation added in v0.1.87

func ParseLBResourceLabelsAnnotation(annotations map[string]string) (map[string]string, bool, error)

ParseLBResourceLabelsAnnotation parses the native GCP Service annotation. The format and validation intentionally match cloud-provider-gcp's accepted key=value[,key=value] representation.

func PrivateIngressZoneName added in v0.1.88

func PrivateIngressZoneName(baseDomain string) (string, error)

PrivateIngressZoneName returns the GCP Cloud DNS managed-zone NAME of the private ingress zone for the given base domain. See PublicIngressZoneName for input requirements.

func PublicIngressZoneName added in v0.1.88

func PublicIngressZoneName(baseDomain string) (string, error)

PublicIngressZoneName returns the GCP Cloud DNS managed-zone NAME of the public ingress zone for the given base domain. The input MUST be the raw HostedControlPlane base domain (hcp.Spec.DNS.BaseDomain), not a prefixed value, so that it matches the name the GCP Private Service Connect controller uses when it creates the zone.

func ReconcileLBResourceLabelAnnotations added in v0.1.87

func ReconcileLBResourceLabelAnnotations(annotations map[string]string, desired map[string]string) (map[string]string, bool, error)

ReconcileLBResourceLabelAnnotations merges HCP labels into a Service's GCP load-balancer resource-label annotation. Labels not previously managed by HyperShift are preserved. It returns the desired annotations and whether they differ from annotations.

func ResourceLabels added in v0.1.87

func ResourceLabels(hcp *hyperv1.HostedControlPlane) map[string]string

ResourceLabels converts the HCP GCP resource-label list to the map format expected by GCP API calls. Returns nil when no labels are configured.

func ResourceLabelsToMap added in v0.1.87

func ResourceLabelsToMap(resourceLabels []hyperv1.GCPResourceLabel) map[string]string

ResourceLabelsToMap converts GCP resource labels to the map format expected by GCP APIs. Labels without a value are represented by an empty string. Returns nil when no labels are configured.

func UpdateManagedResourceLabelKeys added in v0.1.87

func UpdateManagedResourceLabelKeys(ctx context.Context, c client.Client, obj client.Object, annotation string, desiredLabels map[string]string) error

UpdateManagedResourceLabelKeys records the sorted desired resource-label keys in an object's annotation. It patches the object only when the annotation changes.

func ValidateZoneName added in v0.1.88

func ValidateZoneName(name string) error

ValidateZoneName validates that a name meets GCP Cloud DNS managed zone naming constraints.

Types

type CredentialSource

type CredentialSource struct {
	File   string                 `json:"file"`
	Format CredentialSourceFormat `json:"format"`
}

CredentialSource represents the credential source configuration for GCP external account credentials.

type CredentialSourceFormat

type CredentialSourceFormat struct {
	Type string `json:"type"`
}

CredentialSourceFormat represents the format of the credential source.

type ExternalAccountCredential

type ExternalAccountCredential struct {
	Type                           string           `json:"type"`
	Audience                       string           `json:"audience"`
	SubjectTokenType               string           `json:"subject_token_type"`
	TokenURL                       string           `json:"token_url"`
	ServiceAccountImpersonationURL string           `json:"service_account_impersonation_url"`
	CredentialSource               CredentialSource `json:"credential_source"`
}

ExternalAccountCredential represents the complete GCP external account credential configuration for Workload Identity Federation. This follows the Google Cloud credential configuration format.

Jump to

Keyboard shortcuts

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