utils

package
v0.0.0-...-4c5e57f Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToListIfNotExists

func AppendToListIfNotExists(list []string, value string) []string

func BackupKubeadminPasswordHash

func BackupKubeadminPasswordHash(ctx context.Context, client runtimeclient.Client, cryptoDir string) (bool, error)

func BackupKubeconfigCrypto

func BackupKubeconfigCrypto(ctx context.Context, client runtimeclient.Client, cryptoDir string) error

func ConvertToRawExtension

func ConvertToRawExtension(config any) (runtime.RawExtension, error)

func CopyFileIfExists

func CopyFileIfExists(source, dest string) error

func CopyToTempFile

func CopyToTempFile(sourceFileName, directory, pattern string) (string, error)

CopyToTempFile copies a file to a temporary file. WARNING: This function only preserves POSIX permissions to the new file If you want to use it, take that into account and extend it if needed to also preserve other things like owner, extended attributes, selinux contexts or whatever might be needed

func CreateDynamicClient

func CreateDynamicClient(kubeconfig string, isTestEnvAllowed bool, log logr.Logger) (dynamic.Interface, error)

func CreateKubeClient

func CreateKubeClient(scheme *runtime.Scheme, kubeconfig string) (runtimeclient.Client, error)

func ExtractRegistryFromImage

func ExtractRegistryFromImage(image string) string

func GetAdditionalTrustBundleFromConfigmap

func GetAdditionalTrustBundleFromConfigmap(ctx context.Context, client client.Client, configmapName string) (string, error)

func GetCSVDeployment

func GetCSVDeployment(ctx context.Context, client runtimeclient.Client) (*appsv1.Deployment, error)

func GetClusterAdditionalTrustBundleState

func GetClusterAdditionalTrustBundleState(ctx context.Context, client client.Client) (bool, string, error)

func GetClusterBaseDomain

func GetClusterBaseDomain(ctx context.Context, client runtimeclient.Client) (string, error)

func GetClusterName

func GetClusterName(ctx context.Context, client runtimeclient.Client) (string, error)

func GetConfigMapData

func GetConfigMapData(ctx context.Context, name, namespace, key string, client runtimeclient.Client) (string, error)

func GetMirrorRegistrySourceRegistries

func GetMirrorRegistrySourceRegistries(ctx context.Context, client runtimeclient.Client) ([]string, error)

func GetReleaseRegistry

func GetReleaseRegistry(ctx context.Context, client runtimeclient.Client) (string, error)

func GetSNOMasterNode

func GetSNOMasterNode(ctx context.Context, client runtimeclient.Client) (*corev1.Node, error)

func GetSecretData

func GetSecretData(ctx context.Context, name, namespace, key string, client runtimeclient.Client) (string, error)

func HandleFilesWithCallback

func HandleFilesWithCallback(folder string, action func(string) error) error

func HasFIPS

func HasFIPS(ctx context.Context, client runtimeclient.Client) (bool, error)

func HasProxy

func HasProxy(ctx context.Context, client runtimeclient.Client) (bool, error)

func InitIBU

func InitIBU(ctx context.Context, c client.Client, log *logr.Logger) error

func IsIpv6

func IsIpv6(provideIp string) bool

func LoadGroupedManifestsFromPath

func LoadGroupedManifestsFromPath(basePath string, log *logr.Logger) ([][]*unstructured.Unstructured, error)

func LoadKubeadminPasswordHash

func LoadKubeadminPasswordHash(cryptoDir string) (string, error)

func MarshalToFile

func MarshalToFile(data any, filePath string) error

MarshalToFile marshals anything and writes it to the given file path. file only readable by root

func MarshalToYamlFile

func MarshalToYamlFile(data any, filePath string) error

MarshalToYamlFile marshals any object to YAML and writes it to the given file path file only readable by root

func ReadIBIConfigFile

func ReadIBIConfigFile(configFile string) (*ibiconfig.IBIPrepareConfig, error)

func ReadImageFromStaticPodDefinition

func ReadImageFromStaticPodDefinition(podFile, containerName string) (string, error)

func ReadSeedReconfigurationFromFile

func ReadSeedReconfigurationFromFile(path string) (*seedreconfig.SeedReconfiguration, error)

func ReadYamlOrJSONFile

func ReadYamlOrJSONFile(fp string, into any) error

func RemoveListOfFolders

func RemoveListOfFolders(log *logrus.Logger, folders []string) error

func RenderTemplate

func RenderTemplate(templateData string, params any) ([]byte, error)

RenderTemplate render template

func ReplaceImageRegistry

func ReplaceImageRegistry(image, targetRegistry, sourceRegistry string) (string, error)

func RetryMiddleware

func RetryMiddleware(logger logr.Logger) func(rt http.RoundTripper) http.RoundTripper

RetryMiddleware pass this into your client config (with .Wrap()) to make it retriable

func RunOnce

func RunOnce(name, directory string, log *logrus.Logger, f any, args ...any) error

func SeedReconfigurationKubeconfigRetentionFromCluster

func SeedReconfigurationKubeconfigRetentionFromCluster(ctx context.Context, client runtimeclient.Client) (*seedreconfig.KubeConfigCryptoRetention, error)

func SeedReconfigurationKubeconfigRetentionToCryptoDir

func SeedReconfigurationKubeconfigRetentionToCryptoDir(cryptoDir string, kubeconfigCryptoRetention *seedreconfig.KubeConfigCryptoRetention) error

func ShouldOverrideSeedRegistry

func ShouldOverrideSeedRegistry(ctx context.Context, client runtimeclient.Client, mirrorRegistryConfigured bool, releaseRegistry string) (bool, error)

func UpdatePullSecretFromDockerConfig

func UpdatePullSecretFromDockerConfig(ctx context.Context, c client.Client, dockerConfigJSON []byte) (*corev1.Secret, error)

Types

type ClusterInfo

type ClusterInfo struct {
	OCPVersion               string
	BaseDomain               string
	ClusterName              string
	ClusterID                string
	NodeIP                   string
	ReleaseRegistry          string
	Hostname                 string
	MirrorRegistryConfigured bool
	ClusterNetworks          []string
	ServiceNetworks          []string
	MachineNetwork           string
}

func GetClusterInfo

func GetClusterInfo(ctx context.Context, client runtimeclient.Client) (*ClusterInfo, error)

Jump to

Keyboard shortcuts

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