common

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// General constants
	OperatorName     = "kode-operator"
	FinalizerName    = "kode.jacero.io/finalizer"
	PVCFinalizerName = "kode.jacero.io/pvc-finalizer"

	// Resource-related constants
	DefaultNamespace        = "default"
	KodeVolumeStorageName   = "kode-storage"
	DefaultLocalServicePort = 3000

	// Container-related constants
	EnvoyProxyContainerName = "envoy-proxy"
	EnvoyProxyRunAsUser     = 1111
	ProxyInitContainerName  = "proxy-init"
	ProxyInitContainerImage = "openpolicyagent/proxy_init:v8"
	BasicAuthContainerPort  = 9001

	// Basic Auth-related constants
	BasicAuthContainerImage = "ghcr.io/emil-jacero/grpc-basic-auth:latest"
	BasicAuthContainerName  = "basic-auth-service"

	// Time-related constants
	ReconcileTimeout            = 1 * time.Minute
	RequeueInterval             = 10 * time.Second
	DefaultInactiveAfterSeconds = 600
	DefaultRecycleAfterSeconds  = 28800

	// Label keys
	LabelAppName   = "app.kubernetes.io/name"
	LabelManagedBy = "app.kubernetes.io/managed-by"
	LabelKodeName  = "kode.jacero.io/name"

	// Annotation keys
	AnnotationLastUpdated = "kode.jacero.io/last-updated"

	// Status condition types
	ConditionTypeCreated  = "Created"
	ConditionTypeReady    = "Ready"
	ConditionTypeRecycled = "Recycled"
	ConditionTypeInactive = "Inactive"
	ConditionTypeError    = "Error"

	// Default values
	DefaultUser        = "abc"
	DefaultHome        = "/config"
	DefaultWorkspace   = "workspace"
	DefaultStorageSize = "1Gi"

	// Environment variable names
	EnvVarPassword = "PASSWORD"
	EnvVarUser     = "USER"
	EnvVarHome     = "HOME"
	EnvVarPUID     = "PUID"
	EnvVarPGID     = "PGID"
	EnvVarTZ       = "TZ"

	// Validation constants
	MinPasswordLength = 8
	MinUsernameLength = 3
	MaxUsernameLength = 256
)

Variables

View Source
var (
	// DefaultLabels are the base labels added to all resources created by the operator
	DefaultLabels = map[string]string{
		LabelManagedBy: OperatorName,
	}

	// DefaultAccessModes are the default access modes for PersistentVolumeClaims
	DefaultAccessModes = []corev1.PersistentVolumeAccessMode{
		corev1.ReadWriteOnce,
	}
)

Functions

func BoolPtr

func BoolPtr(b bool) *bool

returns a pointer to a bool

func ContainsString

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

checks if a string slice contains a specific string

func ContextWithTimeout

func ContextWithTimeout(ctx context.Context, timeoutSeconds int64) (context.Context, context.CancelFunc)

wraps a context with a timeout

func EncodeAndFillPath

func EncodeAndFillPath(ctx *cue.Context, value cue.Value, parsePath string, valuePath string, schema string, data interface{}) (cue.Value, error)

EncodeAndFillPath encodes a data structure, fills it into a CUE value at a specified path, and validates the result The ctx is the CUE context The value is the CUE value to fill The parsePath is used to parse the schema The valuePath is used to fill the data structure into the CUE value The schema is used to validate the data structure The data is the data structure to encode and fill The function returns the updated CUE value and nil if successful If an error occurs, the function returns the original CUE value and the error

func GetEnvOrDefault

func GetEnvOrDefault(key, defaultValue string) string

gets an environment variable or returns a default value

func GetPVCName

func GetPVCName(kode *kodev1alpha1.Kode) string

returns the name of the PersistentVolumeClaim for the Kode instance

func Int32Ptr

func Int32Ptr(i int32) *int32

returns a pointer to an int32

func Int64Ptr

func Int64Ptr(i int64) *int64

returns a pointer to an int64

func IsNotFound

func IsNotFound(err error) bool

checks if an error is a "not found" error

func JoinErrors

func JoinErrors(errs ...error) error

joins multiple errors into a single error

func LogObject

func LogObject(log logr.Logger, obj client.Object, msg string)

logs an object's key details

func MaskEnvVars

func MaskEnvVars(envs []corev1.EnvVar) []corev1.EnvVar

masks sensitive environment variables

func MaskSensitiveValue

func MaskSensitiveValue(s string) string

masks sensitive string values

func MergeLabels

func MergeLabels(labelsSlice ...map[string]string) map[string]string

merges multiple sets of labels

func NamespacedName

func NamespacedName(namespace string, name string) types.NamespacedName

creates a types.NamespacedName from a namespace and name

func RemoveString

func RemoveString(slice []string, s string) []string

removes a string from a slice of strings

func StringPtr

func StringPtr(s string) *string

returns a pointer to a string

Types

type BootstrapConfigOptions

type BootstrapConfigOptions struct {
	HTTPFilters  []kodev1alpha1.HTTPFilter
	Clusters     []kodev1alpha1.Cluster
	LocalPort    int32
	ExternalPort int32
}

BootstrapConfigOptions contains options for generating Envoy bootstrap config

type KodeResourcesConfig

type KodeResourcesConfig struct {
	Kode                kodev1alpha1.Kode
	Templates           Templates
	UserInitPlugins     []kodev1alpha1.InitPluginSpec
	TemplateInitPlugins []kodev1alpha1.InitPluginSpec
	Labels              map[string]string
	LocalServicePort    int32
	ExternalServicePort int32
}

KodeResourcesConfig holds configuration for Kode resources

type TemplateNotFoundError

type TemplateNotFoundError struct {
	NamespacedName types.NamespacedName
	Kind           string
}

func (*TemplateNotFoundError) Error

func (e *TemplateNotFoundError) Error() string

type Templates

type Templates struct {
	KodeTemplate              *kodev1alpha1.SharedKodeTemplateSpec
	EnvoyProxyConfig          *kodev1alpha1.SharedEnvoyProxyConfigSpec
	KodeTemplateName          string
	KodeTemplateNamespace     string
	EnvoyProxyConfigName      string
	EnvoyProxyConfigNamespace string
}

Templates holds the fetched template configurations

Jump to

Keyboard shortcuts

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