common

package
v0.0.0-...-317aa01 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SuiteController

type SuiteController struct {
	// Wrap K8S client go to interact with Kube cluster
	*kubeCl.CustomClient

	// Github client to interact with GH apis
	Github *github.Github
}

Create the struct for kubernetes and github clients.

func NewSuiteController

func NewSuiteController(kubeC *kubeCl.CustomClient) (*SuiteController, error)

Create controller for the common kubernetes API crud operations. This controller should be used only to interact with non RHTAP/AppStudio APIS like routes, deployment, pods etc... Check if a github organization env var is set, if not use by default the redhat-appstudio-qe org. See: https://github.com/redhat-appstudio-qe

func (*SuiteController) AddRegistryAuthSecretToSA

func (s *SuiteController) AddRegistryAuthSecretToSA(registryAuth, namespace string) error

AddRegistryAuthSecretToSA adds registry auth secret to service account

func (*SuiteController) CheckWorkspaceShare

func (s *SuiteController) CheckWorkspaceShare(user, namespace string) error

CheckWorkspaceShare checks if the given user was added to given namespace

func (*SuiteController) CreateConfigMap

func (s *SuiteController) CreateConfigMap(cm *corev1.ConfigMap, namespace string) (*corev1.ConfigMap, error)

Create and return a configmap by cm name and namespace from the cluster

func (*SuiteController) CreateProxyPlugin

func (s *SuiteController) CreateProxyPlugin(proxyPluginName, proxyPluginNamespace, routeName, routeNamespace string) (*toolchainv1alpha1.ProxyPlugin, error)

CreateProxyPlugin creates an object of ProxyPlugin for the OpenShift route target

func (*SuiteController) CreateRegistryAuthSecret

func (s *SuiteController) CreateRegistryAuthSecret(secretName, namespace, secretStringData string) (*corev1.Secret, error)

CreateRegistryAuthSecret create a docker registry secret in a given ns

func (*SuiteController) CreateRegistryJsonSecret

func (s *SuiteController) CreateRegistryJsonSecret(name, namespace, authKey, keyName string) (*corev1.Secret, error)

CreateRegistryJsonSecret creates a secret for registry repository in namespace given with key passed.

func (*SuiteController) CreateRole

func (s *SuiteController) CreateRole(roleName, namespace string, roleRules map[string][]string) (*rbacv1.Role, error)

CreateRole creates a role with the provided name and namespace using the given list of rules

func (*SuiteController) CreateRoleBinding

func (s *SuiteController) CreateRoleBinding(roleBindingName, namespace, subjectKind, serviceAccountName, serviceAccountNamespace, roleRefKind, roleRefName, roleRefApiGroup string) (*rbacv1.RoleBinding, error)

CreateRoleBinding creates an object of Role Binding in namespace with service account provided and role reference api group.

func (*SuiteController) CreateSecret

func (s *SuiteController) CreateSecret(ns string, secret *corev1.Secret) (*corev1.Secret, error)

Creates a new secret in a specified namespace

func (*SuiteController) CreateServiceAccount

func (s *SuiteController) CreateServiceAccount(name, namespace string, serviceAccountSecretList []corev1.ObjectReference, labels map[string]string) (*corev1.ServiceAccount, error)

CreateServiceAccount creates a service account with the provided name and namespace using the given list of secrets.

func (*SuiteController) CreateSpaceBinding

func (s *SuiteController) CreateSpaceBinding(murName, spaceName, spaceRole string) (*toolchainApi.SpaceBinding, error)

CreateSpaceBinding creates SpaceBinding resource for the given murName and spaceName

func (*SuiteController) CreateTestNamespace

func (s *SuiteController) CreateTestNamespace(name string) (*corev1.Namespace, error)

CreateTestNamespace creates a namespace where Application and Component CR will be created

func (*SuiteController) DeleteAllServiceAccountsInASpecificNamespace

func (h *SuiteController) DeleteAllServiceAccountsInASpecificNamespace(namespace string) error

DeleteAllServiceAccountsInASpecificNamespace deletes all ServiceAccount from a given namespace

func (*SuiteController) DeleteAllSnapshotEnvBindingsInASpecificNamespace

func (s *SuiteController) DeleteAllSnapshotEnvBindingsInASpecificNamespace(namespace string, timeout time.Duration) error

DeleteAllSnapshotEnvBindingsInASpecificNamespace removes all snapshotEnvironmentBindings from a specific namespace. Useful when creating a lot of resources and want to remove all of them

func (*SuiteController) DeleteConfigMap

func (s *SuiteController) DeleteConfigMap(name, namespace string, returnErrorOnNotFound bool) error

DeleteConfigMaps delete a ConfigMap. Optionally, it can avoid returning an error if the resource did not exist: - specify 'false' if it's likely the ConfigMap has already been deleted (for example, because the Namespace was deleted)

func (*SuiteController) DeleteNamespace

func (s *SuiteController) DeleteNamespace(namespace string) error

DeleteNamespace deletes the give namespace.

func (*SuiteController) DeletePod

func (s *SuiteController) DeletePod(podName string, namespace string) error

func (*SuiteController) DeleteProxyPlugin

func (s *SuiteController) DeleteProxyPlugin(proxyPluginName, proxyPluginNamespace string) (bool, error)

DeleteProxyPlugin deletes the ProxyPlugin object

func (*SuiteController) DeleteSecret

func (s *SuiteController) DeleteSecret(ns string, name string) error

Deleted a secret in a specified namespace

func (*SuiteController) DeploymentIsCompleted

func (h *SuiteController) DeploymentIsCompleted(deploymentName, namespace string, readyReplicas int32) wait.ConditionFunc

Checks and waits for a kubernetes deployment object to be completed or not

func (*SuiteController) GetConfigMap

func (s *SuiteController) GetConfigMap(name, namespace string) (*corev1.ConfigMap, error)

Get a configmap by name and namespace from the cluster

func (*SuiteController) GetDeployment

func (h *SuiteController) GetDeployment(deploymentName string, namespace string) (*appsv1.Deployment, error)

GetAppDeploymentByName returns the deployment for a given component name

func (*SuiteController) GetNamespace

func (s *SuiteController) GetNamespace(namespace string) (*corev1.Namespace, error)

GetNamespace returns the requested Namespace object

func (*SuiteController) GetOpenshiftIngress

func (s *SuiteController) GetOpenshiftIngress() (ingress *openshiftApi.Ingress, err error)

Obtain the Openshift ingress specs

func (*SuiteController) GetOpenshiftRoute

func (h *SuiteController) GetOpenshiftRoute(routeName string, routeNamespace string) (*routev1.Route, error)

GetOpenshiftRoute returns the route for a given component name

func (*SuiteController) GetOpenshiftRouteByComponentName

func (h *SuiteController) GetOpenshiftRouteByComponentName(componentName string, componentNamespace string) (*routev1.Route, error)

GetOpenshiftRouteByComponentName returns a route associated with the given component Routes that belong to a given component will have the following label: 'app.kubernetes.io/name: <component-name>'

func (*SuiteController) GetPod

func (s *SuiteController) GetPod(namespace, podName string) (*corev1.Pod, error)

GetPod returns the pod object from a given namespace and pod name

func (*SuiteController) GetPodLogs

func (s *SuiteController) GetPodLogs(pod *corev1.Pod) map[string][]byte

func (*SuiteController) GetResourceQuota

func (s *SuiteController) GetResourceQuota(namespace, ResourceQuotaName string) (*corev1.ResourceQuota, error)

GetResourceQuota returns the ResourceQuota object from a given namespace and ResourceQuota name

func (*SuiteController) GetResourceQuotaInfo

func (s *SuiteController) GetResourceQuotaInfo(test, namespace, resourceQuotaName string) error

GetResourceQuotaInfo returns the available resources and its usage in a given test, namespace, and ResourceQuota name

func (*SuiteController) GetRole

func (s *SuiteController) GetRole(roleName, namespace string) (*rbacv1.Role, error)

func (*SuiteController) GetRoleBinding

func (s *SuiteController) GetRoleBinding(rolebindingName, namespace string) (*rbacv1.RoleBinding, error)

func (*SuiteController) GetSecret

func (s *SuiteController) GetSecret(ns string, name string) (*corev1.Secret, error)

Check if a secret exists, return secret and error

func (*SuiteController) GetServiceAccount

func (s *SuiteController) GetServiceAccount(saName, namespace string) (*corev1.ServiceAccount, error)

func (*SuiteController) GetServiceByName

func (h *SuiteController) GetServiceByName(serviceName string, serviceNamespace string) (*corev1.Service, error)

GetServiceByName returns the service for a given component name

func (*SuiteController) GetSnapshotEnvironmentBinding

func (s *SuiteController) GetSnapshotEnvironmentBinding(applicationName string, namespace string, environment *appservice.Environment) (*appservice.SnapshotEnvironmentBinding, error)

GetSnapshotEnvironmentBinding returns the SnapshotEnvironmentBinding related to the given App and Environment

func (*SuiteController) HaveTestsFinished

func (s *SuiteController) HaveTestsFinished(snapshot *appstudioApi.Snapshot) bool

func (*SuiteController) HaveTestsSucceeded

func (s *SuiteController) HaveTestsSucceeded(snapshot *appstudioApi.Snapshot) bool

func (*SuiteController) IsPodRunning

func (s *SuiteController) IsPodRunning(podName, namespace string) wait.ConditionFunc

func (*SuiteController) IsPodSuccessful

func (s *SuiteController) IsPodSuccessful(podName, namespace string) wait.ConditionFunc

Checks phases of a given pod name in a given namespace

func (*SuiteController) LinkSecretToServiceAccount

func (s *SuiteController) LinkSecretToServiceAccount(ns, secret, serviceaccount string, addImagePullSecrets bool) error

Links a secret to a specified serviceaccount, if argument addImagePullSecrets is true secret will be added also to ImagePullSecrets of SA.

func (*SuiteController) ListAllPods

func (s *SuiteController) ListAllPods(namespace string) (*corev1.PodList, error)

ListAllPods returns a list of all pods in a namespace.

func (*SuiteController) ListAllSnapshotEnvBindings

func (s *SuiteController) ListAllSnapshotEnvBindings(namespace string) (*appservice.SnapshotEnvironmentBindingList, error)

ListAllSnapshotEnvBindings returns a list of all SnapshotEnvBindings in a given namespace.

func (*SuiteController) ListNamespaceScopedResourcesAsString

func (s *SuiteController) ListNamespaceScopedResourcesAsString(namespace string, k8sInterface kubernetes.Interface, dynamicInterface dynamic.Interface) string

ListNamespaceScopedResourcesAsString returns a list of resources in a namespace as a string, for test debugging purposes.

func (*SuiteController) ListPods

func (s *SuiteController) ListPods(namespace, labelKey, labelValue string, selectionLimit int64) (*corev1.PodList, error)

ListPods return a list of pods from a namespace by labels and selection limits

func (*SuiteController) ListRoleBindings

func (s *SuiteController) ListRoleBindings(namespace string) (*rbacv1.RoleBindingList, error)

func (*SuiteController) ListRoles

func (s *SuiteController) ListRoles(namespace string) (*rbacv1.RoleList, error)

func (*SuiteController) MarkTestsSucceeded

func (s *SuiteController) MarkTestsSucceeded(snapshot *appstudioApi.Snapshot) (*appstudioApi.Snapshot, error)

func (*SuiteController) RouteEndpointIsAccessible

func (h *SuiteController) RouteEndpointIsAccessible(route *routev1.Route, endpoint string) error

Checks that the deployed route endpoint is actually reachable and returns 200

func (*SuiteController) RouteHostnameIsAccessible

func (h *SuiteController) RouteHostnameIsAccessible(routeName string, namespace string) wait.ConditionFunc

func (*SuiteController) ServiceAccountPresent

func (s *SuiteController) ServiceAccountPresent(saName, namespace string) wait.ConditionFunc

func (*SuiteController) StoreAllPods

func (s *SuiteController) StoreAllPods(namespace string) error

StoreAllPods stores all pods in a given namespace.

func (*SuiteController) StoreAllSnapshotEnvironmentBindings

func (s *SuiteController) StoreAllSnapshotEnvironmentBindings(namespace string) error

StoreAllSnapshotEnvironmentBindings stores all SnapshotEnvBindings in a given namespace.

func (*SuiteController) StorePod

func (s *SuiteController) StorePod(pod *corev1.Pod) error

StorePod stores a given pod as an artifact.

func (*SuiteController) StoreSnapshotEnvBinding

func (s *SuiteController) StoreSnapshotEnvBinding(snapshotEnvBinding *appservice.SnapshotEnvironmentBinding) error

StoreSnapshotEnvBinding stores a SnapshotEnvBinding as an artifact.

func (*SuiteController) UnlinkSecretFromServiceAccount

func (s *SuiteController) UnlinkSecretFromServiceAccount(namespace, secretName, serviceAccount string, rmImagePullSecrets bool) error

UnlinkSecretFromServiceAccount unlinks secret from service account

func (*SuiteController) UpdateConfigMap

func (s *SuiteController) UpdateConfigMap(cm *corev1.ConfigMap, namespace string) (*corev1.ConfigMap, error)

Update and return a configmap by configmap cm name and namespace from the cluster

func (*SuiteController) WaitForPodSelector

func (s *SuiteController) WaitForPodSelector(
	fn func(podName, namespace string) wait.ConditionFunc, namespace, labelKey string, labelValue string,
	timeout int, selectionLimit int64) error

Wait for a pod selector until exists

Jump to

Keyboard shortcuts

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