util

package
v0.1.64 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 25 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 (
	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 ClearFakeClientObjects added in v0.1.64

func ClearFakeClientObjects()

ClearFakeClientObjects clears the test fake client objects

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 SetFakeClientObjects added in v0.1.64

func SetFakeClientObjects(objects ...crclient.Object)

SetFakeClientObjects sets the objects to be included in fake clients for testing

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