util

package
v0.1.73 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: Apache-2.0 Imports: 25 Imported by: 5

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."

	// 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 */

	// Encryption
	EncryptionKeyIDDescription     = "" /* 130-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."

	// VM configuration
	InstanceTypeDescription = "Azure VM size for NodePool instances (e.g. Standard_D4s_v4, 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 */
)
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"
)

Variables

This section is empty.

Functions

func ConfigMapResource added in v0.1.55

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

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 GetClient

func GetClient() (crclient.Client, error)

GetClient creates a controller-runtime client for Kubernetes

func GetConfig

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

GetConfig creates a REST config from current context

func GetImpersonatedClient added in v0.1.9

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

GetImpersonatedClient creates a controller-runtime client for Kubernetes

func GetSecret

func GetSecret(name string, namespace string) (*corev1.Secret, error)

func GetSecretWithClient

func GetSecretWithClient(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 CredentialsSecretData added in v0.1.32

type CredentialsSecretData struct {
	AWSAccessKeyID     string
	AWSSecretAccessKey string
	AWSSessionToken    string

	BaseDomain string
}

func ExtractOptionsFromSecret

func ExtractOptionsFromSecret(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

Jump to

Keyboard shortcuts

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