util

package
v0.0.0-...-a5cbdf7 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: EPL-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Copyright (c) 2012-2019 Red Hat, Inc. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0/

SPDX-License-Identifier: EPL-2.0

Contributors:

Red Hat, Inc. - initial API and implementation

Copyright (c) 2012-2019 Red Hat, Inc. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0/

SPDX-License-Identifier: EPL-2.0

Contributors:

Red Hat, Inc. - initial API and implementation

Copyright (c) 2012-2019 Red Hat, Inc. This program and the accompanying materials are made available under the terms of the Eclipse Public License 2.0 which is available at https://www.eclipse.org/legal/epl-2.0/

SPDX-License-Identifier: EPL-2.0

Contributors:

Red Hat, Inc. - initial API and implementation

Index

Constants

This section is empty.

Variables

View Source
var (
	IsOpenShift, IsOpenShift4, _ = DetectOpenShift()
)
View Source
var (
	K8sclient = GetK8Client()
)

Functions

func CompareResources

func CompareResources(actualDeployment *appsv1.Deployment, expected TestExpectedResources, t *testing.T)

func ContainsString

func ContainsString(slice []string, s string) bool

func DetectOpenShift

func DetectOpenShift() (isOpenshift bool, isOpenshift4 bool, anError error)

func DoRemoveString

func DoRemoveString(slice []string, s string) (result []string)

func FindEnv

func FindEnv(envs []corev1.EnvVar, name string) *corev1.EnvVar

Finds Env by a given name

func FindVolume

func FindVolume(volumes []corev1.Volume, name string) corev1.Volume

func FindVolumeMount

func FindVolumeMount(volumes []corev1.VolumeMount, name string) corev1.VolumeMount

func GeneratePasswd

func GeneratePasswd(stringLength int) (passwd string)

func GetArchitectureDependentEnv

func GetArchitectureDependentEnv(env string) string

GetArchitectureDependentEnv returns environment variable dependending on architecture by adding "_<ARCHITECTURE>" suffix. If variable is not set then the default will be return.

func GetClusterPublicHostname

func GetClusterPublicHostname(isOpenShift4 bool) (hostname string, err error)

func GetDeploymentEnv

func GetDeploymentEnv(deployment *appsv1.Deployment, key string) (value string)

func GetDeploymentEnvVarSource

func GetDeploymentEnvVarSource(deployment *appsv1.Deployment, key string) (valueFrom *corev1.EnvVarSource)

func GetEnvByRegExp

func GetEnvByRegExp(regExp string) []corev1.EnvVar

func GetK8Client

func GetK8Client() *k8s

func GetMapValue

func GetMapValue(value map[string]string, defaultValue map[string]string) map[string]string

func GetResourceQuantity

func GetResourceQuantity(value string, defaultValue string) resource.Quantity

func GetServerExposureStrategy

func GetServerExposureStrategy(c *orgv1.CheCluster, defaultValue string) string

func GetServerResources

func GetServerResources() ([]*v1.APIResourceList, error)

func GetValue

func GetValue(key string, defaultValue string) (value string)

func GetWorkspaceNamespaceDefault

func GetWorkspaceNamespaceDefault(cr *orgv1.CheCluster) string

GetWorkspaceNamespaceDefault - returns workspace namespace default strategy, which points on the namespaces used for workspaces execution.

func IsDeleteOAuthInitialUser

func IsDeleteOAuthInitialUser(cr *orgv1.CheCluster) bool

IsDeleteOAuthInitialUser - returns true when initial Openshfit oAuth user must be deleted.

func IsInitialOpenShiftOAuthUserEnabled

func IsInitialOpenShiftOAuthUserEnabled(c *orgv1.CheCluster) bool

IsInitialOpenShiftOAuthUserEnabled returns true when initial Openshift oAuth user is enabled for CheCluster resource, otherwise false.

func IsOAuthEnabled

func IsOAuthEnabled(c *orgv1.CheCluster) bool

IsOAuthEnabled returns true when oAuth is enable for CheCluster resource, otherwise false.

func IsTestMode

func IsTestMode() (isTesting bool)

func IsWorkspaceInSameNamespaceWithChe

func IsWorkspaceInSameNamespaceWithChe(cr *orgv1.CheCluster) bool

IsWorkspaceInSameNamespaceWithChe return true when Che workspaces will be executed in the same namespace with Che, otherwise returns false.

func MapToKeyValuePairs

func MapToKeyValuePairs(m map[string]string) string

func MergeMaps

func MergeMaps(first map[string]string, second map[string]string) map[string]string

func NewBoolPointer

func NewBoolPointer(value bool) *bool

NewBoolPointer returns `bool` pointer to value in the memory. Unfortunately golang hasn't got syntax to create `bool` pointer.

func ReadObject

func ReadObject(yamlFile string, obj interface{}) error

func ValidateContainData

func ValidateContainData(actualData map[string]string, expectedData map[string]string, t *testing.T)

func ValidateSecurityContext

func ValidateSecurityContext(actualDeployment *appsv1.Deployment, t *testing.T)

Types

type Process

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

func (*Process) GetStdErr

func (p *Process) GetStdErr() string

func (*Process) GetStdOut

func (p *Process) GetStdOut() string

func (*Process) Run

func (p *Process) Run(name string, args ...string) error

type Runnable

type Runnable interface {
	Run(name string, args ...string) error
	GetStdOut() string
	GetStdErr() string
}

func NewRunnable

func NewRunnable() Runnable

type TestExpectedResources

type TestExpectedResources struct {
	MemoryLimit   string
	MemoryRequest string
	CpuRequest    string
	CpuLimit      string
}

Jump to

Keyboard shortcuts

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