utils

package
v0.0.0-...-5a6eb71 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 37 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 GetCSVDeployment

func GetCSVDeployment(ctx context.Context, client runtimeclient.Client) (*appsv1.Deployment, 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 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 MoveFileIfExists

func MoveFileIfExists(source, dest string) 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 RenderTemplateFile

func RenderTemplateFile(templateData string, params any, dest string, perm os.FileMode) error

RenderTemplateFile render template file

func ReplaceImageRegistry

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

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 TypeMetaForObject

func TypeMetaForObject(scheme *runtime.Scheme, o runtime.Object) (*metav1.TypeMeta, error)

TypeMetaForObject returns the given object's TypeMeta or an error otherwise.

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
}

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