common

package
v0.0.0-...-3c344cc Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const LogCfgName = "log.properties"

Variables

This section is empty.

Functions

func ConvertToResourceRequirements

func ConvertToResourceRequirements(resources *trinov1alpha1.ResourcesSpec) *corev1.ResourceRequirements

func CreateCatalogConfigmapName

func CreateCatalogConfigmapName(instanceName string) string

func CreateRoleGroupLoggingConfigMapName

func CreateRoleGroupLoggingConfigMapName(instanceName string, role string, groupName string) string

CreateRoleGroupLoggingConfigMapName create role group logging config-map name

func CreateSchemaConfigmapName

func CreateSchemaConfigmapName(instanceName string) string

func CreateServiceName

func CreateServiceName(instanceName string, roleName string, groupName string) string

func MergeObjects

func MergeObjects(left interface{}, right interface{}, exclude []string)

MergeObjects merge right to left, if field not in left, it will be added from right, else skip. Node: If variable is a pointer, it will be modified directly.

func OverrideEnvVars

func OverrideEnvVars(origin *[]corev1.EnvVar, override map[string]string)

func ReconcilerDoHandler

func ReconcilerDoHandler(ctx context.Context, reconcilers []ResourceReconciler) (ctrl.Result, error)

Types

type BaseResourceReconciler

type BaseResourceReconciler[T client.Object, G any] struct {
	Instance  T
	Scheme    *runtime.Scheme
	Client    client.Client
	GroupName string

	MergedLabels map[string]string
	MergedCfg    G
}

func NewBaseResourceReconciler

func NewBaseResourceReconciler[T client.Object, G any](
	scheme *runtime.Scheme,
	instance T,
	client client.Client,
	groupName string,
	mergedLabels map[string]string,
	mergedCfg G) *BaseResourceReconciler[T, G]

NewBaseResourceReconciler new a BaseResourceReconciler

func (*BaseResourceReconciler[T, G]) Apply

func (b *BaseResourceReconciler[T, G]) Apply(
	ctx context.Context,
	dep client.Object,
	timeAfter time.Duration) (ctrl.Result, error)

func (*BaseResourceReconciler[T, G]) ReconcileResource

func (b *BaseResourceReconciler[T, G]) ReconcileResource(
	ctx context.Context,
	builder ResourceBuilderType) (ctrl.Result, error)

type BaseRoleGroupReconciler

type BaseRoleGroupReconciler[T client.Object] struct {
	Scheme     *runtime.Scheme
	Instance   T
	Client     client.Client
	GroupName  string
	RoleLabels map[string]string
	Log        logr.Logger

	Reconcilers []ResourceReconciler
}

func (*BaseRoleGroupReconciler[T]) ReconcileGroup

func (m *BaseRoleGroupReconciler[T]) ReconcileGroup(ctx context.Context) (ctrl.Result, error)

ReconcileGroup ReconcileRole implements the Role interface

type BaseRoleReconciler

type BaseRoleReconciler[T client.Object] struct {
	Scheme   *runtime.Scheme
	Instance T
	Client   client.Client
	Log      logr.Logger
	Labels   map[string]string

	Role Role
}

func (*BaseRoleReconciler[T]) GetLabels

func (r *BaseRoleReconciler[T]) GetLabels() map[string]string

type ConditionsGetter

type ConditionsGetter interface {
	GetConditions() *[]metav1.Condition
}

type ConfigurationOverride

type ConfigurationOverride interface {
	ConfigurationOverride(resource client.Object)
}

type ConfigurationStyleReconciler

type ConfigurationStyleReconciler[T client.Object, G any] struct {
	GeneralResourceStyleReconciler[T, G]
}

ConfigurationStyleReconciler configuration style reconciler this reconciler is used to reconcile the configuration style resources such as configMap, secret, etc. it will do the following things: 1. apply the resource Additional: 1. configuration override support

func NewConfigurationStyleReconciler

func NewConfigurationStyleReconciler[T client.Object, G any](
	scheme *runtime.Scheme,
	instance T,
	client client.Client,
	groupName string,
	mergedLabels map[string]string,
	mergedCfg G,
) *ConfigurationStyleReconciler[T, G]

func (*ConfigurationStyleReconciler[T, G]) DoReconcile

func (s *ConfigurationStyleReconciler[T, G]) DoReconcile(
	ctx context.Context,
	resource client.Object,
	instance ResourceHandler,
) (ctrl.Result, error)

type GeneralResourceStyleReconciler

type GeneralResourceStyleReconciler[T client.Object, G any] struct {
	BaseResourceReconciler[T, G]
}

GeneralResourceStyleReconciler general style resource reconcile this reconciler is used to reconcile the general style resources such as configMap, secret, svc, etc.

func NewGeneraResourceStyleReconciler

func NewGeneraResourceStyleReconciler[T client.Object, G any](
	scheme *runtime.Scheme,
	instance T,
	client client.Client,
	groupName string,
	mergedLabels map[string]string,
	mergedCfg G,
) *GeneralResourceStyleReconciler[T, G]

func (*GeneralResourceStyleReconciler[T, G]) DoReconcile

func (s *GeneralResourceStyleReconciler[T, G]) DoReconcile(
	ctx context.Context,
	resource client.Object,
	_ ResourceHandler,
) (ctrl.Result, error)

type InstanceAttributes

type InstanceAttributes interface {
	RoleConfigSpec
	GetClusterConfig() any
}

type LoggingRecociler

type LoggingRecociler struct {
	GeneralResourceStyleReconciler[*trinov1alpha1.TrinoCluster, any]
	RoleLoggingDataBuilder RoleLoggingDataBuilder
	// contains filtered or unexported fields
}

func NewLoggingReconciler

func NewLoggingReconciler(
	scheme *runtime.Scheme,
	instance *trinov1alpha1.TrinoCluster,
	client client.Client,
	groupName string,
	mergedLabels map[string]string,
	mergedCfg any,
	logDataBuilder RoleLoggingDataBuilder,
	role Role,
) *LoggingRecociler

NewLoggingReconciler new logging reconcile

func (*LoggingRecociler) Build

Build log4j config map

type MultiConfigurationStyleReconciler

type MultiConfigurationStyleReconciler[T client.Object, G any] struct {
	BaseResourceReconciler[T, G]
}

MultiConfigurationStyleReconciler multi configuration object reconciler

func NewMultiConfigurationStyleReconciler

func NewMultiConfigurationStyleReconciler[T client.Object, G any](
	scheme *runtime.Scheme,
	instance T,
	client client.Client,
	groupName string,
	mergedLabels map[string]string,
	mergedCfg G,
) *MultiConfigurationStyleReconciler[T, G]

NewMultiConfigurationStyleReconciler newMultiConfigurationStyleReconciler new a MultiConfigurationStyleReconciler

func (*MultiConfigurationStyleReconciler[T, G]) ReconcileResource

func (s *MultiConfigurationStyleReconciler[T, G]) ReconcileResource(
	ctx context.Context,
	builder ResourceBuilderType) (ctrl.Result, error)

ReconcileResource implement ResourceReconcile interface

type MultiResourceReconcilerBuilder

type MultiResourceReconcilerBuilder interface {
	Build(ctx context.Context) ([]ResourceBuilder, error)
}

MultiResourceReconcilerBuilder multi resource builder it will build multi resources for example, it will build more than one configMap currently, it is used to build the configMap see MultiConfigurationStyleReconciler

type PDBReconciler

type PDBReconciler[T client.Object] struct {
	GeneralResourceStyleReconciler[T, any]
	// contains filtered or unexported fields
}

func NewReconcilePDB

func NewReconcilePDB[T client.Object](
	client client.Client,
	schema *runtime.Scheme,
	cr T,
	labels map[string]string,
	name string,
	pdb *trinov1alpha1.PodDisruptionBudgetSpec,
) *PDBReconciler[T]

func (*PDBReconciler[T]) Build

func (r *PDBReconciler[T]) Build(_ context.Context) (client.Object, error)

type ResourceBuilder

type ResourceBuilder interface {
	Build(ctx context.Context) (client.Object, error)
}

type ResourceBuilderType

type ResourceBuilderType struct {
	Single ResourceBuilder
	Multi  MultiResourceReconcilerBuilder
}

ResourceBuilderType union type for resource builder it will build the single resource or multi resources

func NewSingleResourceBuilder

func NewSingleResourceBuilder(builder ResourceBuilder) ResourceBuilderType

type ResourceClient

type ResourceClient struct {
	Ctx       context.Context
	Client    client.Client
	Namespace string
}

func (*ResourceClient) Get

func (r *ResourceClient) Get(obj client.Object) error

type ResourceHandler

type ResourceHandler interface {
	DoReconcile(ctx context.Context, resource client.Object, instance ResourceHandler) (ctrl.Result, error)
}

type ResourceNameGenerator

type ResourceNameGenerator struct {
	InstanceName string
	RoleName     string
	GroupName    string
}

func NewResourceNameGenerator

func NewResourceNameGenerator(instanceName, roleName, groupName string) *ResourceNameGenerator

NewResourceNameGenerator new a ResourceNameGenerator

func (*ResourceNameGenerator) GenerateResourceName

func (r *ResourceNameGenerator) GenerateResourceName(extraSuffix string) string

GenerateResourceName generate resource Name

type ResourceReconciler

type ResourceReconciler interface {
	ReconcileResource(ctx context.Context, builder ResourceBuilderType) (ctrl.Result, error)
}

type Role

type Role string
const (
	Coordinator Role = "coordinator"
	Worker      Role = "worker"
)

type RoleConfigSpec

type RoleConfigSpec interface {
	GetRoleConfigSpec(role Role) (any, error)
}

type RoleGroupRecociler

type RoleGroupRecociler interface {
	ReconcileGroup(ctx context.Context) (ctrl.Result, error)
	MergeLabels(mergedGroupCfg any) map[string]string
	MergeGroupConfigSpec() any
	RegisterResource()
}

RoleGroupRecociler RoleReconcile role reconciler interface all role reconciler should implement this interface

type RoleLabels

type RoleLabels[T client.Object] struct {
	Cr   T
	Name string
}

func (*RoleLabels[T]) GetLabels

func (r *RoleLabels[T]) GetLabels() map[string]string

type RoleLoggingDataBuilder

type RoleLoggingDataBuilder interface {
	MakeContainerLogData() map[string]string
}

type RoleReconciler

type RoleReconciler interface {
	RoleName() Role
	MergeLabels() map[string]string
	ReconcileRole(ctx context.Context) (ctrl.Result, error)
}

type WorkloadOverride

type WorkloadOverride interface {
	CommandOverride(resource client.Object)
	EnvOverride(resource client.Object)
	LogOverride(resource client.Object)
}

type WorkloadStyleReconciler

type WorkloadStyleReconciler[T client.Object, G any] struct {
	BaseResourceReconciler[T, G]
	// contains filtered or unexported fields
}

WorkloadStyleReconciler deployment style reconciler this reconciler is used to reconcile the deployment style resources such as deployment, statefulSet, etc. it will do the following things: 1. apply the resource 2. check if the resource is satisfied 3. if not, return requeue 4. if satisfied, return nil Additional:

command and env override can support

func NewDeploymentStyleReconciler

func NewDeploymentStyleReconciler[T client.Object, G any](
	scheme *runtime.Scheme,
	instance T,
	client client.Client,
	groupName string,
	mergedLabels map[string]string,
	mergedCfg G,
	replicas int32,
) *WorkloadStyleReconciler[T, G]

func (*WorkloadStyleReconciler[T, G]) CheckPodsSatisfied

func (s *WorkloadStyleReconciler[T, G]) CheckPodsSatisfied(ctx context.Context) (bool, error)

func (*WorkloadStyleReconciler[T, G]) DoReconcile

func (s *WorkloadStyleReconciler[T, G]) DoReconcile(
	ctx context.Context,
	resource client.Object,
	instance ResourceHandler,
) (ctrl.Result, error)

Jump to

Keyboard shortcuts

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