common

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: Apache-2.0 Imports: 11 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"

	// These are the condition types that are used in the status of the Kode and EntryPoint resources
	// ConditionTypeReady indicates that the resource is fully operational and prepared to serve its intended purpose.
	ConditionTypeReady = "Ready"

	// ConditionTypeAvailable indicates that the resource is accessible and can actively serve requests or perform its function.
	ConditionTypeAvailable = "Available"

	// ConditionTypeProgressing indicates that the resource is actively working towards a desired state.
	ConditionTypeProgressing = "Progressing"

	// ConditionTypeDegraded indicates that the resource is operational but not functioning optimally or with full capabilities.
	ConditionTypeDegraded = "Degraded"

	// ConditionTypeError indicates that the resource has encountered an error state that requires attention.
	ConditionTypeError = "Error"

	// ConditionTypeConfigured indicates that the resource has been properly configured with all necessary settings.
	ConditionTypeConfigured = "Configured"

	// 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 AddTypeInformationToObject added in v0.2.2

func AddTypeInformationToObject(obj runtime.Object) error

addTypeInformationToObject adds TypeMeta information to a runtime.Object based upon the loaded scheme.Scheme taken from: https://github.com/kubernetes/kubernetes/issues/3030#issuecomment-700099699

func BoolPtr

func BoolPtr(b bool) *bool

returns a pointer to a bool

func ContextWithTimeout

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

wraps a context with a timeout

func GetCurrentTime added in v0.3.0

func GetCurrentTime() metav1.Time

func GetLatestKode added in v0.3.0

func GetLatestKode(ctx context.Context, client client.Client, name, namespace string) (*kodev1alpha1.Kode, error)

func GetPVCName

func GetPVCName(kode *kodev1alpha1.Kode) string

returns the name of the PersistentVolumeClaim for the Kode instance

func GetServiceName added in v0.2.2

func GetServiceName(kode *kodev1alpha1.Kode) string

returns the name of the Kode service

func GetUsernameAndPasswordFromSecret added in v0.3.0

func GetUsernameAndPasswordFromSecret(secret *corev1.Secret) (string, string, error)

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 JoinErrors

func JoinErrors(errs ...error) error

joins multiple errors into a single error

func MaskEnvVars

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

masks sensitive environment variables

func MaskSecretData added in v0.3.0

func MaskSecretData(secret *corev1.Secret) map[string]string

masks sensitive values in a secret

func MaskSpec added in v0.2.2

func MaskSpec(spec corev1.Container) corev1.Container

masks sensitive values in a container spec

func MergeLabels

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

merges multiple sets of labels

func ObjectKeyFromConfig added in v0.3.0

func ObjectKeyFromConfig(config *KodeResourcesConfig) types.NamespacedName

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
	AuthConfig   kodev1alpha1.AuthConfig
	Credentials  Credentials
}

BootstrapConfigOptions contains options for generating Envoy bootstrap config

type Credentials added in v0.3.0

type Credentials struct {
	Username string
	Password string
}

Credentials holds username and password

type EntryPointResourceConfig added in v0.3.0

type EntryPointResourceConfig struct {
	EntryPoint          kodev1alpha1.EntryPoint
	Labels              map[string]string
	EntryPointName      string
	EntryPointNamespace string
	EntryPointService   string
	EntryPointURL       string
}

EntryPointResourceConfig holds configuration for EntryPoint resources

type KodeResourcesConfig

type KodeResourcesConfig struct {
	KodeSpec            kodev1alpha1.KodeSpec
	Labels              map[string]string
	KodeName            string
	KodeNamespace       string
	Secret              corev1.Secret
	SecretName          string
	Credentials         Credentials
	StatefulSetName     string
	PVCName             string
	ServiceName         string
	Templates           Templates
	Containers          []corev1.Container
	InitContainers      []corev1.Container
	UserInitPlugins     []kodev1alpha1.InitPluginSpec
	TemplateInitPlugins []kodev1alpha1.InitPluginSpec
	LocalServicePort    int32
	ExternalServicePort int32
	RetryCount          int
}

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