utils

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RandStrLength        = 10
	TimeoutCapp          = 60 * time.Second
	CappCreationInterval = 2 * time.Second
)
View Source
const (
	ServiceAccountNameFormat   = "system:serviceaccount:%s:%s"
	ServiceAccountName         = "test-user"
	ExcludedServiceAccountName = "excluded-sa"
)
View Source
const RbacObjectSuffix = "-logs-reader"

Variables

This section is empty.

Functions

func CreateCapp

func CreateCapp(k8sClient client.Client, capp *cappv1alpha1.Capp) *cappv1alpha1.Capp

CreateCapp creates a new Capp instance with a unique name and returns it.

func CreateConfigMap added in v0.2.0

func CreateConfigMap(k8sClient client.Client, configmap *corev1.ConfigMap) *corev1.ConfigMap

CreateConfigMap creates a corev1.configMap object with a random suffix in its name and returns it

func CreateExcludedServiceAccount added in v0.3.3

func CreateExcludedServiceAccount(k8sClient client.Client)

CreateExcludedServiceAccount configures a service account that should be excluded from the mutating webhook.

func CreateRole

func CreateRole(k8sClient client.Client, role *rbacv1.Role) *rbacv1.Role

CreateRole creates a rbac1.Role object and returns it.

func CreateRoleBinding

func CreateRoleBinding(k8sClient client.Client, roleBinding *rbacv1.RoleBinding) *rbacv1.RoleBinding

CreateRoleBinding creates a rbacv1.RoleBinding and returns it.

func CreateSecret

func CreateSecret(k8sClient client.Client, secret *corev1.Secret) *corev1.Secret

CreateSecret creates a corev1.secret object with a random suffix in its name and returns it.

func CreateServiceAccount added in v0.3.3

func CreateServiceAccount(k8sClient client.Client, serviceAccount *corev1.ServiceAccount) *corev1.ServiceAccount

CreateServiceAccount creates a corev1.ServiceAccount and returns it.

func CreateTestUser added in v0.2.0

func CreateTestUser(k8sClient client.Client, namespace string)

CreateTestUser creates a test user with the specified Kubernetes client and namespace.

func DeleteCapp

func DeleteCapp(k8sClient client.Client, capp *cappv1alpha1.Capp)

DeleteCapp deletes an existing Capp instance.

func DeleteExcludedServiceAccount added in v0.3.3

func DeleteExcludedServiceAccount(k8sClient client.Client)

DeleteExcludedServiceAccount deletes the excluded user created in the specified namespace.

func DeleteTestUser added in v0.2.0

func DeleteTestUser(k8sClient client.Client, namespace string)

DeleteTestUser deletes the test user created in the specified namespace.

func DoesFinalizerExist

func DoesFinalizerExist(k8sClient client.Client, cappName string, cappNamespace string, finalizerName string) bool

DoesFinalizerExist checks if a finalizer exists on a Capp.

func DoesResourceExist

func DoesResourceExist(k8sClient client.Client, obj client.Object) bool

DoesResourceExist checks if a given Kubernetes object exists in the cluster.

func GenerateUniqueCappName added in v0.1.6

func GenerateUniqueCappName(baseCappName string) string

GenerateUniqueCappName generates a unique Capp name.

func GenerateUniqueName added in v0.2.0

func GenerateUniqueName(baseSecretName string) string

GenerateUniqueName generates a unique name.

func GetAddOnPlacementScore added in v0.1.4

func GetAddOnPlacementScore(k8sClient client.Client, name string, namespace string) *clusterv1alpha1.AddOnPlacementScore

GetAddOnPlacementScore fetches an existing GetAddOnPlacementScore and returns its instance.

func GetCapp

func GetCapp(k8sClient client.Client, name string, namespace string) *cappv1alpha1.Capp

GetCapp fetches an existing Capp and return the instance.

func GetCappFromManifestWork

func GetCappFromManifestWork(manifestWork workv1.ManifestWork) unstructured.Unstructured

GetCappFromManifestWork returns a Capp from its corresponding ManifestWork.

func GetCappWithPlacementAnnotation added in v0.2.0

func GetCappWithPlacementAnnotation(k8sClient client.Client, name, namespace string) *cappv1alpha1.Capp

GetCappWithPlacementAnnotation checks whether a Capp eventually has a placement annotation. If it exists then it returns an up-to-date Capp which contains the annotation.

func IsObjInManifestWork

func IsObjInManifestWork(k8sClient client.Client, manifestWork workv1.ManifestWork, objName string, objNamespace string, object client.Object, kind string) (bool, error)

IsObjInManifestWork checks if a given object is in the ManifestWork's manifests list.

func IsRbacObjInManifestWork

func IsRbacObjInManifestWork(manifestWork workv1.ManifestWork, cappName string, nsName string, kind string) bool

IsRbacObjInManifestWork checks if a given role/rolebinding object is in the ManifestWork's manifests list.

func IsSiteInPlacement

func IsSiteInPlacement(k8sClient client.Client, placementName string, placementNamespace string) (bool, error)

IsSiteInPlacement checks if a given site is part of a clusterset mentioned in a placement.

func SwitchUser added in v0.2.0

func SwitchUser(k8sClient *client.Client, cfg *rest.Config, namespace string, scheme *runtime.Scheme, serviceAccountName string)

SwitchUser switches the Kubernetes client's user context to the given serviceAccountName if it's not empty. If serviceAccountName is empty, it reverts to the original context.

func UpdateCapp

func UpdateCapp(k8sClient client.Client, capp *cappv1alpha1.Capp)

UpdateCapp updates the provided Capp instance in the Kubernetes cluster, and returns it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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