occlient

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2020 License: Apache-2.0 Imports: 64 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OcUpdateTimeout    = 5 * time.Minute
	OpenShiftNameSpace = "openshift"

	// ComponentPortAnnotationName annotation is used on the secrets that are created for each exposed port of the component
	ComponentPortAnnotationName = "component-port"

	// EnvS2IScriptsURL is an env var exposed to https://github.com/openshift/odo-init-image/blob/master/assemble-and-restart to indicate location of s2i scripts in this case assemble script
	EnvS2IScriptsURL = "ODO_S2I_SCRIPTS_URL"

	// EnvS2IScriptsProtocol is an env var exposed to https://github.com/openshift/odo-init-image/blob/master/assemble-and-restart to indicate the way to access location of s2i scripts indicated by ${${EnvS2IScriptsURL}} above
	EnvS2IScriptsProtocol = "ODO_S2I_SCRIPTS_PROTOCOL"

	// EnvS2ISrcOrBinPath is an env var exposed by s2i to indicate where the builder image expects the component source or binary to reside
	EnvS2ISrcOrBinPath = "ODO_S2I_SRC_BIN_PATH"

	// EnvS2ISrcBackupDir is the env var that points to the directory that holds a backup of component source
	// This is required bcoz, s2i assemble script moves(hence deletes contents) the contents of $ODO_S2I_SRC_BIN_PATH to $APP_ROOT during which $APP_DIR alo needs to be empty so that mv doesn't complain pushing to an already exisiting dir with same name
	EnvS2ISrcBackupDir = "ODO_SRC_BACKUP_DIR"

	// S2IScriptsURLLabel S2I script location Label name
	// Ref: https://docs.openshift.com/enterprise/3.2/creating_images/s2i.html#build-process
	S2IScriptsURLLabel = "io.openshift.s2i.scripts-url"

	// S2IBuilderImageName is the S2I builder image name
	S2IBuilderImageName = "name"

	// S2ISrcOrBinLabel is the label that provides, path where S2I expects component source or binary
	S2ISrcOrBinLabel = "io.openshift.s2i.destination"

	// EnvS2IBuilderImageName is the label that provides the name of builder image in component
	EnvS2IBuilderImageName = "ODO_S2I_BUILDER_IMG"

	// EnvS2IDeploymentDir is an env var exposed to https://github.com/openshift/odo-init-image/blob/master/assemble-and-restart to indicate s2i deployment directory
	EnvS2IDeploymentDir = "ODO_S2I_DEPLOYMENT_DIR"

	// DefaultS2ISrcOrBinPath is the default path where S2I expects source/binary artifacts in absence of $S2ISrcOrBinLabel in builder image
	// Ref: https://github.com/openshift/source-to-image/blob/master/docs/builder_image.md#required-image-contents
	DefaultS2ISrcOrBinPath = "/tmp"

	// DefaultS2ISrcBackupDir is the default path where odo backs up the component source
	DefaultS2ISrcBackupDir = "/opt/app-root/src-backup"

	// EnvS2IWorkingDir is an env var to odo-init-image assemble-and-restart.sh to indicate to it the s2i working directory
	EnvS2IWorkingDir = "ODO_S2I_WORKING_DIR"

	DefaultAppRootDir = "/opt/app-root"
)

Variables

View Source
var (
	DEPLOYMENT_CONFIG_NOT_FOUND_ERROR_STR string = "deploymentconfigs.apps.openshift.io \"%s\" not found"
	DEPLOYMENT_CONFIG_NOT_FOUND           error  = fmt.Errorf("Requested deployment config does not exist")
)
View Source
var S2IDeploymentsDir = []string{
	"com.redhat.deployments-dir",
	"org.jboss.deployments-dir",
	"org.jboss.container.deployments-dir",
}

S2IDeploymentsDir is a set of possible S2I labels that provides S2I deployments directory This label is not uniform across different builder images. This slice is expected to grow as odo adds support to more component types and/or the respective builder images use different labels

Functions

func FakeNew added in v0.0.6

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 FetchContainerResourceLimits added in v1.0.0

func FetchContainerResourceLimits(container corev1.Container) corev1.ResourceRequirements

FetchContainerResourceLimits returns cpu and memory resource limits of the component container from the passed dc Parameter:

container: Component container

Returns:

resource limits from passed component container

func FindContainer added in v1.0.0

func FindContainer(containers []corev1.Container, name string) (corev1.Container, error)

FindContainer finds the container

func GenerateOwnerReference added in v1.2.1

func GenerateOwnerReference(dc *appsv1.DeploymentConfig) metav1.OwnerReference

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

func GetInputEnvVarsFromStrings added in v1.0.0

func GetInputEnvVarsFromStrings(envVars []string) ([]corev1.EnvVar, error)

GetInputEnvVarsFromStrings generates corev1.EnvVar values from the array of string key=value pairs envVars is the array containing the key=value pairs

func GetResourceRequirementsFromCmpSettings added in v1.0.0

func GetResourceRequirementsFromCmpSettings(cfg config.LocalConfigInfo) (*corev1.ResourceRequirements, error)

GetResourceRequirementsFromCmpSettings converts the cpu and memory request info from component configuration into format usable in dc Parameters:

cfg: Compoennt configuration/settings

Returns:

*corev1.ResourceRequirements: component configuration converted into format usable in dc

func HasTag added in v1.0.0

func HasTag(tags []string, requiredTag string) bool

HasTag checks to see if there is a tag in a list of over tags..

func IsDCRolledOut added in v1.0.0

func IsDCRolledOut(config *appsv1.DeploymentConfig, desiredRevision int64) bool

IsDCRolledOut indicates whether the deployment config is rolled out or not Borrowed from https://github.com/openshift/origin/blob/64349ed036ed14808124c5b4d8538b3856783b54/pkg/oc/originpolymorphichelpers/deploymentconfigs/status.go

func ParseImageName added in v0.0.9

func ParseImageName(image string) (string, string, string, string, error)

ParseImageName parse image reference returns (imageNamespace, imageName, tag, digest, error) if image is referenced by tag (name:tag) than digest is "" if image is referenced by digest (name@digest) than tag is ""

Types

type Client added in v0.0.3

type Client struct {
	KubeConfig clientcmd.ClientConfig

	Namespace string
	// contains filtered or unexported fields
}

func New added in v0.0.3

func New() (*Client, error)

New creates a new client

func (*Client) AddEnvironmentVariablesToDeploymentConfig added in v0.0.4

func (c *Client) AddEnvironmentVariablesToDeploymentConfig(envs []corev1.EnvVar, dc *appsv1.DeploymentConfig) error

AddEnvironmentVariablesToDeploymentConfig adds the given environment variables to the only container in the Deployment Config and updates in the cluster

func (*Client) AddPVCToDeploymentConfig added in v0.0.4

func (c *Client) AddPVCToDeploymentConfig(dc *appsv1.DeploymentConfig, pvc string, path string) error

AddPVCToDeploymentConfig adds the given PVC to the given Deployment Config at the given path

func (*Client) BootstrapSupervisoredS2I added in v0.0.5

func (c *Client) BootstrapSupervisoredS2I(params CreateArgs, commonObjectMeta metav1.ObjectMeta) error

BootstrapSupervisoredS2I uses S2I (Source To Image) to inject Supervisor into the application container. Odo uses https://github.com/ochinchina/supervisord which is pre-built in a ready-to-deploy InitContainer. The supervisord binary is copied over to the application container using a temporary volume and overrides the built-in S2I run function for the supervisord run command instead.

Supervisor keeps the pod running (as PID 1), so you it is possible to trigger assembly script inside running pod, and than restart application using Supervisor without need to restart the container/Pod.

func (*Client) BuildPortForwardReq added in v1.0.0

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

BuildPortForwardReq builds a port forward request

func (*Client) CollectEvents added in v1.1.2

func (c *Client) CollectEvents(selector string, events map[string]corev1.Event, spinner *log.Status, quit <-chan int)

CollectEvents collects events in a Goroutine by manipulating a spinner. We don't care about the error (it's usually ran in a go routine), so erroring out is not needed.

func (*Client) CreateBuildConfig added in v0.0.14

func (c *Client) CreateBuildConfig(commonObjectMeta metav1.ObjectMeta, builderImage string, gitURL string, gitRef string, envVars []corev1.EnvVar) (buildv1.BuildConfig, error)

CreateBuildConfig creates a buildConfig using the builderImage as well as gitURL. envVars is the array containing the environment variables

func (*Client) CreateNewProject added in v0.0.3

func (c *Client) CreateNewProject(projectName string, wait bool) error

CreateNewProject creates project with given projectName

func (*Client) CreatePVC added in v0.0.4

func (c *Client) CreatePVC(name string, size string, labels map[string]string, ownerReference ...metav1.OwnerReference) (*corev1.PersistentVolumeClaim, error)

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

func (*Client) CreateRoute added in v0.0.3

func (c *Client) CreateRoute(name string, serviceName string, portNumber intstr.IntOrString, labels map[string]string, secureURL bool, ownerReference metav1.OwnerReference) (*routev1.Route, error)

CreateRoute creates a route object for the given service and with the given labels serviceName is the name of the service for the target reference portNumber is the target port of the route secureURL indicates if the route is a secure one or not

func (*Client) CreateSecret added in v0.0.15

func (c *Client) CreateSecret(objectMeta metav1.ObjectMeta, data map[string]string, ownerReference metav1.OwnerReference) error

CreateSecret generates and creates the secret commonObjectMeta is the ObjectMeta for the service

func (*Client) CreateService added in v0.0.9

func (c *Client) CreateService(commonObjectMeta metav1.ObjectMeta, containerPorts []corev1.ContainerPort, ownerReference metav1.OwnerReference) (*corev1.Service, error)

CreateService generates and creates the service commonObjectMeta is the ObjectMeta for the service dc is the deploymentConfig to get the container ports

func (*Client) CreateServiceBinding added in v0.0.14

func (c *Client) CreateServiceBinding(bindingName string, namespace string, labels map[string]string) error

CreateServiceBinding creates a ServiceBinding (essentially a secret) within the namespace of the service instance created using the service's parameters.

func (*Client) CreateServiceInstance added in v0.0.11

func (c *Client) CreateServiceInstance(serviceName string, serviceType string, servicePlan string, parameters map[string]string, labels map[string]string) error

CreateServiceInstance creates service instance from service catalog

func (*Client) Delete added in v0.0.3

func (c *Client) Delete(labels map[string]string, wait bool) error

Delete takes labels as a input and based on it, deletes respective resource

func (*Client) DeleteBuildConfig added in v0.0.14

func (c *Client) DeleteBuildConfig(commonObjectMeta metav1.ObjectMeta) error

DeleteBuildConfig deletes the given BuildConfig by name using CommonObjectMeta..

func (*Client) DeletePVC added in v0.0.4

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

DeletePVC deletes the given PVC by name

func (*Client) DeleteProject added in v0.0.3

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

DeleteProject deletes given project

NOTE: There is a very specific edge case that may happen during project deletion when deleting a project and then immediately creating another. Unfortunately, despite the watch interface, we cannot safely determine if the project is 100% deleted. See this link: https://stackoverflow.com/questions/48208001/deleted-openshift-online-pro-project-has-left-a-trace-so-cannot-create-project-o Will Gordon (Engineer @ Red Hat) describes the issue:

"Projects are deleted asynchronously after you send the delete command. So it's possible that the deletion just hasn't been reconciled yet. It should happen within a minute or so, so try again. Also, please be aware that in a multitenant environment, like OpenShift Online, you are prevented from creating a project with the same name as any other project in the cluster, even if it's not your own. So if you can't create the project, it's possible that someone has already created a project with the same name."

func (*Client) DeleteRoute added in v0.0.3

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

DeleteRoute deleted the given route

func (*Client) DeleteServiceInstance added in v0.0.11

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

DeleteServiceInstance takes labels as a input and based on it, deletes respective service instance

func (*Client) DisplayDeploymentConfigLog added in v0.0.6

func (c *Client) DisplayDeploymentConfigLog(deploymentConfigName string, followLog bool, stdout io.Writer) error

DisplayDeploymentConfigLog logs the deployment config to stdout

func (*Client) ExecCMDInContainer added in v0.0.5

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 specified container of a pod. If `containerName` is blank, it execs in the first container.

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) FollowBuildLog added in v0.0.3

func (c *Client) FollowBuildLog(buildName string, stdout io.Writer, buildTimeout time.Duration) error

FollowBuildLog stream build log to stdout

func (*Client) GetAllClusterServicePlans added in v0.0.14

func (c *Client) GetAllClusterServicePlans() ([]scv1beta1.ClusterServicePlan, error)

GetAllClusterServicePlans returns list of available plans

func (*Client) GetBuildConfigFromName added in v0.0.10

func (c *Client) GetBuildConfigFromName(name string) (*buildv1.BuildConfig, error)

GetBuildConfigFromName get BuildConfig by its name

func (*Client) GetClusterPlansFromServiceName added in v0.0.15

func (c *Client) GetClusterPlansFromServiceName(serviceName string) ([]scv1beta1.ClusterServicePlan, error)

GetClusterPlansFromServiceName returns the plans associated with a service class serviceName is the name (the actual id, NOT the external name) of the service class whose plans are required returns array of ClusterServicePlans or error

func (*Client) GetClusterServiceClass added in v0.0.15

func (c *Client) GetClusterServiceClass(serviceName string) (*scv1beta1.ClusterServiceClass, error)

GetClusterServiceClass returns the required service class from the service name serviceName is the name of the service returns the required service class and the error

func (*Client) GetClusterServiceClasses added in v0.0.3

func (c *Client) GetClusterServiceClasses() ([]scv1beta1.ClusterServiceClass, error)

GetClusterServiceClasses queries the service service catalog to get available clusterServiceClasses

func (*Client) GetCurrentProjectName added in v0.0.3

func (c *Client) GetCurrentProjectName() string

func (*Client) GetDeploymentConfigFromName added in v0.0.4

func (c *Client) GetDeploymentConfigFromName(name string) (*appsv1.DeploymentConfig, error)

GetDeploymentConfigFromName returns the Deployment Config resource given the Deployment Config name

func (*Client) GetDeploymentConfigLabelValues added in v1.0.0

func (c *Client) GetDeploymentConfigLabelValues(label string, selector string) ([]string, error)

GetDeploymentConfigLabelValues get label values of given label from objects in project that are matching selector returns slice of unique label values

func (*Client) GetDeploymentConfigsFromSelector added in v0.0.4

func (c *Client) GetDeploymentConfigsFromSelector(selector string) ([]appsv1.DeploymentConfig, error)

GetDeploymentConfigsFromSelector returns an array of Deployment Config resources which match the given selector

func (*Client) GetEnvVarsFromDC added in v0.0.14

func (c *Client) GetEnvVarsFromDC(dcName string) ([]corev1.EnvVar, error)

GetEnvVarsFromDC retrieves the env vars from the DC dcName is the name of the dc from which the env vars are retrieved projectName is the name of the project

func (*Client) GetExposedPorts added in v0.0.5

func (c *Client) GetExposedPorts(imageStreamImage *imagev1.ImageStreamImage) ([]corev1.ContainerPort, error)

GetExposedPorts returns list of ContainerPorts that are exposed by given image

func (*Client) GetImageStream added in v0.0.11

func (c *Client) GetImageStream(imageNS string, imageName string, imageTag string) (*imagev1.ImageStream, error)

GetImageStream returns the imagestream using image details like imageNS, imageName and imageTag imageNS can be empty in which case, this function searches currentNamespace on priority. If imagestream of required tag not found in current namespace, then searches openshift namespace. If not found, error out. If imageNS is not empty string, then, the requested imageNS only is searched for requested imagestream

func (*Client) GetImageStreamImage added in v0.0.15

func (c *Client) GetImageStreamImage(imageStream *imagev1.ImageStream, imageTag string) (*imagev1.ImageStreamImage, error)

GetImageStreamImage returns image and error if any, corresponding to the passed imagestream and image tag

func (*Client) GetImageStreamTags added in v0.0.19

func (c *Client) GetImageStreamTags(namespace string) ([]imagev1.ImageStreamTag, error)

GetImageStreamTags returns all the ImageStreamTag objects in the given namespace

func (*Client) GetImageStreams added in v0.0.3

func (c *Client) GetImageStreams(namespace string) ([]imagev1.ImageStream, error)

GetImageStreams returns the Image Stream objects in the given namespace

func (*Client) GetImageStreamsNames added in v0.0.3

func (c *Client) GetImageStreamsNames(namespace string) ([]string, error)

GetImageStreamsNames returns the names of the image streams in a given namespace

func (*Client) GetLatestBuildName added in v0.0.4

func (c *Client) GetLatestBuildName(buildConfigName string) (string, error)

GetLatestBuildName gets the name of the latest build buildConfigName is the name of the buildConfig for which we are fetching the build name returns the name of the latest build or the error

func (*Client) GetMatchingPlans added in v0.0.18

func (c *Client) GetMatchingPlans(class scv1beta1.ClusterServiceClass) (plans map[string]scv1beta1.ClusterServicePlan, err error)

GetMatchingPlans retrieves a map associating service plan name to service plan instance associated with the specified service class

func (*Client) GetOneDeploymentConfigFromSelector added in v0.0.4

func (c *Client) GetOneDeploymentConfigFromSelector(selector string) (*appsv1.DeploymentConfig, error)

GetOneDeploymentConfigFromSelector returns the Deployment Config object associated with the given selector. An error is thrown when exactly one Deployment Config is not found for the selector.

func (*Client) GetOnePodFromSelector added in v0.0.4

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

GetOnePodFromSelector returns the Pod object associated with the given selector. An error is thrown when exactly one Pod is not found.

func (*Client) GetOneServiceFromSelector added in v0.0.4

func (c *Client) GetOneServiceFromSelector(selector string) (*corev1.Service, error)

GetOneServiceFromSelector returns the Service object associated with the given selector. An error is thrown when exactly one Service is not found for the selector

func (*Client) GetPVCFromName added in v0.0.6

func (c *Client) GetPVCFromName(pvcName string) (*corev1.PersistentVolumeClaim, error)

GetPVCFromName returns the PVC of the given name

func (*Client) GetPVCNameFromVolumeMountName added in v0.0.6

func (c *Client) GetPVCNameFromVolumeMountName(volumeMountName string, dc *appsv1.DeploymentConfig) string

GetPVCNameFromVolumeMountName returns the PVC associated with the given volume An empty string is returned if the volume is not found

func (*Client) GetPVCNamesFromSelector added in v0.0.4

func (c *Client) GetPVCNamesFromSelector(selector string) ([]string, error)

GetPVCNamesFromSelector returns the PVC names for the given selector

func (*Client) GetPVCsFromSelector added in v0.0.4

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

GetPVCsFromSelector returns the PVCs based on the given selector

func (*Client) GetPodUsingComponentName added in v1.2.3

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

func (*Client) GetPortsFromBuilderImage added in v1.0.0

func (c *Client) GetPortsFromBuilderImage(componentType string) ([]string, error)

GetPortsFromBuilderImage returns list of available port from given builder image of given component type

func (*Client) GetProject added in v1.0.0

func (c *Client) GetProject(projectName string) (*projectv1.Project, error)

GetProject returns project based on the name of the project.Errors related to project not being found or forbidden are translated to nil project for compatibility

func (*Client) GetProjectNames added in v0.0.4

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

GetProjectNames return list of existing projects that user has access to.

func (*Client) GetRoute added in v1.1.2

func (c *Client) GetRoute(name string) (*routev1.Route, error)

func (*Client) GetSecret added in v0.0.14

func (c *Client) GetSecret(name, namespace string) (*corev1.Secret, error)

GetSecret returns the Secret object in the given namespace

func (*Client) GetServerVersion added in v0.0.5

func (c *Client) GetServerVersion() (*ServerInfo, error)

GetServerVersion will fetch the Server Host, OpenShift and Kubernetes Version It will be shown on the execution of odo version command

func (*Client) GetServiceBinding added in v0.0.15

func (c *Client) GetServiceBinding(serviceName string, namespace string) (*scv1beta1.ServiceBinding, error)

GetServiceBinding returns the ServiceBinding named serviceName in the namespace namespace

func (*Client) GetServiceClassesByCategory added in v0.0.18

func (c *Client) GetServiceClassesByCategory() (categories map[string][]scv1beta1.ClusterServiceClass, err error)

GetServiceClassesByCategory retrieves a map associating category name to ClusterServiceClasses matching the category

func (*Client) GetServiceInstanceLabelValues added in v1.0.0

func (c *Client) GetServiceInstanceLabelValues(label string, selector string) ([]string, error)

GetServiceInstanceLabelValues get label values of given label from objects in project that match the selector

func (*Client) GetServiceInstanceList added in v0.0.11

func (c *Client) GetServiceInstanceList(selector string) ([]scv1beta1.ServiceInstance, error)

GetServiceInstanceList returns list service instances

func (*Client) GetServicesFromSelector added in v0.0.4

func (c *Client) GetServicesFromSelector(selector string) ([]corev1.Service, error)

GetServicesFromSelector returns an array of Service resources which match the given selector

func (*Client) GetVolumeMountsFromDC added in v0.0.6

func (c *Client) GetVolumeMountsFromDC(dc *appsv1.DeploymentConfig) []corev1.VolumeMount

GetVolumeMountsFromDC returns a list of all volume mounts in the given DC

func (*Client) IsAppSupervisorDVolume added in v1.0.0

func (c *Client) IsAppSupervisorDVolume(volumeName, dcName string) bool

IsAppSupervisorDVolume checks if the volume is a supervisorD volume

func (*Client) IsDeploymentConfigSupported added in v1.2.4

func (c *Client) IsDeploymentConfigSupported() (bool, error)

IsDeploymentConfigSupported checks if DeploymentConfig type is present on the cluster

func (*Client) IsImageStreamSupported added in v1.2.2

func (c *Client) IsImageStreamSupported() (bool, error)

IsImageStreamSupported checks if imagestream resource type is present on the cluster

func (*Client) IsRouteSupported added in v1.2.1

func (c *Client) IsRouteSupported() (bool, error)

IsRouteSupported checks if route resource type is present on the cluster

func (*Client) IsVolumeAnEmptyDir added in v0.0.14

func (c *Client) IsVolumeAnEmptyDir(volumeMountName string, dc *appsv1.DeploymentConfig) bool

IsVolumeAnEmptyDir returns true if the volume is an EmptyDir, false if not

func (*Client) LinkSecret added in v0.0.14

func (c *Client) LinkSecret(secretName, componentName, applicationName string) error

LinkSecret links a secret to the DeploymentConfig of a component

func (*Client) ListRouteNames added in v0.0.3

func (c *Client) ListRouteNames(labelSelector string) ([]string, error)

ListRouteNames lists all the names of the routes based on the given label selector

func (*Client) ListRoutes added in v0.0.3

func (c *Client) ListRoutes(labelSelector string) ([]routev1.Route, error)

ListRoutes lists all the routes based on the given label selector

func (*Client) ListSecrets added in v0.0.15

func (c *Client) ListSecrets(labelSelector string) ([]corev1.Secret, error)

ListSecrets lists all the secrets based on the given label selector

func (*Client) NewAppS2I added in v0.0.3

func (c *Client) NewAppS2I(params CreateArgs, commonObjectMeta metav1.ObjectMeta) error

NewAppS2I is only used with "Git" as we need Build gitURL is the url of the git repo inputPorts is the array containing the string port values envVars is the array containing the string env var values

func (*Client) PatchCurrentDC added in v0.0.14

func (c *Client) PatchCurrentDC(dc appsv1.DeploymentConfig, prePatchDCHandler dcStructUpdater, existingCmpContainer corev1.Container, ucp UpdateComponentParams, isGit bool) error

PatchCurrentDC "patches" the current DeploymentConfig with a new one however... we make sure that configurations such as: - volumes - environment variables are correctly copied over / consistent without an issue. if prePatchDCHandler is specified (meaning not nil), then it's applied as the last action before the actual call to the Kubernetes API thus giving us the chance to perform arbitrary updates to a DC before it's finalized for patching isGit indicates if the deployment config belongs to a git component or a local/binary component

func (*Client) PropagateDeletes added in v0.0.18

func (c *Client) PropagateDeletes(targetPodName string, delSrcRelPaths []string, s2iPaths []string) error

PropagateDeletes deletes the watch detected deleted files from remote component pod from each of the paths in passed s2iPaths Parameters:

targetPodName: Name of component pod
delSrcRelPaths: Paths to be deleted on the remote pod relative to component source base path ex: Compoent src: /abc/src, file deleted: abc/src/foo.lang => relative path: foo.lang
s2iPaths: Slice of all s2i paths -- deployment dir, destination dir, working dir, etc..

func (*Client) RemoveVolumeFromDeploymentConfig added in v0.0.4

func (c *Client) RemoveVolumeFromDeploymentConfig(pvc string, dcName string) error

RemoveVolumeFromDeploymentConfig removes the volume associated with the given PVC from the Deployment Config. Both, the volume entry and the volume mount entry in the containers, are deleted.

func (*Client) RunLogout added in v0.0.15

func (c *Client) RunLogout(stdout io.Writer) error

RunLogout logs out the current user from cluster

func (*Client) SetCurrentProject added in v0.0.3

func (c *Client) SetCurrentProject(projectName string) error

SetCurrentProject sets the given projectName to current project

func (*Client) StartBuild added in v0.0.3

func (c *Client) StartBuild(name string) (string, error)

StartBuild starts new build as it is, returns name of the build stat was started

func (*Client) StartDeployment added in v1.0.0

func (c *Client) StartDeployment(deploymentName string) (string, error)

StartDeployment instantiates a given deployment deploymentName is the name of the deployment to instantiate

func (*Client) UnlinkSecret added in v0.0.18

func (c *Client) UnlinkSecret(secretName, componentName, applicationName string) error

UnlinkSecret unlinks a secret to the DeploymentConfig of a component

func (*Client) UpdateBuildConfig added in v0.0.4

func (c *Client) UpdateBuildConfig(buildConfigName string, gitURL string, annotations map[string]string) error

UpdateBuildConfig updates the BuildConfig file buildConfigName is the name of the BuildConfig file to be updated projectName is the name of the project gitURL equals to the git URL of the source and is equals to "" if the source is of type dir or binary annotations contains the annotations for the BuildConfig file

func (*Client) UpdateDCAnnotations added in v0.0.9

func (c *Client) UpdateDCAnnotations(dcName string, annotations map[string]string) error

UpdateDCAnnotations updates the DeploymentConfig file dcName is the name of the DeploymentConfig file to be updated annotations contains the annotations for the DeploymentConfig file

func (*Client) UpdateDCToGit added in v0.0.14

func (c *Client) UpdateDCToGit(ucp UpdateComponentParams, isDeleteSupervisordVolumes bool) (err error)

UpdateDCToGit replaces / updates the current DeplomentConfig with the appropriate generated image from BuildConfig as well as the correct DeploymentConfig triggers for Git.

func (*Client) UpdateDCToSupervisor added in v0.0.14

func (c *Client) UpdateDCToSupervisor(ucp UpdateComponentParams, isToLocal bool, createPVC bool) error

UpdateDCToSupervisor updates the current DeploymentConfig to a SupervisorD configuration. Parameters:

	commonObjectMeta: dc meta object
	componentImageType: type of builder image
	isToLocal: bool used to indicate if component is to be updated to local in which case a source backup dir will be injected into component env
 isCreatePVC bool used to indicate if a new supervisorD PVC should be created during the update

Returns:

errors if any or nil

func (*Client) UpdatePVCLabels added in v0.0.6

func (c *Client) UpdatePVCLabels(pvc *corev1.PersistentVolumeClaim, labels map[string]string) error

UpdatePVCLabels updates the given PVC with the given labels

func (*Client) WaitAndGetDC added in v0.0.15

func (c *Client) WaitAndGetDC(name string, desiredRevision int64, timeout time.Duration, waitCond func(*appsv1.DeploymentConfig, int64) bool) (*appsv1.DeploymentConfig, error)

WaitAndGetDC block and waits until the DeploymentConfig has updated it's annotation Parameters:

name: Name of DC
timeout: Interval of time.Duration to wait for before timing out waiting for its rollout
waitCond: Function indicating when to consider dc rolled out

Returns:

Updated DC and errors if any

func (*Client) WaitAndGetPod added in v0.0.5

func (c *Client) WaitAndGetPod(selector string, desiredPhase corev1.PodPhase, waitMessage string) (*corev1.Pod, error)

WaitAndGetPod block and waits until pod matching selector is in in Running state desiredPhase cannot be PodFailed or PodUnknown

func (*Client) WaitAndGetSecret added in v0.0.15

func (c *Client) WaitAndGetSecret(name string, namespace string) (*corev1.Secret, error)

WaitAndGetSecret blocks and waits until the secret is available

func (*Client) WaitForBuildToFinish added in v0.0.5

func (c *Client) WaitForBuildToFinish(buildName string, stdout io.Writer, buildTimeout time.Duration) error

WaitForBuildToFinish block and waits for build to finish. Returns error if build failed or was canceled.

func (*Client) WaitForComponentDeletion added in v1.1.3

func (c *Client) WaitForComponentDeletion(selector string) error

WaitForComponentDeletion waits for component to be deleted

func (*Client) WaitForServiceAccountInNamespace added in v1.1.2

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

WaitForServiceAccountInNamespace waits for the given service account to be ready

type CommonImageMeta added in v0.0.14

type CommonImageMeta struct {
	Name      string
	Tag       string
	Namespace string
	Ports     []corev1.ContainerPort
}

CommonImageMeta has all the most common image data that is passed around within Odo

type CreateArgs added in v0.0.17

type CreateArgs struct {
	Name            string
	SourcePath      string
	SourceRef       string
	SourceType      config.SrcType
	ImageName       string
	EnvVars         []string
	Ports           []string
	Resources       *corev1.ResourceRequirements
	ApplicationName string
	Wait            bool
	// StorageToBeMounted describes the storage to be created
	// storagePath is the key of the map, the generatedPVC is the value of the map
	StorageToBeMounted map[string]*corev1.PersistentVolumeClaim
	StdOut             io.Writer
}

CreateArgs is a container of attributes of component create action

type FakeClientset added in v0.0.6

type FakeClientset struct {
	Kubernetes              *fakeKubeClientset.Clientset
	AppsClientset           *fakeAppsClientset.Clientset
	BuildClientset          *fakeBuildClientset.Clientset
	ImageClientset          *fakeImageClientset.Clientset
	RouteClientset          *fakeRouteClientset.Clientset
	ProjClientset           *fakeProjClientset.Clientset
	ServiceCatalogClientSet *fakeServiceCatalogClientSet.Clientset
}

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

type S2IPaths added in v0.0.15

type S2IPaths struct {
	ScriptsPathProtocol string
	ScriptsPath         string
	SrcOrBinPath        string
	DeploymentDir       string
	WorkingDir          string
	SrcBackupPath       string
	BuilderImgName      string
}

S2IPaths is a struct that will hold path to S2I scripts and the protocol indicating access to them, component source/binary paths, artifacts deployments directory These are passed as env vars to component pod

func GetS2IMetaInfoFromBuilderImg added in v0.0.18

func GetS2IMetaInfoFromBuilderImg(builderImage *imagev1.ImageStreamImage) (S2IPaths, error)

GetS2IMetaInfoFromBuilderImg returns script path protocol, S2I scripts path, S2I source or binary expected path, S2I deployment dir and errors(if any) from the passed builder image

type ServerInfo added in v0.0.17

type ServerInfo struct {
	Address           string
	OpenShiftVersion  string
	KubernetesVersion string
}

ServerInfo contains the fields that contain the server's information like address, OpenShift and Kubernetes versions

type SupervisorDUpdateParams added in v1.0.0

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

type UpdateComponentParams added in v1.0.0

type UpdateComponentParams struct {
	// CommonObjectMeta is the object meta containing the labels and annotations expected for the new deployment
	CommonObjectMeta metav1.ObjectMeta
	// ResourceLimits are the cpu and memory constraints to be applied on to the component
	ResourceLimits corev1.ResourceRequirements
	// EnvVars to be exposed
	EnvVars []corev1.EnvVar
	// ExistingDC is the dc of the existing component that is requested for an update
	ExistingDC *appsv1.DeploymentConfig
	// DcRollOutWaitCond holds the logic to wait for dc with requested updates to be applied
	DcRollOutWaitCond dcRollOutWait
	// ImageMeta describes the image to be used in dc(builder image for local/binary and built component image for git deployments)
	ImageMeta CommonImageMeta
	// StorageToBeMounted describes the storage to be mounted
	// storagePath is the key of the map, the generatedPVC is the value of the map
	StorageToBeMounted map[string]*corev1.PersistentVolumeClaim
	// StorageToBeUnMounted describes the storage to be unmounted
	// path is the key of the map,storageName is the value of the map
	StorageToBeUnMounted map[string]string
}

UpdateComponentParams serves the purpose of holding the arguments to a component update request

Jump to

Keyboard shortcuts

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