util

package
v0.1.89 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 27 Imported by: 2 modules, 5 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 (
	// Credentials
	AzureCredsDescription = "" /* 214-byte string literal not displayed */

	// ARO HCP (managed Azure) identity flags
	KMSCredentialsSecretNameDescription    = "" /* 130-byte string literal not displayed */
	ManagedIdentitiesFileDescription       = "Path to a file containing the managed identities configuration in JSON format."
	DataPlaneIdentitiesFileDescription     = "Path to a file containing the client IDs of the managed identities for the data plane configured in JSON format."
	AssignCustomHCPRolesDescription        = "Assign custom roles to HCP identities."
	AssignServicePrincipalRolesDescription = "Assign required Azure RBAC roles to identities (managed identities for ARO HCP, workload identities for self-managed)."

	// Location and availability
	LocationDescription          = "Azure region where the cluster and its resources will be created (e.g. eastus, westus2, northeurope)."
	AvailabilityZonesDescription = "" /* 150-byte string literal not displayed */
	AvailabilityZoneDescription  = "Availability zone for the NodePool (e.g. 1, 2, or 3). Omit if the region does not support availability zones."

	// Resource group
	ResourceGroupNameDescription = "" /* 146-byte string literal not displayed */
	ResourceGroupTagsDescription = "Additional tags to apply to the resource group (e.g. 'environment=prod,team=platform')."
	DNSZoneRGNameDescription     = "Name of the resource group containing your Azure DNS zone. Required for the ingress controller to create DNS records."

	// Networking
	VnetIDDescription                 = "" /* 199-byte string literal not displayed */
	SubnetIDDescription               = "" /* 127-byte string literal not displayed */
	NetworkSecurityGroupIDDescription = "Full resource ID of an existing Network Security Group for the default NodePool. If omitted, a new NSG will be created."
	IPForwardingDescription           = "" /* 328-byte string literal not displayed */

	// Identity
	WorkloadIdentitiesFileDescription = "" /* 192-byte string literal not displayed */
	OIDCIssuerURLDescription          = "" /* 145-byte string literal not displayed */
	SATokenIssuerKeyPathDescription   = "" /* 127-byte string literal not displayed */
	AutoAssignRolesDescription        = "" /* 179-byte string literal not displayed */

	// Private connectivity / endpoint access
	EndpointAccessDescription                                      = "Endpoint access type: Public, PublicAndPrivate, or Private."
	EndpointAccessPrivateNATSubnetIDDescription                    = "" /* 146-byte string literal not displayed */
	EndpointAccessPrivateAdditionalAllowedSubscriptionsDescription = "" /* 143-byte string literal not displayed */

	// Encryption
	EnableKMSDescription           = "" /* 137-byte string literal not displayed */
	EncryptionKeyIDDescription     = "" /* 205-byte string literal not displayed */
	EncryptionAtHostDescription    = "Enable host-based encryption for VM disks and temp disks. Valid values: Enabled, Disabled."
	DiskEncryptionSetIDDescription = "Full resource ID of an Azure Disk Encryption Set used to encrypt NodePool OS disks with customer-managed keys."

	// AutoNode / Karpenter
	AutoNodeDescription          = "If true, this flag indicates the Hosted Cluster will support the AutoNode feature."
	EnableKarpenterDescription   = "Create a Karpenter workload identity for AutoNode. Use this when the cluster will be created with --auto-node."
	KarpenterClientIDDescription = "" /* 187-byte string literal not displayed */

	// VM configuration
	InstanceTypeDescription = "Azure VM size for NodePool instances (e.g. Standard_D4s_v5, Standard_D8s_v5)."
	RootDiskSizeDescription = "Size of the OS disk in GB for each NodePool VM. Minimum: 16 GB."

	// Disk configuration
	DiskStorageAccountTypeDescription = "Azure storage type for NodePool OS disks. Valid values: Premium_LRS, StandardSSD_LRS, Standard_LRS."
	EnableEphemeralOSDiskDescription  = "Use ephemeral OS disks for faster VM provisioning and lower latency. Note: Data is lost when VMs are deallocated."

	// Image configuration
	ImageGenerationDescription      = "Hyper-V generation for VM images. Valid values: Gen1, Gen2. Gen2 is recommended for most modern workloads."
	MarketplacePublisherDescription = "Publisher name for Azure Marketplace image (e.g. redhat). Only needed if overriding the default RHCOS image."
	MarketplaceOfferDescription     = "Offer name for Azure Marketplace image (e.g. rhcos). Only needed if overriding the default RHCOS image."
	MarketplaceSKUDescription       = "SKU for Azure Marketplace image (e.g. rhcos-414). Only needed if overriding the default RHCOS image."
	MarketplaceVersionDescription   = "" /* 127-byte string literal not displayed */

	// Diagnostics
	DiagnosticsStorageAccountTypeDescription = "" /* 153-byte string literal not displayed */
	DiagnosticsStorageAccountURIDescription  = "URI of your storage account for boot diagnostics logs. Required when using UserManaged diagnostics type."

	// Destroy options
	PreserveResourceGroupDescription = "Keep the resource group after cluster deletion. Only cluster-specific resources within the group will be removed."

	// Destroy-specific location and resource group descriptions
	LocationDestroyDescription          = "" /* 138-byte string literal not displayed */
	AzureCredsDestroyDescription        = "Path to an Azure credentials file (JSON format) used to authenticate and delete Azure resources."
	ResourceGroupNameDestroyDescription = "" /* 180-byte string literal not displayed */
	DNSZoneRGNameDestroyDescription     = "" /* 146-byte string literal not displayed */

	// Infrastructure command specific flags
	AssignIdentityRolesDescription          = "" /* 136-byte string literal not displayed */
	DisableClusterCapabilitiesDescription   = "" /* 156-byte string literal not displayed */
	InfraIDDescription                      = "Unique identifier used to name and tag Azure resources. This ID will be incorporated into resource names and Azure tags."
	BaseDomainInfraDescription              = "Base DNS domain for the cluster (e.g. example.com). A public DNS zone for this domain must exist in your Azure subscription."
	InfraOutputFileDescription              = "" /* 147-byte string literal not displayed */
	WorkloadIdentitiesOutputFileDescription = "" /* 160-byte string literal not displayed */

	// Common flags
	NameDescription  = "A name for the HostedCluster. This name is used to identify resources and must be unique within the namespace."
	CloudDescription = "" /* 131-byte string literal not displayed */
)
View Source
const (
	AutoInfraLabelName = "hypershift.openshift.io/auto-created-for-infra"
	// DeleteWithClusterLabelName marks CLI created secrets, to be safely removed on hosted cluster deletion
	DeleteWithClusterLabelName = "hypershift.openshift.io/safe-to-delete-with-cluster"

	KubeconfigFlagHelp = "" /* 180-byte string literal not displayed */
)
View Source
const (
	DefaultGCPMachineTypeAMD64 = "n2-standard-4"
	DefaultGCPMachineTypeARM64 = "t2a-standard-4"

	GCPMachineTypeHelp = "GCP machine type for node instances (default: " +
		DefaultGCPMachineTypeAMD64 + " for AMD64, " +
		DefaultGCPMachineTypeARM64 + " for ARM64)"
)

Variables

This section is empty.

Functions

func BuildGCPNodePoolPlatform added in v0.1.85

func BuildGCPNodePoolPlatform(opts GCPNodePoolPlatformOptions) *hyperv1.GCPNodePoolPlatform

BuildGCPNodePoolPlatform constructs basic GCPNodePoolPlatform with shared fields. Handles machine type defaulting based on architecture. Advanced fields (BootDisk, ServiceAccount, etc.) should be set separately.

func ConfigMapResource added in v0.1.55

func ConfigMapResource(namespace, name string) *corev1.ConfigMap

func DefaultGCPMachineType added in v0.1.85

func DefaultGCPMachineType(arch string) string

DefaultGCPMachineType returns the default machine type for arch, or an empty string if the architecture is unsupported.

func FlagErr added in v0.1.52

func FlagErr(flagName, format string, a ...any) error

func GenerateRoleAssignmentName added in v0.1.58

func GenerateRoleAssignmentName(infraID, component, scope string) string

GenerateRoleAssignmentName generates a unique GUID based on the cluster infra ID, component, and scope; this allows us to create the same GUID that we can then later regenerate to delete the role assignment.

func GenerateSSHKeys added in v0.1.55

func GenerateSSHKeys() ([]byte, []byte, error)

func GetClientWithKubeconfig added in v0.1.78

func GetClientWithKubeconfig(kubeconfigPath string) (crclient.Client, error)

GetClientWithKubeconfig creates a controller-runtime client for Kubernetes using the specified kubeconfig path, or the default resolution when empty.

func GetConfig

func GetConfig() (*rest.Config, error)

GetConfig creates a REST config from current context

func GetConfigWithKubeconfig added in v0.1.78

func GetConfigWithKubeconfig(kubeconfigPath string) (*rest.Config, error)

GetConfigWithKubeconfig creates a REST config from the specified kubeconfig file path. If kubeconfigPath is empty, it falls back to the default kubeconfig resolution.

func GetImpersonatedClient added in v0.1.9

func GetImpersonatedClient(kubeconfigPath, userName string) (crclient.Client, error)

GetImpersonatedClient creates a controller-runtime client for Kubernetes

func GetKubernetesClientSetWithKubeconfig added in v0.1.87

func GetKubernetesClientSetWithKubeconfig(kubeconfigPath string) (kubernetes.Interface, error)

GetKubernetesClientSetWithKubeconfig creates a typed Kubernetes clientset using the specified kubeconfig file path.

func GetSecretWithClient

func GetSecretWithClient(ctx context.Context, client client.Client, name string, namespace string) (*corev1.Secret, error)

func Map added in v0.1.52

func Map(flagName, paramsStr string, obj interface{}) error

Map assigns the parameter value into the right struct field, which is represented by obj. For example, if we use Map("param1", "value1", &myFlag) with MyFlag struct above, Param1 field would be assigned with "value1".

func ParseAWSTags

func ParseAWSTags(tags []string) (map[string]string, error)

ParseAWSTags does exactly that

func SecretResource added in v0.1.55

func SecretResource(namespace, name string) *corev1.Secret

func SetupAzureCredentials added in v0.1.18

func SetupAzureCredentials(l logr.Logger, credentials *AzureCreds, credentialsFile string) (string, *azidentity.DefaultAzureCredential, error)

SetupAzureCredentials creates the Azure credentials needed to create Azure resources from credentials passed in from the user or from a credentials file

func Supported added in v0.1.52

func Supported(obj interface{}) string

Supported returns the list of supported flags for a parameter struct. This is mainly used to show the user the list of supported parameters

func ValidateMarketplaceFlags added in v0.1.43

func ValidateMarketplaceFlags(marketplaceFlags map[string]*string) error

ValidateMarketplaceFlags validates if any marketplace flag was used, all were set to a non-empty value

func ValidateRequiredOption added in v0.1.32

func ValidateRequiredOption(flag string, value string) error

ValidateRequiredOption returns a cobra style error message when the flag value is empty

Types

type AzureCreds added in v0.1.18

type AzureCreds struct {
	SubscriptionID string `json:"subscriptionId,omitempty"`
	ClientID       string `json:"clientId,omitempty"`
	ClientSecret   string `json:"clientSecret,omitempty"`
	TenantID       string `json:"tenantId,omitempty"`
}

AzureCreds is the file format we expect for credentials. It is copied from the installer to allow using the same credentials file for both: https://github.com/openshift/installer/blob/8fca1ade5b096d9b2cd312c4599881d099439288/pkg/asset/installconfig/azure/session.go#L36

func ReadCredentials added in v0.1.18

func ReadCredentials(path string) (*AzureCreds, error)

ReadCredentials reads a file with azure credentials and returns it as a struct

type ClientFactory added in v0.1.87

type ClientFactory func(kubeconfigPath string) (crclient.Client, error)

ClientFactory creates a controller-runtime client for the requested kubeconfig.

type ClientProvider added in v0.1.87

type ClientProvider struct {
	ControllerRuntimeClient ClientFactory
	KubernetesClientSet     KubeClientSetFactory
	Config                  ConfigFactory
	ImpersonatedClient      ImpersonatedClientFactory
}

ClientProvider groups the management-cluster dependencies used by CLI commands. Tests can replace individual factories with fake clients without changing the command implementation.

func DefaultClientProvider added in v0.1.87

func DefaultClientProvider() *ClientProvider

DefaultClientProvider returns the production client factories used by the CLI.

func ResolveClientProvider added in v0.1.87

func ResolveClientProvider(clientProviders ...*ClientProvider) *ClientProvider

ResolveClientProvider returns the supplied provider or the production provider when no dependency was injected.

func (*ClientProvider) ConfigFor added in v0.1.87

func (p *ClientProvider) ConfigFor(kubeconfigPath string) (*rest.Config, error)

ConfigFor returns a REST config from the provider and rejects missing or nil dependencies.

func (*ClientProvider) ControllerRuntimeClientFor added in v0.1.87

func (p *ClientProvider) ControllerRuntimeClientFor(kubeconfigPath string) (crclient.Client, error)

ControllerRuntimeClientFor returns a controller-runtime client from the provider and rejects missing or nil dependencies.

func (*ClientProvider) ImpersonatedClientFor added in v0.1.87

func (p *ClientProvider) ImpersonatedClientFor(kubeconfigPath, userName string) (crclient.Client, error)

ImpersonatedClientFor returns an impersonated client from the provider and rejects missing or nil dependencies.

func (*ClientProvider) KubernetesClientSetFor added in v0.1.87

func (p *ClientProvider) KubernetesClientSetFor(kubeconfigPath string) (kubernetes.Interface, error)

KubernetesClientSetFor returns a typed Kubernetes clientset from the provider and rejects missing or nil dependencies.

type ConfigFactory added in v0.1.87

type ConfigFactory func(kubeconfigPath string) (*rest.Config, error)

ConfigFactory creates a REST config for the requested kubeconfig.

type CredentialsSecretData added in v0.1.32

type CredentialsSecretData struct {
	AWSAccessKeyID     string
	AWSSecretAccessKey string
	AWSSessionToken    string

	BaseDomain string
}

func ExtractOptionsFromSecret

func ExtractOptionsFromSecret(ctx context.Context, client client.Client, name string, namespace string, baseDomain string) (*CredentialsSecretData, error)

ExtractOptionsFromSecret Returns baseDomain, awsAccessKeyID & awsSecretAccessKey If len(baseDomain) > 0 we override the value found in the secret

type GCPNodePoolPlatformOptions added in v0.1.85

type GCPNodePoolPlatformOptions struct {
	// Zone is the GCP zone for the NodePool
	Zone string

	// Subnet is the subnet name for node instances
	Subnet string

	// MachineType is the GCP machine type. If empty, defaults based on Arch.
	MachineType string

	// Arch is the architecture for machine type defaulting
	Arch string

	// Image is the boot image override (optional)
	Image string
}

GCPNodePoolPlatformOptions contains options for building basic GCP NodePool platform spec. Only includes fields shared between cluster and nodepool commands.

type ImpersonatedClientFactory added in v0.1.87

type ImpersonatedClientFactory func(kubeconfigPath, userName string) (crclient.Client, error)

ImpersonatedClientFactory creates a controller-runtime client for an impersonated user.

type KubeClientSetFactory added in v0.1.87

type KubeClientSetFactory func(kubeconfigPath string) (kubernetes.Interface, error)

KubeClientSetFactory creates a typed Kubernetes clientset for the requested kubeconfig.

Jump to

Keyboard shortcuts

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