Documentation ¶
Overview ¶
Package steps provides cucumber steps implementations on top of the OpenShift API
Index ¶
- Constants
- func CreateResource(info *resource.Info, err error) error
- func Login(server string, username string, password string) (*kclient.Config, error)
- func NewFactory(config *kclient.Config) *clientcmd.Factory
- func RegisterSteps(registerer StepsRegisterer)
- func ValidateToken(server string, token string) (*kclient.Config, error)
- type Context
- func (c *Context) AddSecretToServiceAccount(secretName string, serviceAccountName string) error
- func (c *Context) ClientConfig() (*kclient.Config, error)
- func (c *Context) Clients() (*client.Client, *kclient.Client, error)
- func (c *Context) CloseTunnel(tunnelName string)
- func (c *Context) CreateNewProject(projectName string) error
- func (c *Context) CreateSecret(secretName string, secretType kapi.SecretType, sources []string) (*kapi.Secret, error)
- func (c *Context) DeleteAllResources() error
- func (c *Context) DeleteDeploymentConfig(dcName string) error
- func (c *Context) DeleteProject(projectName string) error
- func (c *Context) DeleteResourcesBySelector(selector string) error
- func (c *Context) DeploymentConfigExists(dcName string) (bool, error)
- func (c *Context) ExecWithExponentialBackoff(op backoff.Operation) error
- func (c *Context) Factory() (*clientcmd.Factory, error)
- func (c *Context) Fail(msgAndArgs ...interface{}) bool
- func (c *Context) GetBuildConfig(bcName string) (*buildapi.BuildConfig, error)
- func (c *Context) GetBuildLogs(buildName string) (string, error)
- func (c *Context) GetCurrentUser() (*userapi.User, error)
- func (c *Context) GetDeploymentConfig(dcName string) (*deployapi.DeploymentConfig, error)
- func (c *Context) GetDeploymentLogs(name string) (string, error)
- func (c *Context) GetEndpoints(epName string) (*kapi.Endpoints, error)
- func (c *Context) GetImageStream(isName string) (*imageapi.ImageStream, error)
- func (c *Context) GetPod(podName string) (*kapi.Pod, error)
- func (c *Context) GetPods(labelSelector labels.Selector) (*kapi.PodList, error)
- func (c *Context) GetReplicationControllers(labelSelector labels.Selector) (*kapi.ReplicationControllerList, error)
- func (c *Context) GetResourceQuotas() ([]kapi.ResourceQuota, error)
- func (c *Context) GetRoleBindingsForRole(roleName string) ([]authapi.RoleBinding, error)
- func (c *Context) GetRoute(routeName string) (*routeapi.Route, error)
- func (c *Context) GetSecret(secretName string) (*kapi.Secret, error)
- func (c *Context) GetService(serviceName string) (*kapi.Service, error)
- func (c *Context) GetServiceAccount(saName string) (*kapi.ServiceAccount, error)
- func (c *Context) GetTemplate(templateName string) (*templateapi.Template, error)
- func (c *Context) GetTunnel(tunnelName string) *Tunnel
- func (c *Context) GetUser(userName string) (*userapi.User, error)
- func (c *Context) GroupHasRole(groupName string, roleName string) (bool, error)
- func (c *Context) IsBuildComplete(buildName string, timeout time.Duration) (bool, error)
- func (c *Context) IsDeploymentComplete(deploymentName string, timeout time.Duration) (bool, error)
- func (c *Context) Namespace() (string, error)
- func (c *Context) NewAppFromTemplate(templateName string, templateParameters []string) (*kapi.List, []error)
- func (c *Context) OpenTunnel(tunnelName string, podName string, targetPort int) (*Tunnel, error)
- func (c *Context) ParseResource(fileName string) (*resource.Result, error)
- func (c *Context) ProjectExists(projectName string) (bool, error)
- func (c *Context) StartNewBuild(bcName string) (*buildapi.Build, error)
- func (c *Context) TemplateExists(tmplName string) (bool, error)
- func (c *Context) UserHasRole(userName string, roleName string) (bool, error)
- type StepsRegisterer
- type Tunnel
Constants ¶
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 ¶
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 ¶
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 ¶
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
Types ¶
type Context ¶
Context shared by all steps Used to access the openshift client factory and the underlying gucumber context
func NewContext ¶
NewContext build a new context based on the given gucumber context It will register all known steps on the gucumber context
func (*Context) AddSecretToServiceAccount ¶
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 ¶
ClientConfig is a shortcut to the client config It returns the k8s client config used by the factory or an error
func (*Context) Clients ¶
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 ¶
CloseTunnel closes the tunnel with the given name
func (*Context) CreateNewProject ¶
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 ¶
DeleteAllResources deletes all resources
func (*Context) DeleteDeploymentConfig ¶
DeleteDeploymentConfig deletes the DeploymentConfig with the given name, or returns an error
func (*Context) DeleteProject ¶
DeleteProject deletes the project with the given name, or returns an error
func (*Context) DeleteResourcesBySelector ¶
DeleteResourcesBySelector deletes all resources matching the given label selector
func (*Context) DeploymentConfigExists ¶
DeploymentConfigExists checks if a DeploymentConfig with the given name exists.
func (*Context) ExecWithExponentialBackoff ¶
ExecWithExponentialBackoff executes an operation with an exponential backoff retry and returns the operation's error
func (*Context) Factory ¶
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 ¶
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) GetCurrentUser ¶
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 (*Context) GetEndpoints ¶
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) GetPods ¶
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) GetService ¶
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 ¶
GetTunnel returns the tunnel with the given name or nil if no tunnel exists with this name
func (*Context) GroupHasRole ¶
GroupHasRole checks that the given group has the given role
func (*Context) IsBuildComplete ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
ProjectExists checks if a project with the given name exists.
func (*Context) StartNewBuild ¶
StartNewBuild starts a new build for the BuildConfig with the given name and returns the newly created Build, or an error
func (*Context) TemplateExists ¶
TemplateExists checks if a template with the given name exists.
type StepsRegisterer ¶
type StepsRegisterer func(c *Context)
StepsRegisterer allows to register steps on a Context using the context Given/When/Then methods
type Tunnel ¶
Tunnel is a wrapper around an HTTP tunnel implemented by port forwarding
func NewTunnel ¶
NewTunnel build a new Tunnel with the given name The tunnel will need to be started with StartForwardingToPod
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.