k8s

package
v0.0.0-...-07c49c1 Latest Latest
Warning

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

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

Documentation

Overview

Package k8s provides common functionalities for interacting with a Kubernetes cluster in the context of infrastructure testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConfigContextForServiceAccountE

func AddConfigContextForServiceAccountE(
	t testing.TestingT,
	kubectlOptions *KubectlOptions,
	contextName string,
	serviceAccountName string,
	token string,
) error

AddConfigContextForServiceAccountE will add a new config context that binds the ServiceAccount auth token to the Kubernetes cluster of the current config context.

func AreAllNodesReady

func AreAllNodesReady(t testing.TestingT, options *KubectlOptions) bool

AreAllNodesReady checks if all nodes are ready in the Kubernetes cluster targeted by the current config context

func AreAllNodesReadyE

func AreAllNodesReadyE(t testing.TestingT, options *KubectlOptions) (bool, error)

AreAllNodesReadyE checks if all nodes are ready in the Kubernetes cluster targeted by the current config context. If false, returns an error indicating the reason.

func CanIDo

func CanIDo(t testing.TestingT, options *KubectlOptions, action authv1.ResourceAttributes) bool

CanIDo returns whether or not the provided action is allowed by the client configured by the provided kubectl option. This will fail if there are any errors accessing the kubernetes API (but not if the action is denied).

func CanIDoE

func CanIDoE(t testing.TestingT, options *KubectlOptions, action authv1.ResourceAttributes) (bool, error)

CanIDoE returns whether or not the provided action is allowed by the client configured by the provided kubectl option. This will an error if there are problems accessing the kubernetes API (but not if the action is simply denied).

func CopyHomeKubeConfigToTemp

func CopyHomeKubeConfigToTemp(t testing.TestingT) string

CopyHomeKubeConfigToTemp will copy the kubeconfig in the home directory to a temp file. This will fail the test if there are any errors.

func CopyHomeKubeConfigToTempE

func CopyHomeKubeConfigToTempE(t testing.TestingT) (string, error)

CopyHomeKubeConfigToTempE will copy the kubeconfig in the home directory to a temp file.

func CreateNamespace

func CreateNamespace(t testing.TestingT, options *KubectlOptions, namespaceName string)

CreateNamespace will create a new Kubernetes namespace on the cluster targeted by the provided options. This will fail the test if there is an error in creating the namespace.

func CreateNamespaceE

func CreateNamespaceE(t testing.TestingT, options *KubectlOptions, namespaceName string) error

CreateNamespaceE will create a new Kubernetes namespace on the cluster targeted by the provided options.

func CreateNamespaceWithMetadata

func CreateNamespaceWithMetadata(t testing.TestingT, options *KubectlOptions, namespaceObjectMeta metav1.ObjectMeta)

CreateNamespaceWithMetadata will create a new Kubernetes namespace on the cluster targeted by the provided options and with the provided metadata. This method expects the entire namespace ObjectMeta to be passed in, so you'll need to set the name within the ObjectMeta struct yourself. This will fail the test if there is an error while creating the namespace.

func CreateNamespaceWithMetadataE

func CreateNamespaceWithMetadataE(t testing.TestingT, options *KubectlOptions, namespaceObjectMeta metav1.ObjectMeta) error

CreateNamespaceWithMetadataE will create a new Kubernetes namespace on the cluster targeted by the provided options and with the provided metadata. This method expects the entire namespace ObjectMeta to be passed in, so you'll need to set the name within the ObjectMeta struct yourself.

func CreateServiceAccount

func CreateServiceAccount(t testing.TestingT, options *KubectlOptions, serviceAccountName string)

CreateServiceAccount will create a new service account resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions. This will fail the test if there is an error.

func CreateServiceAccountE

func CreateServiceAccountE(t testing.TestingT, options *KubectlOptions, serviceAccountName string) error

CreateServiceAccountE will create a new service account resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions.

func DeleteConfigContextE

func DeleteConfigContextE(t testing.TestingT, contextName string) error

DeleteConfigContextE will remove the context specified at the provided name, and remove any clusters and authinfos that are orphaned as a result of it. The config path is either specified in the environment variable KUBECONFIG or at the user's home directory under `.kube/config`.

func DeleteConfigContextWithPathE

func DeleteConfigContextWithPathE(t testing.TestingT, kubeConfigPath string, contextName string) error

DeleteConfigContextWithPathE will remove the context specified at the provided name, and remove any clusters and authinfos that are orphaned as a result of it.

func DeleteNamespace

func DeleteNamespace(t testing.TestingT, options *KubectlOptions, namespaceName string)

DeleteNamespace will delete the requested namespace from the Kubernetes cluster targeted by the provided options. This will fail the test if there is an error in creating the namespace.

func DeleteNamespaceE

func DeleteNamespaceE(t testing.TestingT, options *KubectlOptions, namespaceName string) error

DeleteNamespaceE will delete the requested namespace from the Kubernetes cluster targeted by the provided options.

func FindNodeHostnameE

func FindNodeHostnameE(t testing.TestingT, node corev1.Node) (string, error)

Given a node, return the ip address, preferring the external IP

func FindNodePortE

func FindNodePortE(service *corev1.Service, servicePort int32) (int32, error)

Given the desired servicePort, return the allocated nodeport

func GetAvailablePort

func GetAvailablePort(t testing.TestingT) int

GetAvailablePort retrieves an available port on the host machine. This delegates the port selection to the golang net library by starting a server and then checking the port that the server is using. This will fail the test if it could not find an available port.

func GetAvailablePortE

func GetAvailablePortE(t testing.TestingT) (int, error)

GetAvailablePortE retrieves an available port on the host machine. This delegates the port selection to the golang net library by starting a server and then checking the port that the server is using.

func GetClusterRole

func GetClusterRole(t testing.TestingT, options *KubectlOptions, roleName string) *rbacv1.ClusterRole

GetClusterRole returns a Kubernetes ClusterRole resource with the given name. This will fail the test if there is an error.

func GetClusterRoleE

func GetClusterRoleE(t testing.TestingT, options *KubectlOptions, roleName string) (*rbacv1.ClusterRole, error)

GetClusterRoleE returns a Kubernetes ClusterRole resource with the given name.

func GetConfigMap

func GetConfigMap(t testing.TestingT, options *KubectlOptions, configMapName string) *corev1.ConfigMap

GetConfigMap returns a Kubernetes configmap resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions. This will fail the test if there is an error.

func GetConfigMapE

func GetConfigMapE(t testing.TestingT, options *KubectlOptions, configMapName string) (*corev1.ConfigMap, error)

GetConfigMapE returns a Kubernetes configmap resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions.

func GetDaemonSet

func GetDaemonSet(t testing.TestingT, options *KubectlOptions, daemonSetName string) *appsv1.DaemonSet

GetDaemonSet returns a Kubernetes daemonset resource in the provided namespace with the given name. This will fail the test if there is an error.

func GetDaemonSetE

func GetDaemonSetE(t testing.TestingT, options *KubectlOptions, daemonSetName string) (*appsv1.DaemonSet, error)

GetDaemonSetE returns a Kubernetes daemonset resource in the provided namespace with the given name.

func GetDeployment

func GetDeployment(t testing.TestingT, options *KubectlOptions, deploymentName string) *appsv1.Deployment

GetDeployment returns a Kubernetes deployment resource in the provided namespace with the given name. This will fail the test if there is an error.

func GetDeploymentE

func GetDeploymentE(t testing.TestingT, options *KubectlOptions, deploymentName string) (*appsv1.Deployment, error)

GetDeploymentE returns a Kubernetes deployment resource in the provided namespace with the given name.

func GetIngress

func GetIngress(t testing.TestingT, options *KubectlOptions, ingressName string) *networkingv1.Ingress

GetIngress returns a Kubernetes Ingress resource in the provided namespace with the given name. This will fail the test if there is an error.

func GetIngressE

func GetIngressE(t testing.TestingT, options *KubectlOptions, ingressName string) (*networkingv1.Ingress, error)

GetIngressE returns a Kubernetes Ingress resource in the provided namespace with the given name.

func GetIngressV1Beta1

func GetIngressV1Beta1(t testing.TestingT, options *KubectlOptions, ingressName string) *networkingv1beta1.Ingress

GetIngressV1Beta1 returns a Kubernetes Ingress resource in the provided namespace with the given name, using networking.k8s.io/v1beta1 API. This will fail the test if there is an error.

func GetIngressV1Beta1E

func GetIngressV1Beta1E(t testing.TestingT, options *KubectlOptions, ingressName string) (*networkingv1beta1.Ingress, error)

GetIngressV1Beta1E returns a Kubernetes Ingress resource in the provided namespace with the given name, using networking.k8s.io/v1beta1.

func GetJob

func GetJob(t testing.TestingT, options *KubectlOptions, jobName string) *batchv1.Job

GetJob returns a Kubernetes job resource in the provided namespace with the given name. This will fail the test if there is an error.

func GetJobE

func GetJobE(t testing.TestingT, options *KubectlOptions, jobName string) (*batchv1.Job, error)

GetJobE returns a Kubernetes job resource in the provided namespace with the given name.

func GetKubeConfigPathE

func GetKubeConfigPathE(t testing.TestingT) (string, error)

GetKubeConfigPathE determines which file path to use as the kubectl config path

func GetKubernetesClientE

func GetKubernetesClientE(t testing.TestingT) (*kubernetes.Clientset, error)

GetKubernetesClientE returns a Kubernetes API client that can be used to make requests.

func GetKubernetesClientFromOptionsE

func GetKubernetesClientFromOptionsE(t testing.TestingT, options *KubectlOptions) (*kubernetes.Clientset, error)

GetKubernetesClientFromOptionsE returns a Kubernetes API client given a configured KubectlOptions object.

func GetKubernetesClusterVersionE

func GetKubernetesClusterVersionE(t testing.TestingT) (string, error)

GetKubernetesClusterVersion returns the Kubernetes cluster version.

func GetKubernetesClusterVersionWithOptionsE

func GetKubernetesClusterVersionWithOptionsE(t testing.TestingT, kubectlOptions *KubectlOptions) (string, error)

GetKubernetesClusterVersion returns the Kubernetes cluster version given a configured KubectlOptions object.

func GetNamespace

func GetNamespace(t testing.TestingT, options *KubectlOptions, namespaceName string) *corev1.Namespace

GetNamespace will query the Kubernetes cluster targeted by the provided options for the requested namespace. This will fail the test if there is an error in getting the namespace or if the namespace doesn't exist.

func GetNamespaceE

func GetNamespaceE(t testing.TestingT, options *KubectlOptions, namespaceName string) (*corev1.Namespace, error)

GetNamespaceE will query the Kubernetes cluster targeted by the provided options for the requested namespace.

func GetNetworkPolicy

func GetNetworkPolicy(t testing.TestingT, options *KubectlOptions, networkPolicyName string) *networkingv1.NetworkPolicy

GetNetworkPolicy returns a Kubernetes networkpolicy resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions. This will fail the test if there is an error.

func GetNetworkPolicyE

func GetNetworkPolicyE(t testing.TestingT, options *KubectlOptions, networkPolicyName string) (*networkingv1.NetworkPolicy, error)

GetNetworkPolicyE returns a Kubernetes networkpolicy resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions.

func GetNodes

func GetNodes(t testing.TestingT, options *KubectlOptions) []corev1.Node

GetNodes queries Kubernetes for information about the worker nodes registered to the cluster. If anything goes wrong, the function will automatically fail the test.

func GetNodesByFilterE

func GetNodesByFilterE(t testing.TestingT, options *KubectlOptions, filter metav1.ListOptions) ([]corev1.Node, error)

GetNodesByFilterE queries Kubernetes for information about the worker nodes registered to the cluster, filtering the list of nodes using the provided ListOptions.

func GetNodesE

func GetNodesE(t testing.TestingT, options *KubectlOptions) ([]corev1.Node, error)

GetNodesE queries Kubernetes for information about the worker nodes registered to the cluster.

func GetPersistentVolume

func GetPersistentVolume(t testing.TestingT, options *KubectlOptions, name string) *corev1.PersistentVolume

GetPersistentVolume returns a Kubernetes PersistentVolume resource with the given name. This will fail the test if there is an error.

func GetPersistentVolumeClaim

func GetPersistentVolumeClaim(t testing.TestingT, options *KubectlOptions, pvcName string) *corev1.PersistentVolumeClaim

GetPersistentVolumeClaim returns a Kubernetes PersistentVolumeClaim resource in the provided namespace with the given name. This will fail the test if there is an error.

func GetPersistentVolumeClaimE

func GetPersistentVolumeClaimE(t testing.TestingT, options *KubectlOptions, pvcName string) (*corev1.PersistentVolumeClaim, error)

GetPersistentVolumeClaimE returns a Kubernetes PersistentVolumeClaim resource in the provided namespace with the given name.

func GetPersistentVolumeE

func GetPersistentVolumeE(t testing.TestingT, options *KubectlOptions, name string) (*corev1.PersistentVolume, error)

GetPersistentVolumeE returns a Kubernetes PersistentVolume resource with the given name.

func GetPod

func GetPod(t testing.TestingT, options *KubectlOptions, podName string) *corev1.Pod

GetPod returns a Kubernetes pod resource in the provided namespace with the given name. This will fail the test if there is an error.

func GetPodE

func GetPodE(t testing.TestingT, options *KubectlOptions, podName string) (*corev1.Pod, error)

GetPodE returns a Kubernetes pod resource in the provided namespace with the given name.

func GetPodLogs

func GetPodLogs(t testing.TestingT, options *KubectlOptions, pod *corev1.Pod, containerName string) string

GetPodLogsE returns the logs of a Pod at the time when the function was called. Pass container name if there are more containers in the Pod or set to "" if there is only one.

func GetPodLogsE

func GetPodLogsE(t testing.TestingT, options *KubectlOptions, pod *corev1.Pod, containerName string) (string, error)

GetPodLogsE returns the logs of a Pod at the time when the function was called. Pass container name if there are more containers in the Pod or set to "" if there is only one. If the Pod is not running an Error is returned. If the provided containerName is not the name of a container in the Pod an Error is returned.

func GetReadyNodes

func GetReadyNodes(t testing.TestingT, options *KubectlOptions) []corev1.Node

GetReadyNodes queries Kubernetes for information about the worker nodes registered to the cluster and only returns those that are in the ready state. If anything goes wrong, the function will automatically fail the test.

func GetReadyNodesE

func GetReadyNodesE(t testing.TestingT, options *KubectlOptions) ([]corev1.Node, error)

GetReadyNodesE queries Kubernetes for information about the worker nodes registered to the cluster and only returns those that are in the ready state.

func GetReplicaSet

func GetReplicaSet(t testing.TestingT, options *KubectlOptions, replicaSetName string) *appsv1.ReplicaSet

GetReplicaSet returns a Kubernetes replicaset resource in the provided namespace with the given name. This will fail the test if there is an error.

func GetReplicaSetE

func GetReplicaSetE(t testing.TestingT, options *KubectlOptions, replicaSetName string) (*appsv1.ReplicaSet, error)

GetReplicaSetE returns a Kubernetes replicaset resource in the provided namespace with the given name.

func GetRole

func GetRole(t testing.TestingT, options *KubectlOptions, roleName string) *rbacv1.Role

GetRole returns a Kubernetes role resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions. This will fail the test if there is an error.

func GetRoleE

func GetRoleE(t testing.TestingT, options *KubectlOptions, roleName string) (*rbacv1.Role, error)

GetRoleE returns a Kubernetes role resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions.

func GetSecret

func GetSecret(t testing.TestingT, options *KubectlOptions, secretName string) *corev1.Secret

GetSecret returns a Kubernetes secret resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions. This will fail the test if there is an error.

func GetSecretE

func GetSecretE(t testing.TestingT, options *KubectlOptions, secretName string) (*corev1.Secret, error)

GetSecretE returns a Kubernetes secret resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions.

func GetService

func GetService(t testing.TestingT, options *KubectlOptions, serviceName string) *corev1.Service

GetService returns a Kubernetes service resource in the provided namespace with the given name. This will fail the test if there is an error.

func GetServiceAccount

func GetServiceAccount(t testing.TestingT, options *KubectlOptions, serviceAccountName string) *corev1.ServiceAccount

GetServiceAccount returns a Kubernetes service account resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions. This will fail the test if there is an error.

func GetServiceAccountAuthToken

func GetServiceAccountAuthToken(t testing.TestingT, kubectlOptions *KubectlOptions, serviceAccountName string) string

GetServiceAccountAuthToken will retrieve the ServiceAccount token from the cluster so it can be used to authenticate requests as that ServiceAccount. This will fail the test if there is an error.

func GetServiceAccountAuthTokenE

func GetServiceAccountAuthTokenE(t testing.TestingT, kubectlOptions *KubectlOptions, serviceAccountName string) (string, error)

GetServiceAccountAuthTokenE will retrieve the ServiceAccount token from the cluster so it can be used to authenticate requests as that ServiceAccount.

func GetServiceAccountE

func GetServiceAccountE(t testing.TestingT, options *KubectlOptions, serviceAccountName string) (*corev1.ServiceAccount, error)

GetServiceAccountE returns a Kubernetes service account resource in the provided namespace with the given name. The namespace used is the one provided in the KubectlOptions.

func GetServiceE

func GetServiceE(t testing.TestingT, options *KubectlOptions, serviceName string) (*corev1.Service, error)

GetServiceE returns a Kubernetes service resource in the provided namespace with the given name.

func GetServiceEndpoint

func GetServiceEndpoint(t testing.TestingT, options *KubectlOptions, service *corev1.Service, servicePort int) string

GetServiceEndpoint will return the service access point. If the service endpoint is not ready, will fail the test immediately.

func GetServiceEndpointE

func GetServiceEndpointE(t testing.TestingT, options *KubectlOptions, service *corev1.Service, servicePort int) (string, error)

GetServiceEndpointE will return the service access point using the following logic:

  • For ClusterIP service type, return the URL that maps to ClusterIP and Service Port
  • For NodePort service type, identify the public IP of the node (if it exists, otherwise return the bound hostname), and the assigned node port for the provided service port, and return the URL that maps to node ip and node port.
  • For LoadBalancer service type, return the publicly accessible hostname of the load balancer. If the hostname is empty, it will return the public IP of the LoadBalancer.
  • All other service types are not supported.

func IsDeploymentAvailable

func IsDeploymentAvailable(deploy *appsv1.Deployment) bool

IsDeploymentAvailable returns true if all pods within the deployment are ready and started

func IsIngressAvailable

func IsIngressAvailable(ingress *networkingv1.Ingress) bool

IsIngressAvailable returns true if the Ingress endpoint is provisioned and available.

func IsIngressAvailableV1Beta1

func IsIngressAvailableV1Beta1(ingress *networkingv1beta1.Ingress) bool

IsIngressAvailableV1Beta1 returns true if the Ingress endpoint is provisioned and available, using networking.k8s.io/v1beta1 API.

func IsJobSucceeded

func IsJobSucceeded(job *batchv1.Job) bool

IsJobSucceeded returns true when the job status condition "Complete" is true. This behavior is documented in the kubernetes API reference: https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/job-v1/#JobStatus

func IsMinikubeE

func IsMinikubeE(t testing.TestingT, options *KubectlOptions) (bool, error)

IsMinikubeE returns true if the underlying kubernetes cluster is Minikube. This is determined by getting the associated nodes and checking if all nodes has at least one label namespaced with "minikube.k8s.io".

func IsNodeReady

func IsNodeReady(node corev1.Node) bool

IsNodeReady takes a Kubernetes Node information object and checks if the Node is in the ready state.

func IsPersistentVolumeClaimInStatus

func IsPersistentVolumeClaimInStatus(pvc *corev1.PersistentVolumeClaim, pvcStatusPhase *corev1.PersistentVolumeClaimPhase) bool

IsPersistentVolumeClaimInStatus returns true if the given PersistentVolumeClaim is in the given status phase

func IsPersistentVolumeInStatus

func IsPersistentVolumeInStatus(pv *corev1.PersistentVolume, pvStatusPhase *corev1.PersistentVolumePhase) bool

IsPersistentVolumeInStatus returns true if the given PersistentVolume is in the given status phase

func IsPodAvailable

func IsPodAvailable(pod *corev1.Pod) bool

IsPodAvailable returns true if the all of the containers within the pod are ready and started

func IsServiceAvailable

func IsServiceAvailable(service *corev1.Service) bool

IsServiceAvailable returns true if the service endpoint is ready to accept traffic. Note that for Minikube, this function is moot as all services, even LoadBalancer, is available immediately.

func KubeConfigPathFromHomeDirE

func KubeConfigPathFromHomeDirE() (string, error)

KubeConfigPathFromHomeDirE returns a string to the default Kubernetes config path in the home directory. This will error if the home directory can not be determined.

func KubectlApply

func KubectlApply(t testing.TestingT, options *KubectlOptions, configPath string)

KubectlApply will take in a file path and apply it to the cluster targeted by KubectlOptions. If there are any errors, fail the test immediately.

func KubectlApplyE

func KubectlApplyE(t testing.TestingT, options *KubectlOptions, configPath string) error

KubectlApplyE will take in a file path and apply it to the cluster targeted by KubectlOptions.

func KubectlApplyFromKustomize

func KubectlApplyFromKustomize(t testing.TestingT, options *KubectlOptions, configPath string)

KubectlApplyFromKustomize will take in a kustomization directory path and apply it to the cluster targeted by KubectlOptions. If there are any errors, fail the test immediately.

func KubectlApplyFromKustomizeE

func KubectlApplyFromKustomizeE(t testing.TestingT, options *KubectlOptions, configPath string) error

KubectlApplyFromKustomizeE will take in a kustomization directory path and apply it to the cluster targeted by KubectlOptions.

func KubectlApplyFromString

func KubectlApplyFromString(t testing.TestingT, options *KubectlOptions, configData string)

KubectlApplyFromString will take in a kubernetes resource config as a string and apply it on the cluster specified by the provided kubectl options.

func KubectlApplyFromStringE

func KubectlApplyFromStringE(t testing.TestingT, options *KubectlOptions, configData string) error

KubectlApplyFromStringE will take in a kubernetes resource config as a string and apply it on the cluster specified by the provided kubectl options. If it fails, this will return the error.

func KubectlDelete

func KubectlDelete(t testing.TestingT, options *KubectlOptions, configPath string)

KubectlDelete will take in a file path and delete it from the cluster targeted by KubectlOptions. If there are any errors, fail the test immediately.

func KubectlDeleteE

func KubectlDeleteE(t testing.TestingT, options *KubectlOptions, configPath string) error

KubectlDeleteE will take in a file path and delete it from the cluster targeted by KubectlOptions.

func KubectlDeleteFromKustomize

func KubectlDeleteFromKustomize(t testing.TestingT, options *KubectlOptions, configPath string)

KubectlDeleteFromKustomize will take in a kustomization directory path and delete it from the cluster targeted by KubectlOptions. If there are any errors, fail the test immediately.

func KubectlDeleteFromKustomizeE

func KubectlDeleteFromKustomizeE(t testing.TestingT, options *KubectlOptions, configPath string) error

KubectlDeleteFromKustomizeE will take in a kustomization directory path and delete it from the cluster targeted by KubectlOptions.

func KubectlDeleteFromString

func KubectlDeleteFromString(t testing.TestingT, options *KubectlOptions, configData string)

KubectlDeleteFromString will take in a kubernetes resource config as a string and delete it on the cluster specified by the provided kubectl options.

func KubectlDeleteFromStringE

func KubectlDeleteFromStringE(t testing.TestingT, options *KubectlOptions, configData string) error

KubectlDeleteFromStringE will take in a kubernetes resource config as a string and delete it on the cluster specified by the provided kubectl options. If it fails, this will return the error.

func ListDaemonSets

func ListDaemonSets(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) []appsv1.DaemonSet

ListDaemonSets will look for daemonsets in the given namespace that match the given filters and return them. This will fail the test if there is an error.

func ListDaemonSetsE

func ListDaemonSetsE(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) ([]appsv1.DaemonSet, error)

ListDaemonSetsE will look for daemonsets in the given namespace that match the given filters and return them.

func ListDeployments

func ListDeployments(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) []appsv1.Deployment

ListDeployments will look for deployments in the given namespace that match the given filters and return them. This will fail the test if there is an error.

func ListDeploymentsE

func ListDeploymentsE(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) ([]appsv1.Deployment, error)

ListDeploymentsE will look for deployments in the given namespace that match the given filters and return them.

func ListEvents

func ListEvents(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) []corev1.Event

ListEvents will retrieve the Events in the given namespace that match the given filters and return them. This will fail the test if there is an error.

func ListEventsE

func ListEventsE(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) ([]corev1.Event, error)

ListEventsE will retrieve the Events that match the given filters and return them.

func ListIngresses

func ListIngresses(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) []networkingv1.Ingress

ListIngresses will look for Ingress resources in the given namespace that match the given filters and return them. This will fail the test if there is an error.

func ListIngressesE

func ListIngressesE(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) ([]networkingv1.Ingress, error)

ListIngressesE will look for Ingress resources in the given namespace that match the given filters and return them.

func ListIngressesV1Beta1

func ListIngressesV1Beta1(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) []networkingv1beta1.Ingress

ListIngressesV1Beta1 will look for Ingress resources in the given namespace that match the given filters and return them, using networking.k8s.io/v1beta1 API. This will fail the test if there is an error.

func ListIngressesV1Beta1E

func ListIngressesV1Beta1E(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) ([]networkingv1beta1.Ingress, error)

ListIngressesV1Beta1E will look for Ingress resources in the given namespace that match the given filters and return them, using networking.k8s.io/v1beta1 API.

func ListJobs

func ListJobs(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) []batchv1.Job

ListJobs will look for Jobs in the given namespace that match the given filters and return them. This will fail the test if there is an error.

func ListJobsE

func ListJobsE(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) ([]batchv1.Job, error)

ListJobsE will look for jobs in the given namespace that match the given filters and return them.

func ListPersistentVolumeClaims

func ListPersistentVolumeClaims(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) []corev1.PersistentVolumeClaim

ListPersistentVolumeClaims will look for PersistentVolumeClaims in the given namespace that match the given filters and return them. This will fail the test if there is an error.

func ListPersistentVolumeClaimsE

func ListPersistentVolumeClaimsE(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) ([]corev1.PersistentVolumeClaim, error)

ListPersistentVolumeClaimsE will look for PersistentVolumeClaims in the given namespace that match the given filters and return them.

func ListPersistentVolumes

func ListPersistentVolumes(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) []corev1.PersistentVolume

ListPersistentVolumes will look for PersistentVolumes in the given namespace that match the given filters and return them. This will fail the test if there is an error.

func ListPersistentVolumesE

func ListPersistentVolumesE(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) ([]corev1.PersistentVolume, error)

ListPersistentVolumesE will look for PersistentVolumes that match the given filters and return them.

func ListPods

func ListPods(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) []corev1.Pod

ListPods will look for pods in the given namespace that match the given filters and return them. This will fail the test if there is an error.

func ListPodsE

func ListPodsE(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) ([]corev1.Pod, error)

ListPodsE will look for pods in the given namespace that match the given filters and return them.

func ListReplicaSets

func ListReplicaSets(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) []appsv1.ReplicaSet

ListReplicaSets will look for replicasets in the given namespace that match the given filters and return them. This will fail the test if there is an error.

func ListReplicaSetsE

func ListReplicaSetsE(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) ([]appsv1.ReplicaSet, error)

ListReplicaSetsE will look for replicasets in the given namespace that match the given filters and return them.

func ListServices

func ListServices(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) []corev1.Service

ListServices will look for services in the given namespace that match the given filters and return them. This will fail the test if there is an error.

func ListServicesE

func ListServicesE(t testing.TestingT, options *KubectlOptions, filters metav1.ListOptions) ([]corev1.Service, error)

ListServicesE will look for services in the given namespace that match the given filters and return them.

func LoadApiClientConfigE

func LoadApiClientConfigE(configPath string, contextName string) (*restclient.Config, error)

LoadApiClientConfigE will load a ClientConfig object from a file path that points to a location on disk containing a kubectl config, with the requested context loaded.

func LoadConfigFromPath

func LoadConfigFromPath(path string) clientcmd.ClientConfig

LoadConfigFromPath will load a ClientConfig object from a file path that points to a location on disk containing a kubectl config.

func RemoveOrphanedClusterAndAuthInfoConfig

func RemoveOrphanedClusterAndAuthInfoConfig(config *api.Config)

RemoveOrphanedClusterAndAuthInfoConfig will remove all configurations related to clusters and users that have no contexts associated with it

func RunKubectl

func RunKubectl(t testing.TestingT, options *KubectlOptions, args ...string)

RunKubectl will call kubectl using the provided options and args, failing the test on error.

func RunKubectlAndGetOutputE

func RunKubectlAndGetOutputE(t testing.TestingT, options *KubectlOptions, args ...string) (string, error)

RunKubectlAndGetOutputE will call kubectl using the provided options and args, returning the output of stdout and stderr.

func RunKubectlE

func RunKubectlE(t testing.TestingT, options *KubectlOptions, args ...string) error

RunKubectlE will call kubectl using the provided options and args.

func StoreConfigToTempFile

func StoreConfigToTempFile(t testing.TestingT, configData string) string

StoreConfigToTempFile will store the provided config data to a temporary file created on the os and return the filename.

func StoreConfigToTempFileE

func StoreConfigToTempFileE(t testing.TestingT, configData string) (string, error)

StoreConfigToTempFileE will store the provided config data to a temporary file created on the os and return the filename, or error.

func UnmarshalJSONPath

func UnmarshalJSONPath(t testing.TestingT, jsonData []byte, jsonpathStr string, output interface{})

UnmarshalJSONPath allows you to use an arbitrary JSONPath string to query a json blob and unmarshal the resulting output into a go object. Note that the output will always be a list. That means that if you query a single object, the output will be a list of single element, not the element itself. However, if the json path maps to a list, then the output will be that list. Example:

jsonBlob := []byte(`{"key": {"data": [1,2,3]}}`) jsonPath := "{.key.data[*]}" var output []int UnmarshalJSONPath(t, jsonBlob, jsonPath, &output) // output is []int{1,2,3}

This will fail the test if there is an error.

func UnmarshalJSONPathE

func UnmarshalJSONPathE(t testing.TestingT, jsonData []byte, jsonpathStr string, output interface{}) error

UnmarshalJSONPathE allows you to use an arbitrary JSONPath string to query a json blob and unmarshal the resulting output into a go object. Note that the output will always be a list. That means that if you query a single object, the output will be a list of single element, not the element itself. However, if the json path maps to a list, then the output will be that list. Example:

jsonBlob := []byte(`{"key": {"data": [1,2,3]}}`) jsonPath := "{.key.data[*]}" var output []int UnmarshalJSONPathE(t, jsonBlob, jsonPath, &output) => output = []int{1,2,3}

func UpsertConfigContext

func UpsertConfigContext(config *api.Config, contextName string, clusterName string, userName string)

UpsertConfigContext will update or insert a new context to the provided config, binding the provided cluster to the provided user.

func WaitUntilAllNodesReady

func WaitUntilAllNodesReady(t testing.TestingT, options *KubectlOptions, retries int, sleepBetweenRetries time.Duration)

WaitUntilAllNodesReady continuously polls the Kubernetes cluster until all nodes in the cluster reach the ready state, or runs out of retries. Will fail the test immediately if it times out.

func WaitUntilAllNodesReadyE

func WaitUntilAllNodesReadyE(t testing.TestingT, options *KubectlOptions, retries int, sleepBetweenRetries time.Duration) error

WaitUntilAllNodesReadyE continuously polls the Kubernetes cluster until all nodes in the cluster reach the ready state, or runs out of retries.

func WaitUntilConfigMapAvailable

func WaitUntilConfigMapAvailable(t testing.TestingT, options *KubectlOptions, configMapName string, retries int, sleepBetweenRetries time.Duration)

WaitUntilConfigMapAvailable waits until the configmap is present on the cluster in cases where it is not immediately available (for example, when using ClusterIssuer to request a certificate).

func WaitUntilDeploymentAvailable

func WaitUntilDeploymentAvailable(t testing.TestingT, options *KubectlOptions, deploymentName string, retries int, sleepBetweenRetries time.Duration)

WaitUntilDeploymentAvailableE waits until all pods within the deployment are ready and started, retrying the check for the specified amount of times, sleeping for the provided duration between each try. This will fail the test if there is an error.

func WaitUntilDeploymentAvailableE

func WaitUntilDeploymentAvailableE(
	t testing.TestingT,
	options *KubectlOptions,
	deploymentName string,
	retries int,
	sleepBetweenRetries time.Duration,
) error

WaitUntilDeploymentAvailableE waits until all pods within the deployment are ready and started, retrying the check for the specified amount of times, sleeping for the provided duration between each try.

func WaitUntilIngressAvailable

func WaitUntilIngressAvailable(t testing.TestingT, options *KubectlOptions, ingressName string, retries int, sleepBetweenRetries time.Duration)

WaitUntilIngressAvailable waits until the Ingress resource has an endpoint provisioned for it.

func WaitUntilIngressAvailableV1Beta1

func WaitUntilIngressAvailableV1Beta1(t testing.TestingT, options *KubectlOptions, ingressName string, retries int, sleepBetweenRetries time.Duration)

WaitUntilIngressAvailableV1Beta1 waits until the Ingress resource has an endpoint provisioned for it, using networking.k8s.io/v1beta1 API.

func WaitUntilJobSucceed

func WaitUntilJobSucceed(t testing.TestingT, options *KubectlOptions, jobName string, retries int, sleepBetweenRetries time.Duration)

WaitUntilJobSucceed waits until requested job is suceeded, retrying the check for the specified amount of times, sleeping for the provided duration between each try. This will fail the test if there is an error or if the check times out.

func WaitUntilJobSucceedE

func WaitUntilJobSucceedE(t testing.TestingT, options *KubectlOptions, jobName string, retries int, sleepBetweenRetries time.Duration) error

WaitUntilJobSucceedE waits until requested job is succeeded, retrying the check for the specified amount of times, sleeping for the provided duration between each try.

func WaitUntilNetworkPolicyAvailable

func WaitUntilNetworkPolicyAvailable(t testing.TestingT, options *KubectlOptions, networkPolicyName string, retries int, sleepBetweenRetries time.Duration)

WaitUntilNetworkPolicyAvailable waits until the networkpolicy is present on the cluster in cases where it is not immediately available (for example, when using ClusterIssuer to request a certificate).

func WaitUntilNumPodsCreated

func WaitUntilNumPodsCreated(
	t testing.TestingT,
	options *KubectlOptions,
	filters metav1.ListOptions,
	desiredCount int,
	retries int,
	sleepBetweenRetries time.Duration,
)

WaitUntilNumPodsCreated waits until the desired number of pods are created that match the provided filter. This will retry the check for the specified amount of times, sleeping for the provided duration between each try. This will fail the test if the retry times out.

func WaitUntilNumPodsCreatedE

func WaitUntilNumPodsCreatedE(
	t testing.TestingT,
	options *KubectlOptions,
	filters metav1.ListOptions,
	desiredCount int,
	retries int,
	sleepBetweenRetries time.Duration,
) error

WaitUntilNumPodsCreatedE waits until the desired number of pods are created that match the provided filter. This will retry the check for the specified amount of times, sleeping for the provided duration between each try.

func WaitUntilPersistentVolumeClaimInStatus

func WaitUntilPersistentVolumeClaimInStatus(t testing.TestingT, options *KubectlOptions, pvcName string, pvcStatusPhase *corev1.PersistentVolumeClaimPhase, retries int, sleepBetweenRetries time.Duration)

WaitUntilPersistentVolumeClaimInStatus waits until the given PersistentVolumeClaim is the given status phase, retrying the check for the specified amount of times, sleeping for the provided duration between each try. This will fail the test if there is an error.

func WaitUntilPersistentVolumeClaimInStatusE

func WaitUntilPersistentVolumeClaimInStatusE(t testing.TestingT, options *KubectlOptions, pvcName string, pvcStatusPhase *corev1.PersistentVolumeClaimPhase, retries int, sleepBetweenRetries time.Duration) error

WaitUntilPersistentVolumeClaimInStatusE waits until the given PersistentVolumeClaim is the given status phase, retrying the check for the specified amount of times, sleeping for the provided duration between each try. This will fail the test if there is an error.

func WaitUntilPersistentVolumeInStatus

func WaitUntilPersistentVolumeInStatus(t testing.TestingT, options *KubectlOptions, pvName string, pvStatusPhase *corev1.PersistentVolumePhase, retries int, sleepBetweenRetries time.Duration)

WaitUntilPersistentVolumeInStatus waits until the given Persistent Volume is the given status phase, retrying the check for the specified amount of times, sleeping for the provided duration between each try. This will fail the test if there is an error.

func WaitUntilPersistentVolumeInStatusE

func WaitUntilPersistentVolumeInStatusE(
	t testing.TestingT,
	options *KubectlOptions,
	pvName string,
	pvStatusPhase *corev1.PersistentVolumePhase,
	retries int,
	sleepBetweenRetries time.Duration,
) error

WaitUntilPersistentVolumeInStatusE waits until the given PersistentVolume is in the given status phase, retrying the check for the specified amount of times, sleeping for the provided duration between each try.

func WaitUntilPodAvailable

func WaitUntilPodAvailable(t testing.TestingT, options *KubectlOptions, podName string, retries int, sleepBetweenRetries time.Duration)

WaitUntilPodAvailable waits until all of the containers within the pod are ready and started, retrying the check for the specified amount of times, sleeping for the provided duration between each try. This will fail the test if there is an error or if the check times out.

func WaitUntilPodAvailableE

func WaitUntilPodAvailableE(t testing.TestingT, options *KubectlOptions, podName string, retries int, sleepBetweenRetries time.Duration) error

WaitUntilPodAvailableE waits until all of the containers within the pod are ready and started, retrying the check for the specified amount of times, sleeping for the provided duration between each try.

func WaitUntilSecretAvailable

func WaitUntilSecretAvailable(t testing.TestingT, options *KubectlOptions, secretName string, retries int, sleepBetweenRetries time.Duration)

WaitUntilSecretAvailable waits until the secret is present on the cluster in cases where it is not immediately available (for example, when using ClusterIssuer to request a certificate).

func WaitUntilServiceAvailable

func WaitUntilServiceAvailable(t testing.TestingT, options *KubectlOptions, serviceName string, retries int, sleepBetweenRetries time.Duration)

WaitUntilServiceAvailable waits until the service endpoint is ready to accept traffic.

Types

type DeploymentNotAvailable

type DeploymentNotAvailable struct {
	// contains filtered or unexported fields
}

DeploymentNotAvailable is returned when a Kubernetes deployment is not yet available to accept traffic.

func NewDeploymentNotAvailableError

func NewDeploymentNotAvailableError(deploy *appsv1.Deployment) DeploymentNotAvailable

NewDeploymentNotAvailableError returnes a DeploymentNotAvailable struct when Kubernetes deems a deployment is not available

func (DeploymentNotAvailable) Error

func (err DeploymentNotAvailable) Error() string

Error is a simple function to return a formatted error message as a string

type DesiredNumberOfPodsNotCreated

type DesiredNumberOfPodsNotCreated struct {
	Filter       metav1.ListOptions
	DesiredCount int
}

DesiredNumberOfPodsNotCreated is returned when the number of pods matching a filter condition does not match the desired number of Pods.

func (DesiredNumberOfPodsNotCreated) Error

Error is a simple function to return a formatted error message as a string

type IngressNotAvailable

type IngressNotAvailable struct {
	// contains filtered or unexported fields
}

IngressNotAvailable is returned when a Kubernetes service is not yet available to accept traffic.

func (IngressNotAvailable) Error

func (err IngressNotAvailable) Error() string

Error is a simple function to return a formatted error message as a string

type IngressNotAvailableV1Beta1

type IngressNotAvailableV1Beta1 struct {
	// contains filtered or unexported fields
}

IngressNotAvailableV1Beta1 is returned when a Kubernetes service is not yet available to accept traffic.

func (IngressNotAvailableV1Beta1) Error

func (err IngressNotAvailableV1Beta1) Error() string

Error is a simple function to return a formatted error message as a string

type JSONPathExtractJSONPathErr

type JSONPathExtractJSONPathErr struct {
	// contains filtered or unexported fields
}

JSONPathExtractJSONPathErr is returned when the jsonpath unmarshal routine fails to extract the given JSON path from the JSON blob.

func (JSONPathExtractJSONPathErr) Error

func (err JSONPathExtractJSONPathErr) Error() string

type JSONPathMalformedJSONErr

type JSONPathMalformedJSONErr struct {
	// contains filtered or unexported fields
}

JSONPathMalformedJSONErr is returned when the jsonpath unmarshal routine fails to parse the given JSON blob.

func (JSONPathMalformedJSONErr) Error

func (err JSONPathMalformedJSONErr) Error() string

type JSONPathMalformedJSONPathErr

type JSONPathMalformedJSONPathErr struct {
	// contains filtered or unexported fields
}

JSONPathMalformedJSONPathErr is returned when the jsonpath unmarshal routine fails to parse the given JSON path string.

func (JSONPathMalformedJSONPathErr) Error

type JSONPathMalformedJSONPathResultErr

type JSONPathMalformedJSONPathResultErr struct {
	// contains filtered or unexported fields
}

JSONPathMalformedJSONPathResultErr is returned when the jsonpath unmarshal routine fails to unmarshal the resulting data from extraction.

func (JSONPathMalformedJSONPathResultErr) Error

type JobNotSucceeded

type JobNotSucceeded struct {
	// contains filtered or unexported fields
}

JobNotSucceeded is returned when a Kubernetes job is not Succeeded

func NewJobNotSucceeded

func NewJobNotSucceeded(job *batchv1.Job) JobNotSucceeded

NewJobNotSucceeded returnes a JobNotSucceeded when the status of the job is not Succeeded

func (JobNotSucceeded) Error

func (err JobNotSucceeded) Error() string

Error is a simple function to return a formatted error message as a string

type KubeResourceType

type KubeResourceType int

KubeResourceType is an enum representing known resource types that can support port forwarding

const (
	// ResourceTypePod is a k8s pod kind identifier
	ResourceTypePod KubeResourceType = iota
	// ResourceTypeDeployment is a k8s deployment kind identifier
	ResourceTypeDeployment
	// ResourceTypeService is a k8s service kind identifier
	ResourceTypeService
)

func (KubeResourceType) String

func (resourceType KubeResourceType) String() string

type KubectlOptions

type KubectlOptions struct {
	ContextName   string
	ConfigPath    string
	Namespace     string
	Env           map[string]string
	InClusterAuth bool
}

KubectlOptions represents common options necessary to specify for all Kubectl calls

func NewKubectlOptions

func NewKubectlOptions(contextName string, configPath string, namespace string) *KubectlOptions

NewKubectlOptions will return a pointer to new instance of KubectlOptions with the configured options

func NewKubectlOptionsWithInClusterAuth

func NewKubectlOptionsWithInClusterAuth() *KubectlOptions

NewKubectlOptionsWithInClusterAuth will return a pointer to a new instance of KubectlOptions with the InClusterAuth field set to true

func (*KubectlOptions) GetConfigPath

func (kubectlOptions *KubectlOptions) GetConfigPath(t testing.TestingT) (string, error)

GetConfigPath will return a sensible default if the config path is not set on the options.

type MalformedNodeID

type MalformedNodeID struct {
	// contains filtered or unexported fields
}

MalformedNodeID is returned when a Kubernetes node has a malformed node id scheme

func NewMalformedNodeIDError

func NewMalformedNodeIDError(node *corev1.Node) MalformedNodeID

NewMalformedNodeIDError returns a MalformedNodeID struct when Kubernetes deems that a NodeID is malformed

func (MalformedNodeID) Error

func (err MalformedNodeID) Error() string

Error is a simple function to return a formatted error message as a string

type NoNodesInKubernetes

type NoNodesInKubernetes struct{}

NoNodesInKubernetes is returned when the Kubernetes cluster has no nodes registered.

func NewNoNodesInKubernetesError

func NewNoNodesInKubernetesError() NoNodesInKubernetes

NewNoNodesInKubernetesError returns a NoNodesInKubernetes struct when it is deemed that there are no Kubernetes nodes registered

func (NoNodesInKubernetes) Error

func (err NoNodesInKubernetes) Error() string

Error is a simple function to return a formatted error message as a string

type NodeHasNoHostname

type NodeHasNoHostname struct {
	// contains filtered or unexported fields
}

NodeHasNoHostname is returned when a Kubernetes node has no discernible hostname

func NewNodeHasNoHostnameError

func NewNodeHasNoHostnameError(node *corev1.Node) NodeHasNoHostname

NewNodeHasNoHostnameError returns a NodeHasNoHostname struct when it is deemed that the provided node has no hostname

func (NodeHasNoHostname) Error

func (err NodeHasNoHostname) Error() string

Error is a simple function to return a formatted error message as a string

type PersistentVolumeClaimNotInStatus

type PersistentVolumeClaimNotInStatus struct {
	// contains filtered or unexported fields
}

PersistentVolumeClaimNotInStatus is returned when a Kubernetes PersistentVolumeClaim is not in the expected status phase

func NewPersistentVolumeClaimNotInStatusError

func NewPersistentVolumeClaimNotInStatusError(pvc *corev1.PersistentVolumeClaim, pvcStatusPhase *corev1.PersistentVolumeClaimPhase) PersistentVolumeClaimNotInStatus

NewPersistentVolumeClaimNotInStatusError returns a PersistentVolumeClaimNotInStatus struct when the given PersistentVolumeClaim is not in the expected status phase

func (PersistentVolumeClaimNotInStatus) Error

Error is a simple function to return a formatted error message as a string

type PersistentVolumeNotInStatus

type PersistentVolumeNotInStatus struct {
	// contains filtered or unexported fields
}

PersistentVolumeNotInStatus is returned when a Kubernetes PersistentVolume is not in the expected status phase

func NewPersistentVolumeNotInStatusError

func NewPersistentVolumeNotInStatusError(pv *corev1.PersistentVolume, pvStatusPhase *corev1.PersistentVolumePhase) PersistentVolumeNotInStatus

NewPersistentVolumeNotInStatusError returns a PersistentVolumeNotInStatus struct when the given Persistent Volume is not in the expected status phase

func (PersistentVolumeNotInStatus) Error

func (err PersistentVolumeNotInStatus) Error() string

Error is a simple function to return a formatted error message as a string

type PodNotAvailable

type PodNotAvailable struct {
	// contains filtered or unexported fields
}

PodNotAvailable is returned when a Kubernetes service is not yet available to accept traffic.

func NewPodNotAvailableError

func NewPodNotAvailableError(pod *corev1.Pod) PodNotAvailable

NewPodNotAvailableError returnes a PodNotAvailable struct when Kubernetes deems a pod is not available

func (PodNotAvailable) Error

func (err PodNotAvailable) Error() string

Error is a simple function to return a formatted error message as a string

type ServiceAccountTokenNotAvailable

type ServiceAccountTokenNotAvailable struct {
	Name string
}

ServiceAccountTokenNotAvailable is returned when a Kubernetes ServiceAccount does not have a token provisioned yet.

func (ServiceAccountTokenNotAvailable) Error

Error is a simple function to return a formatted error message as a string

type ServiceNotAvailable

type ServiceNotAvailable struct {
	// contains filtered or unexported fields
}

ServiceNotAvailable is returned when a Kubernetes service is not yet available to accept traffic.

func NewServiceNotAvailableError

func NewServiceNotAvailableError(service *corev1.Service) ServiceNotAvailable

NewServiceNotAvailableError returnes a ServiceNotAvailable struct when Kubernetes deems a service is not available

func (ServiceNotAvailable) Error

func (err ServiceNotAvailable) Error() string

Error is a simple function to return a formatted error message as a string

type Tunnel

type Tunnel struct {
	// contains filtered or unexported fields
}

Tunnel is the main struct that configures and manages port forwading tunnels to Kubernetes resources.

func NewTunnel

func NewTunnel(kubectlOptions *KubectlOptions, resourceType KubeResourceType, resourceName string, local int, remote int) *Tunnel

NewTunnel creates a new tunnel with NewTunnelWithLogger, setting logger.Terratest as the logger.

func NewTunnelWithLogger

func NewTunnelWithLogger(
	kubectlOptions *KubectlOptions,
	resourceType KubeResourceType,
	resourceName string,
	local int,
	remote int,
	logger logger.TestLogger,
) *Tunnel

NewTunnelWithLogger will create a new Tunnel struct with the provided logger. Note that if you use 0 for the local port, an open port on the host system will be selected automatically, and the Tunnel struct will be updated with the selected port.

func (*Tunnel) Close

func (tunnel *Tunnel) Close()

Close disconnects a tunnel connection by closing the StopChan, thereby stopping the goroutine.

func (*Tunnel) Endpoint

func (tunnel *Tunnel) Endpoint() string

Endpoint returns the tunnel endpoint

func (*Tunnel) ForwardPort

func (tunnel *Tunnel) ForwardPort(t testing.TestingT)

ForwardPort opens a tunnel to a kubernetes resource, as specified by the provided tunnel struct. This will fail the test if there is an error attempting to open the port.

func (*Tunnel) ForwardPortE

func (tunnel *Tunnel) ForwardPortE(t testing.TestingT) error

ForwardPortE opens a tunnel to a kubernetes resource, as specified by the provided tunnel struct.

type UnknownKubeResourceType

type UnknownKubeResourceType struct {
	ResourceType KubeResourceType
}

UnknownKubeResourceType is returned if the given resource type does not match the list of known resource types.

func (UnknownKubeResourceType) Error

func (err UnknownKubeResourceType) Error() string

type UnknownServicePort

type UnknownServicePort struct {
	// contains filtered or unexported fields
}

UnknownServicePort is returned when the given service port is not an exported port of the service.

func NewUnknownServicePortError

func NewUnknownServicePortError(service *corev1.Service, port int32) UnknownServicePort

NewUnknownServicePortError returns an UnknownServicePort struct when it is deemed that Kuberenetes does not know of the provided Service Port

func (UnknownServicePort) Error

func (err UnknownServicePort) Error() string

Error is a simple function to return a formatted error message as a string

type UnknownServiceType

type UnknownServiceType struct {
	// contains filtered or unexported fields
}

UnknownServiceType is returned when a Kubernetes service has a type that is not yet handled by the test functions.

func NewUnknownServiceTypeError

func NewUnknownServiceTypeError(service *corev1.Service) UnknownServiceType

NewUnknownServiceTypeError returns an UnknownServiceType struct when is it deemed that Kubernetes does not know the service type provided

func (UnknownServiceType) Error

func (err UnknownServiceType) Error() string

Error is a simple function to return a formatted error message as a string

Jump to

Keyboard shortcuts

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