utils

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0, MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RunnerType represents resource of type Runner
	RunnerType = "runner"

	// GitlabType represents resource of type Gitlab
	GitlabType = "gitlab"

	// BackupType represents the Backup resource
	BackupType = "backup"
)

Variables

View Source
var (
	// ConfigMapDefaultMode for configmap projected volume
	ConfigMapDefaultMode int32 = 420

	// ExecutableDefaultMode for configmap projected volume
	ExecutableDefaultMode int32 = 493

	// ProjectedVolumeDefaultMode for projected volume
	ProjectedVolumeDefaultMode int32 = 256

	// SecretDefaultMode for secret projected volume
	SecretDefaultMode int32 = 288
)

Functions

func ConfigMapData

func ConfigMapData(name, namespace string) (map[string]string, error)

ConfigMapData returns data contained in a configmap

func ConfigMapWithHash

func ConfigMapWithHash(cm *corev1.ConfigMap)

ConfigMapWithHash updates configmap with annotation containing a SHA256 hash of its data

func DeploymentConfigMaps

func DeploymentConfigMaps(deploy *appsv1.Deployment) []string

DeploymentConfigMaps returns a list of configmaps used in a deployment

func EncodeString

func EncodeString(message string) string

EncodeString accepts strings and returns a base64 encoded string

func GenericConfigMap

func GenericConfigMap(name, namespace string, labels map[string]string) *corev1.ConfigMap

GenericConfigMap returns empty configmap

func GenericDeployment

func GenericDeployment(component Component) *appsv1.Deployment

GenericDeployment returns a generic deployment

func GenericSecret

func GenericSecret(name, namespace string, labels map[string]string) *corev1.Secret

GenericSecret returns empty secret

func GetSecretValue

func GetSecretValue(client client.Client, namespace, secret, key string) (string, error)

GetSecretValue returns the value for a key from an existing secret

func IsConfigMapChanged

func IsConfigMapChanged(old, new *corev1.ConfigMap) (*corev1.ConfigMap, bool)

IsConfigMapChanged returns an updated configmap object and true if the configmap has changed

func IsDeploymentChanged

func IsDeploymentChanged(old, new *appsv1.Deployment) (*appsv1.Deployment, bool)

IsDeploymentChanged compares two deployments and returns a merged deployment object and true if they are different

func IsOpenshift

func IsOpenshift() bool

IsOpenshift check if API has the API route.openshift.io/v1, then it is considered an openshift environment

func IsPrometheusSupported

func IsPrometheusSupported() bool

IsPrometheusSupported checks for Prometheus API endpoint

func Label

func Label(cr *gitlabv1beta2.Runner, component, resourceType string) map[string]string

Label function returns uniform labels for resources

func ReadConfig

func ReadConfig(filename string) string

ReadConfig returns contents of file as string

func ResourceQuantity

func ResourceQuantity(request string) resource.Quantity

ResourceQuantity returns quantity requested for resource

func SecretData

func SecretData(name, namespace string) (map[string]string, error)

SecretData gets a secret by name and returns its data

func ServiceAccount

func ServiceAccount(name, namespace string) *corev1.ServiceAccount

ServiceAccount returns service account to be used by pods

Types

type Component

type Component struct {
	// Namespace of the component
	Namespace string
	// Defines the number of pods for the
	// component to be created
	Replicas int32
	// Labels for the component
	Labels map[string]string
	// InitContainers contains a list of containers	that may
	// need to run before the main application container starts up
	InitContainers []corev1.Container
	// Containers containers a list of containers that make up a pod
	Containers []corev1.Container
	// Contains a list of volumes used by the containers
	Volumes []corev1.Volume
	// Defines volume claims to be used by a statefulset
	VolumeClaimTemplates []corev1.PersistentVolumeClaim
}

Component represents an application / micro-service that makes part of a larger application

type KubeConfig

type KubeConfig struct {
	Config *rest.Config
	Error  error
}

KubeConfig returns kubernetes client configuration

func KubernetesConfig

func KubernetesConfig() KubeConfig

KubernetesConfig returns kubernetes client config

func (KubeConfig) NewKubernetesClient

func (k KubeConfig) NewKubernetesClient() (*kubernetes.Clientset, error)

NewKubernetesClient returns a client that can be used to interact with the kubernetes api

type PasswordOptions

type PasswordOptions struct {
	// Length defines desired password length
	Length int
	// EnableSpecialCharacters adds special characters
	// to generated passwords
	EnableSpecialChars bool
}

PasswordOptions provides parameters to be used when generating passwords

Jump to

Keyboard shortcuts

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