utils

package
v0.0.0-...-603c858 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: AGPL-3.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCommitAndPushChanges

func AddCommitAndPushChanges(ctx context.Context, repo *git.Repository, workTree *git.Worktree, branch string, auth transport.AuthMethod, clusterName string, commitMessage string) plumbing.Hash

func CreateAndCheckoutToBranch

func CreateAndCheckoutToBranch(repo *git.Repository, branch string, workTree *git.Worktree)

func CreateIntermediateDirsForFile

func CreateIntermediateDirsForFile(ctx context.Context, filePath string)

Creates intermediate directories which don't exist for the given file path.

func CreateK3DCluster

func CreateK3DCluster(ctx context.Context, name string)

Creates a K3D cluster with the given name (only if it doesn't already exist).

func CreateKubernetesClient

func CreateKubernetesClient(ctx context.Context, kubeconfigPath string) client.Client

Uses the kubeconfig file present at the given path, to create and return a Kubernetes Go client.

func CreateNamespace

func CreateNamespace(ctx context.Context, namespaceName string, kubeClient client.Client)

Creates the given namespace (if it doesn't already exist).

func ExecuteCommand

func ExecuteCommand(command string) (string, error)

Executes the given command. Doesn't panic and returns error (if occurred).

func ExecuteCommandOrDie

func ExecuteCommandOrDie(command string) string

Executes the given command. Panics if the command execution fails.

func GenerateSealedSecret

func GenerateSealedSecret(ctx context.Context, secretFilePath string)

Takes the path to a Kubernetes Secret file. It replaces the contents of that file by generating the corresponding Sealed Secret.

func GetCapiClusterNamespace

func GetCapiClusterNamespace() string

Returns the namespace (capi-cluster / capi-cluster-<customer-id>) where the 'cloud-credentials' Kubernetes Secret will exist. This Kubernetes Secret will be used by Cluster API to communicate with the underlying cloud provider.

func GetClusterDir

func GetClusterDir() string

func GetClusterResource

func GetClusterResource(ctx context.Context, kubeClient client.Client, cluster *clusterAPIV1Beta1.Cluster) error

Queries the Cluster resource using the given kube-client.

func GetDefaultBranchName

func GetDefaultBranchName(ctx context.Context, repo *git.Repository) string

func GetDirPathForDownloadedStorageBucketContents

func GetDirPathForDownloadedStorageBucketContents(bucketName string) string

Returns the path to the local temp directory, where contents of the given blob storage bucket will be / is downloaded.

func GetEnv

func GetEnv(name string) string

Returns value of the given environment variable. Panics if the environment variable isn't found.

func GetGitAuthMethod

func GetGitAuthMethod(ctx context.Context) (authMethod transport.AuthMethod)

func GetParentDirPath

func GetParentDirPath(filePath string) string

Returns path to the parent dir of the given file.

func GitCloneRepo

func GitCloneRepo(ctx context.Context, url, dirPath string, authMethod transport.AuthMethod) *git.Repository

Clones the given git repository into the given directory (only if the repo doesn't already exist in there). If the repo already exists, then it just does git pull.

func HelmInstall

func HelmInstall(ctx context.Context, args *HelmInstallArgs)

Installs the given Helm chart (if not already deployed).

func InitTempDir

func InitTempDir()

Creates a temp dir inside /tmp, where KubeAid Bootstrap Script will clone repos. Then sets the value of constants.TempDir as the temp dir path. If the temp dir already exists, then that gets reused.

func InstallAndSetupArgoCD

func InstallAndSetupArgoCD(ctx context.Context, clusterDir string, kubeClient client.Client)

Installs ArgoCD Helm chart and creates the root ArgoCD App. Then creates and returns an ArgoCD Application client.

func InstallSealedSecrets

func InstallSealedSecrets(ctx context.Context)

Installs Sealed Secrets in the underlying Kubernetes cluster.

func SaveKubeconfig

func SaveKubeconfig(ctx context.Context, kubeClient client.Client)

Saves kubeconfig of the provisioned cluster locally.

func SyncArgoCDApp

func SyncArgoCDApp(ctx context.Context, name string, resources []*argoCDV1Aplha1.SyncOperationResource)

Syncs the ArgoCD App (if not synced already). If the resources array is empty, then the whole ArgoCD App is synced. Otherwise, only the specified resources.

func WaitForMainClusterToBeProvisioned

func WaitForMainClusterToBeProvisioned(ctx context.Context, kubeClient client.Client)

Waits for the main cluster to be provisioned.

func WaitForMainClusterToBeReady

func WaitForMainClusterToBeReady(ctx context.Context, kubeClient client.Client)

Waits for the main cluster to be ready to run our application workloads.

func WaitUntilPRMerged

func WaitUntilPRMerged(ctx context.Context, repo *git.Repository, defaultBranchName string, commitHash plumbing.Hash, auth transport.AuthMethod, branchToBeMerged string)

Types

type HelmInstallArgs

type HelmInstallArgs struct {
	RepoURL,
	RepoName,
	ChartName,
	Version,
	ReleaseName,
	Namespace string
	Values string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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