Version: v1.2.6 Latest Latest

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

Go to latest
Published: Aug 31, 2020 License: Apache-2.0 Imports: 38 Imported by: 0




View Source
const (
	DeploymentKind       = "Deployment"
	DeploymentAPIVersion = "apps/v1"

constants for deployments

View Source
const (
	// OdoSourceVolume is the constant containing the name of the emptyDir volume containing the project source
	OdoSourceVolume = "odo-projects"

	// OdoSourceVolumeMount is the directory to mount the volume in the container
	OdoSourceVolumeMount = "/projects"
View Source
const (
	PersistentVolumeClaimKind       = "PersistentVolumeClaim"
	PersistentVolumeClaimAPIVersion = "v1"

constants for volumes


View Source
var (
	ErrNoSuchOperator = errors.New("Could not find specified operator")


func AddBootstrapSupervisordInitContainer added in v1.1.2

func AddBootstrapSupervisordInitContainer(podTemplateSpec *corev1.PodTemplateSpec)

AddBootstrapSupervisordInitContainer creates an init container that will copy over supervisord to the application image during the start-up procress.

func AddPVCAndVolumeMount added in v1.1.1

func AddPVCAndVolumeMount(podTemplateSpec *corev1.PodTemplateSpec, volumeNameToPVCName map[string]string, containerNameToVolumes map[string][]common.DevfileVolume) error

AddPVCAndVolumeMount adds PVC and volume mount to the pod template spec volumeNameToPVCName is a map of volume name to the PVC created containerNameToVolumes is a map of the Devfile container names to the Devfile Volumes

func AddPVCToPodTemplateSpec added in v1.1.1

func AddPVCToPodTemplateSpec(podTemplateSpec *corev1.PodTemplateSpec, volumeName, pvcName string)

AddPVCToPodTemplateSpec adds the given PVC to the podTemplateSpec

func AddVolumeMountToPodTemplateSpec added in v1.1.1

func AddVolumeMountToPodTemplateSpec(podTemplateSpec *corev1.PodTemplateSpec, volumeName string, containerNameToMountPaths map[string][]string) error

AddVolumeMountToPodTemplateSpec adds the Volume Mounts in containerNameToMountPaths to the podTemplateSpec containers for a given pvc and volumeName containerNameToMountPaths is a map of a container name to an array of its Mount Paths

func CreateObjectMeta added in v1.1.1

func CreateObjectMeta(name, namespace string, labels, annotations map[string]string) metav1.ObjectMeta

CreateObjectMeta creates a common object meta

func FakeNew

func FakeNew() (*Client, *FakeClientset)

FakeNew creates new fake client for testing returns Client that is filled with fake clients and FakeClientSet that holds fake Clientsets to access Actions, Reactors etc... in fake client

func FakePodStatus added in v1.1.1

func FakePodStatus(status corev1.PodPhase, podName string) *corev1.Pod

FakePodStatus returns a pod with the status

func GenerateContainer added in v1.1.1

func GenerateContainer(name, image string, isPrivileged bool, command, args []string, envVars []corev1.EnvVar, resourceReqs corev1.ResourceRequirements, ports []corev1.ContainerPort) *corev1.Container

GenerateContainer creates a container spec that can be used when creating a pod

func GenerateDeploymentSpec added in v1.1.1

func GenerateDeploymentSpec(podTemplateSpec corev1.PodTemplateSpec, podSelectorLabels map[string]string) *appsv1.DeploymentSpec

GenerateDeploymentSpec creates a deployment spec

func GenerateIngressSpec added in v1.1.1

func GenerateIngressSpec(ingressParam IngressParameter) *extensionsv1.IngressSpec

GenerateIngressSpec creates an ingress spec

func GenerateOwnerReference added in v1.1.1

func GenerateOwnerReference(deployment *appsv1.Deployment) metav1.OwnerReference

GenerateOwnerReference genertes an ownerReference from the deployment which can then be set as owner for various Kubernetes objects and ensure that when the owner object is deleted from the cluster, all other objects are automatically removed by Kubernetes garbage collector

func GeneratePVCSpec added in v1.1.1

func GeneratePVCSpec(quantity resource.Quantity) *corev1.PersistentVolumeClaimSpec

GeneratePVCSpec creates a pvc spec

func GeneratePodTemplateSpec added in v1.1.1

func GeneratePodTemplateSpec(objectMeta metav1.ObjectMeta, containers []corev1.Container) *corev1.PodTemplateSpec

GeneratePodTemplateSpec creates a pod template spec that can be used to create a deployment spec

func GenerateServiceSpec added in v1.1.2

func GenerateServiceSpec(componentName string, containerPorts []corev1.ContainerPort) *corev1.ServiceSpec

GenerateServiceSpec creates a service spec


type Client

type Client struct {
	KubeClient       kubernetes.Interface
	KubeConfig       clientcmd.ClientConfig
	KubeClientConfig *rest.Config
	Namespace        string
	OperatorClient   *operatorsclientset.OperatorsV1alpha1Client
	// DynamicClient interacts with client-go's `dynamic` package. It is used
	// to dynamically create service from an operator. It can take an arbitrary
	// yaml and create k8s/OpenShift resource from it.
	DynamicClient dynamic.Interface

Client is a collection of fields used for client configuration and interaction

func New

func New() (*Client, error)

New creates a new client

func (*Client) CreateDeployment added in v1.1.1

func (c *Client) CreateDeployment(deploymentSpec appsv1.DeploymentSpec) (*appsv1.Deployment, error)

CreateDeployment creates a deployment based on the given deployment spec

func (*Client) CreateDynamicResource added in v1.1.3

func (c *Client) CreateDynamicResource(exampleCustomResource map[string]interface{}, group, version, resource string) error

CreateDynamicResource creates a dynamic custom resource

func (*Client) CreateIngress added in v1.1.1

func (c *Client) CreateIngress(objectMeta metav1.ObjectMeta, spec extensionsv1.IngressSpec) (*extensionsv1.Ingress, error)

CreateIngress creates an ingress object for the given service and with the given labels

func (*Client) CreateNamespace added in v1.2.6

func (c *Client) CreateNamespace(name string) (*corev1.Namespace, error)

CreateNamespace creates new namespace

func (*Client) CreatePVC added in v1.1.1

CreatePVC creates a PVC resource in the cluster with the given name, size and labels

func (*Client) CreateService added in v1.1.2

func (c *Client) CreateService(commonObjectMeta metav1.ObjectMeta, svcSpec corev1.ServiceSpec) (*corev1.Service, error)

CreateService generates and creates the service commonObjectMeta is the ObjectMeta for the service

func (*Client) CreateTLSSecret added in v1.1.1

func (c *Client) CreateTLSSecret(tlsCertificate []byte, tlsPrivKey []byte, objectMeta metav1.ObjectMeta) (*corev1.Secret, error)

CreateTLSSecret creates a TLS Secret with the given certificate and private key serviceName is the name of the service for the target reference ingressDomain is the ingress domain to use for the ingress

func (*Client) DeleteDeployment added in v1.1.2

func (c *Client) DeleteDeployment(labels map[string]string) error

DeleteDeployment deletes the deployments with the given selector

func (*Client) DeleteDynamicResource added in v1.2.4

func (c *Client) DeleteDynamicResource(name, group, version, resource string) error

DeleteDynamicResource deletes an instance, specified by name, of a Custom Resource

func (*Client) DeleteIngress added in v1.1.1

func (c *Client) DeleteIngress(name string) error

DeleteIngress deletes the given ingress

func (*Client) DeleteNamespace added in v1.2.6

func (c *Client) DeleteNamespace(name string, wait bool) error

DeleteNamespace deletes namespace if wait=true , it will wait for deletion

func (*Client) DeletePVC added in v1.2.6

func (c *Client) DeletePVC(pvcName string) error

DeletePVC deletes the required PVC resource from the cluster

func (*Client) ExecCMDInContainer

func (c *Client) ExecCMDInContainer(compInfo common.ComponentInfo, cmd []string, stdout io.Writer, stderr io.Writer, stdin io.Reader, tty bool) error

ExecCMDInContainer execute command in the container of a pod, pass an empty string for containerName to execute in the first container of the pod

func (*Client) ExtractProjectToComponent added in v1.2.0

func (c *Client) ExtractProjectToComponent(compInfo common.ComponentInfo, targetPath string, stdin io.Reader) error

ExtractProjectToComponent extracts the project archive(tar) to the target path from the reader stdin

func (*Client) GeneratePortForwardReq added in v1.2.3

func (c *Client) GeneratePortForwardReq(podName string) *rest.Request

GeneratePortForwardReq builds a port forward request

func (*Client) GetCSVWithCR added in v1.2.4

func (c *Client) GetCSVWithCR(name string) (*olm.ClusterServiceVersion, error)

GetCSVWithCR returns the CSV (Operator) that contains the CR (service)

func (*Client) GetClusterServiceVersion added in v1.1.3

func (c *Client) GetClusterServiceVersion(name string) (olm.ClusterServiceVersion, error)

GetClusterServiceVersion returns a particular CSV from a list of CSVs

func (*Client) GetClusterServiceVersionList added in v1.1.1

func (c *Client) GetClusterServiceVersionList() (*olm.ClusterServiceVersionList, error)

GetClusterServiceVersionList returns a list of CSVs in the cluster It is equivalent to doing `oc get csvs` using oc cli

func (*Client) GetCurrentNamespace added in v1.2.6

func (c *Client) GetCurrentNamespace() string

func (*Client) GetCustomResource added in v1.2.5

func (c *Client) GetCustomResource(customResource string) (*olm.CRDDescription, error)

GetCustomResource returns the CR matching the name

func (*Client) GetCustomResourcesFromCSV added in v1.2.1

func (c *Client) GetCustomResourcesFromCSV(csv *olm.ClusterServiceVersion) *[]olm.CRDDescription

GetCustomResourcesFromCSV returns a list of CRs provided by an operator/CSV.

func (*Client) GetDeploymentByName added in v1.1.1

func (c *Client) GetDeploymentByName(name string) (*appsv1.Deployment, error)

GetDeploymentByName gets a deployment by querying by name

func (*Client) GetIngress added in v1.1.2

func (c *Client) GetIngress(name string) (*extensionsv1.Ingress, error)

GetIngress gets an ingress based on the given name

func (*Client) GetNamespace added in v1.2.6

func (c *Client) GetNamespace(name string) (*corev1.Namespace, error)

GetNamespace returns Namespace based on its name Errors related to project not being found or forbidden are translated to nil project for compatibility

func (*Client) GetNamespaces added in v1.2.6

func (c *Client) GetNamespaces() ([]string, error)

GetNamespaces return list of existing namespaces that user has access to.

func (*Client) GetOnePodFromSelector added in v1.2.3

func (c *Client) GetOnePodFromSelector(selector string) (*corev1.Pod, error)

GetOnePodFromSelector gets a pod from the selector

func (*Client) GetPVCsFromSelector added in v1.1.1

func (c *Client) GetPVCsFromSelector(selector string) ([]corev1.PersistentVolumeClaim, error)

GetPVCsFromSelector returns the PVCs based on the given selector

func (*Client) GetPodLogs added in v1.2.4

func (c *Client) GetPodLogs(podName, containerName string, followLog bool) (io.ReadCloser, error)

GetPodLogs prints the log from pod to stdout

func (*Client) GetPodUsingComponentName added in v1.2.3

func (c *Client) GetPodUsingComponentName(componentName string) (*corev1.Pod, error)

GetPodUsingComponentName gets a pod using the component name

func (*Client) ListDeployments added in v1.2.4

func (c *Client) ListDeployments(selector string) (*appsv1.DeploymentList, error)

ListDeployments lists all deployments by selector

func (*Client) ListDynamicResource added in v1.2.1

func (c *Client) ListDynamicResource(group, version, resource string) (*unstructured.UnstructuredList, error)

ListDynamicResource returns an unstructured list of instances of a Custom Resource currently deployed in the active namespace of the cluster

func (*Client) ListIngresses added in v1.1.1

func (c *Client) ListIngresses(labelSelector string) ([]extensionsv1.Ingress, error)

ListIngresses lists all the ingresses based on the given label selector

func (*Client) SearchClusterServiceVersionList added in v1.2.4

func (c *Client) SearchClusterServiceVersionList(name string) (*olm.ClusterServiceVersionList, error)

SearchClusterServiceVersionList searches for whether the operator/CSV contains given keyword then return it

func (*Client) SetCurrentNamespace added in v1.2.6

func (c *Client) SetCurrentNamespace(namespace string) error

SetCurrentNamespace change current namespace in kubeconfig

func (*Client) UpdateDeployment added in v1.1.1

func (c *Client) UpdateDeployment(deploymentSpec appsv1.DeploymentSpec) (*appsv1.Deployment, error)

UpdateDeployment updates a deployment based on the given deployment spec

func (*Client) UpdateService added in v1.1.2

func (c *Client) UpdateService(commonObjectMeta metav1.ObjectMeta, svcSpec corev1.ServiceSpec) (*corev1.Service, error)

UpdateService updates a service based on the given servcie spec

func (*Client) WaitAndGetPod

func (c *Client) WaitAndGetPod(watchOptions metav1.ListOptions, desiredPhase corev1.PodPhase, waitMessage string, hideSpinner bool) (*corev1.Pod, error)

WaitAndGetPod block and waits until pod matching selector is in the desired phase desiredPhase cannot be PodFailed or PodUnknown

func (*Client) WaitForDeploymentRollout added in v1.1.2

func (c *Client) WaitForDeploymentRollout(deploymentName string) (*appsv1.Deployment, error)

WaitForDeploymentRollout waits for deployment to finish rollout. Returns the state of the deployment after rollout.

func (*Client) WaitForServiceAccountInNamespace added in v1.2.6

func (c *Client) WaitForServiceAccountInNamespace(namespace, serviceAccountName string) error

WaitForServiceAccountInNamespace waits for the given service account to be ready

type FakeClientset

type FakeClientset struct {
	Kubernetes *fakeKubeClientset.Clientset

FakeClientset holds fake ClientSets this is returned by FakeNew to access methods of fake client sets

type IngressParameter added in v1.1.1

type IngressParameter struct {
	ServiceName   string
	IngressDomain string
	PortNumber    intstr.IntOrString
	TLSSecretName string
	Path          string

IngressParameter struct for function createIngress serviceName is the name of the service for the target reference ingressDomain is the ingress domain to use for the ingress portNumber is the target port of the ingress TLSSecretName is the target TLS Secret name of the ingress

type PodNotFoundError added in v1.2.6

type PodNotFoundError struct {
	Selector string

PodNotFoundError returns an error if no pod is found with the selector

func (*PodNotFoundError) Error added in v1.2.6

func (e *PodNotFoundError) Error() string

type SelfSignedCertificate added in v1.1.2

type SelfSignedCertificate struct {
	CertPem []byte
	KeyPem  []byte

SelfSignedCertificate struct is the return type of function GenerateSelfSignedCertificate CertPem is the byte array for certificate pem encode KeyPem is the byte array for key pem encode

func GenerateSelfSignedCertificate added in v1.1.2

func GenerateSelfSignedCertificate(host string) (SelfSignedCertificate, error)

GenerateSelfSignedCertificate creates a self-signed SSl certificate


Path Synopsis

Jump to

Keyboard shortcuts

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