steps

package
v0.0.0-...-6fcca8b Latest Latest
Warning

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

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

Documentation

Overview

Package steps provides cucumber steps implementations on top of the OpenShift API

Index

Constants

View Source
const (
	// Name of the env var that contains the OpenShift server used to login
	// example: "https://localhost:8443"
	OpenShiftServerEnvVarName = "OPENSHIFT_HOST"

	// Name of the env var that contains the OpenShift username used to login
	// Either use login/password or token
	OpenShiftUsernameEnvVarName = "OPENSHIFT_USER"

	// Name of the env var that contains the OpenShift password used to login
	// Either use login/password or token
	OpenShiftPasswordEnvVarName = "OPENSHIFT_PASSWD"

	// Name of the env var that contains the OpenShift token
	// Either use login/password or token
	OpenShiftTokenEnvVarName = "OPENSHIFT_TOKEN"
)

Variables

This section is empty.

Functions

func CreateResource

func CreateResource(info *resource.Info, err error) error

CreateResource creates the given resource on openshift and returns an error, or nil if successful

Usage: first parse the resource with Context.ParseResource and then use the visitor pattern on the parsed resource:

r.Visit(CreateResource)

func Login

func Login(server string, username string, password string) (*kclient.Config, error)

Login uses the given server/username/password to login on an openshift instance

It returns a client config if successful, or an error

func NewFactory

func NewFactory(config *kclient.Config) *clientcmd.Factory

NewFactory builds a new openshift client factory from the given config

func RegisterSteps

func RegisterSteps(registerer StepsRegisterer)

RegisterSteps allows to register steps on a Context using the context Given/When/Then methods

func ValidateToken

func ValidateToken(server string, token string) (*kclient.Config, error)

ValidateToken validates that the given token is valid on the given server

It returns a client config if successful, or an error

Types

type Context

type Context struct {
	*gucumber.Context
	// contains filtered or unexported fields
}

Context shared by all steps Used to access the openshift client factory and the underlying gucumber context

func NewContext

func NewContext(gc *gucumber.Context) *Context

NewContext build a new context based on the given gucumber context It will register all known steps on the gucumber context

func (*Context) AddSecretToServiceAccount

func (c *Context) AddSecretToServiceAccount(secretName string, serviceAccountName string) error

AddSecretToServiceAccount adds the secret with the given name to the service account with the given name.

Both secret and service account should already exist.

It returns an error, or nil if the operation was successful.

func (*Context) ClientConfig

func (c *Context) ClientConfig() (*kclient.Config, error)

ClientConfig is a shortcut to the client config It returns the k8s client config used by the factory or an error

func (*Context) Clients

func (c *Context) Clients() (*client.Client, *kclient.Client, error)

Clients is a shortcut to the factory Clients It returns the openshift and k8s clients if available otherwise it returns an error (for example if we are not logged in)

func (*Context) CloseTunnel

func (c *Context) CloseTunnel(tunnelName string)

CloseTunnel closes the tunnel with the given name

func (*Context) CreateNewProject

func (c *Context) CreateNewProject(projectName string) error

CreateNewProject creates a new project with the given name, or returns an error

func (*Context) CreateSecret

func (c *Context) CreateSecret(secretName string, secretType kapi.SecretType, sources []string) (*kapi.Secret, error)

CreateSecret creates a new secret with the given name and content (sources).

The most common secret types are SecretTypeOpaque and SecretTypeDockercfg.

It returns the newly created secret, or an error.

func (*Context) DeleteAllResources

func (c *Context) DeleteAllResources() error

DeleteAllResources deletes all resources

func (*Context) DeleteDeploymentConfig

func (c *Context) DeleteDeploymentConfig(dcName string) error

DeleteDeploymentConfig deletes the DeploymentConfig with the given name, or returns an error

func (*Context) DeleteProject

func (c *Context) DeleteProject(projectName string) error

DeleteProject deletes the project with the given name, or returns an error

func (*Context) DeleteResourcesBySelector

func (c *Context) DeleteResourcesBySelector(selector string) error

DeleteResourcesBySelector deletes all resources matching the given label selector

func (*Context) DeploymentConfigExists

func (c *Context) DeploymentConfigExists(dcName string) (bool, error)

DeploymentConfigExists checks if a DeploymentConfig with the given name exists.

func (*Context) ExecWithExponentialBackoff

func (c *Context) ExecWithExponentialBackoff(op backoff.Operation) error

ExecWithExponentialBackoff executes an operation with an exponential backoff retry and returns the operation's error

func (*Context) Factory

func (c *Context) Factory() (*clientcmd.Factory, error)

Factory returns the available client factory (if any) or return an error if no factory is available (meaning we are not logged in)

func (*Context) Fail

func (c *Context) Fail(msgAndArgs ...interface{}) bool

Fail fails the current step It will display the given message and optional arguments Note that it will not stop the step, but only record the failure so it is recommended to return from your step directly after calling this method

func (*Context) GetBuildConfig

func (c *Context) GetBuildConfig(bcName string) (*buildapi.BuildConfig, error)

GetBuildConfig gets the BuildConfig with the given name, or returns an error

func (*Context) GetBuildLogs

func (c *Context) GetBuildLogs(buildName string) (string, error)

func (*Context) GetCurrentUser

func (c *Context) GetCurrentUser() (*userapi.User, error)

GetCurrentUser gets the current User, or returns an error

func (*Context) GetDeploymentConfig

func (c *Context) GetDeploymentConfig(dcName string) (*deployapi.DeploymentConfig, error)

GetDeploymentConfig gets the DeploymentConfig with the given name, or returns an error

func (*Context) GetDeploymentLogs

func (c *Context) GetDeploymentLogs(name string) (string, error)

func (*Context) GetEndpoints

func (c *Context) GetEndpoints(epName string) (*kapi.Endpoints, error)

GetEndpoints gets the Endpoints with the given name, or returns an error

func (*Context) GetImageStream

func (c *Context) GetImageStream(isName string) (*imageapi.ImageStream, error)

GetImageStream gets the ImageStream with the given name, or returns an error

func (*Context) GetPod

func (c *Context) GetPod(podName string) (*kapi.Pod, error)

GetPod gets the Pod with the given name, or returns an error

func (*Context) GetPods

func (c *Context) GetPods(labelSelector labels.Selector) (*kapi.PodList, error)

GetPods gets the PodList from the given label selector, or returns an error

func (*Context) GetReplicationControllers

func (c *Context) GetReplicationControllers(labelSelector labels.Selector) (*kapi.ReplicationControllerList, error)

GetReplicationControllers gets a ReplicationControllerList from the given label selector, or returns an error

func (*Context) GetResourceQuotas

func (c *Context) GetResourceQuotas() ([]kapi.ResourceQuota, error)

GetResourceQuotas gets all the ResourceQuotas, or returns an error

func (*Context) GetRoleBindingsForRole

func (c *Context) GetRoleBindingsForRole(roleName string) ([]authapi.RoleBinding, error)

GetRoleBindingsForRole gets the RoleBindings with the given role name, or returns an error

func (*Context) GetRoute

func (c *Context) GetRoute(routeName string) (*routeapi.Route, error)

GetRoute gets the Route with the given name, or returns an error

func (*Context) GetSecret

func (c *Context) GetSecret(secretName string) (*kapi.Secret, error)

GetSecret gets the Secret with the given name, or returns an error

func (*Context) GetService

func (c *Context) GetService(serviceName string) (*kapi.Service, error)

GetService gets the Service with the given name, or returns an error

func (*Context) GetServiceAccount

func (c *Context) GetServiceAccount(saName string) (*kapi.ServiceAccount, error)

GetServiceAccount gets the ServiceAccount with the given name, or returns an error

func (*Context) GetTemplate

func (c *Context) GetTemplate(templateName string) (*templateapi.Template, error)

GetTemplate gets the Template with the given name, or returns an error

func (*Context) GetTunnel

func (c *Context) GetTunnel(tunnelName string) *Tunnel

GetTunnel returns the tunnel with the given name or nil if no tunnel exists with this name

func (*Context) GetUser

func (c *Context) GetUser(userName string) (*userapi.User, error)

GetUser gets the User with the given name, or returns an error

func (*Context) GroupHasRole

func (c *Context) GroupHasRole(groupName string, roleName string) (bool, error)

GroupHasRole checks that the given group has the given role

func (*Context) IsBuildComplete

func (c *Context) IsBuildComplete(buildName string, timeout time.Duration) (bool, error)

IsBuildComplete checks if the build with the given name is complete.

If the build is still running, it will wait for the given timeout duration.

It returns true if the build completed, or false if it failed (or was cancelled).

func (*Context) IsDeploymentComplete

func (c *Context) IsDeploymentComplete(deploymentName string, timeout time.Duration) (bool, error)

IsDeploymentComplete checks if the deployment with the given name is complete.

If the deployment is still running, it will wait for the given timeout duration.

It returns true if the deployment completed, or false if it failed.

func (*Context) Namespace

func (c *Context) Namespace() (string, error)

Namespace returns the current namespace (if defined) or return an error if no namespace is defined

func (*Context) NewAppFromTemplate

func (c *Context) NewAppFromTemplate(templateName string, templateParameters []string) (*kapi.List, []error)

NewAppFromTemplate creates a new application from the given template and parameters and returns the list of objects created, or the errors

The template referenced should already have been created

func (*Context) OpenTunnel

func (c *Context) OpenTunnel(tunnelName string, podName string, targetPort int) (*Tunnel, error)

OpenTunnel opens a new Tunnel with the given name, targeting the given pod and port. It returns the tunnel object (to get the local port), or an error.

func (*Context) ParseResource

func (c *Context) ParseResource(fileName string) (*resource.Result, error)

ParseResource parses the resource stored in the given file, and returns the Result or an error.

If you need to create resources on openshift, after parsing you will need to use the visitor pattern, and the CreateResource function.

func (*Context) ProjectExists

func (c *Context) ProjectExists(projectName string) (bool, error)

ProjectExists checks if a project with the given name exists.

func (*Context) StartNewBuild

func (c *Context) StartNewBuild(bcName string) (*buildapi.Build, error)

StartNewBuild starts a new build for the BuildConfig with the given name and returns the newly created Build, or an error

func (*Context) TemplateExists

func (c *Context) TemplateExists(tmplName string) (bool, error)

TemplateExists checks if a template with the given name exists.

func (*Context) UserHasRole

func (c *Context) UserHasRole(userName string, roleName string) (bool, error)

UserHasRole checks if the given user has the given role if the userName is empty, the current user will be used

type StepsRegisterer

type StepsRegisterer func(c *Context)

StepsRegisterer allows to register steps on a Context using the context Given/When/Then methods

type Tunnel

type Tunnel struct {
	Name      string
	LocalPort int
	// contains filtered or unexported fields
}

Tunnel is a wrapper around an HTTP tunnel implemented by port forwarding

func NewTunnel

func NewTunnel(name string) *Tunnel

NewTunnel build a new Tunnel with the given name The tunnel will need to be started with StartForwardingToPod

func (*Tunnel) Close

func (tunnel *Tunnel) Close()

Close is an alias of StopForwarding

func (*Tunnel) StartForwardingToPod

func (tunnel *Tunnel) StartForwardingToPod(podName string, namespace string, targetPort int, restClient *kclientapi.RESTClient, clientConfig *kclientapi.Config) error

StartForwardingToPod starts forwarding requests to the given pod on the given target port If no localPort has been defined on the tunnel, a random available port will be assigned The tunnel is started in the background (using a goroutine), and will need to be stopped with Stop() It returns an error if it can't start the tunnel.

func (*Tunnel) StopForwarding

func (tunnel *Tunnel) StopForwarding()

StopForwarding stop forwarding to the pod, and close the tunnel.

Jump to

Keyboard shortcuts

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