Documentation
¶
Index ¶
- type DependencyContainer
- type Error
- type FieldSelector
- type FieldSelectorRequirement
- type HTTPClient
- type HTTPOption
- type HTTPOptionApplier
- type Hook
- type HookConfig
- type HookConfigSettings
- type HookInput
- type HookMetadata
- type KubernetesClient
- type KubernetesConfig
- type KubernetesOption
- type KubernetesOptionApplier
- type Logger
- type MetricCollectorOption
- type MetricCollectorOptionApplier
- type MetricsCollector
- type NameSelector
- type NamespaceSelector
- type OrderedConfig
- type OutputMetricsCollector
- type OutputPatchCollector
- type OutputPatchableValuesCollector
- type Outputer
- type PatchCollector
- type PatchCollectorOperation
- type PatchCollectorOption
- type PatchCollectorOptionApplier
- type PatchableValuesCollector
- type ReconcileFunc
- type RegistryClient
- type RegistryOption
- type RegistryOptionApplier
- type ScheduleConfig
- type Snapshot
- type Snapshots
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DependencyContainer ¶
type DependencyContainer interface {
GetHTTPClient(options ...HTTPOption) HTTPClient
GetK8sClient(options ...KubernetesOption) (KubernetesClient, error)
MustGetK8sClient(options ...KubernetesOption) KubernetesClient
GetClientConfig() (*rest.Config, error)
GetRegistryClient(repo string, options ...RegistryOption) (RegistryClient, error)
MustGetRegistryClient(repo string, options ...RegistryOption) RegistryClient
GetClock() clockwork.Clock
}
Container with external dependencies Avoid using dependencies, if you can, because of it cost
type FieldSelector ¶
type FieldSelector struct {
MatchExpressions []FieldSelectorRequirement
}
type HTTPOption ¶
type HTTPOption interface {
Apply(optsApplier HTTPOptionApplier)
}
type HTTPOptionApplier ¶
type Hook ¶
type Hook struct {
Config *HookConfig
ReconcileFunc ReconcileFunc
}
type HookConfig ¶
type HookConfig struct {
Metadata HookMetadata
Schedule []ScheduleConfig
Kubernetes []KubernetesConfig
// OnStartup runs hook on module/global startup
// Attention! During the startup you don't have snapshots available
// use native KubeClient to fetch resources
OnStartup *OrderedConfig
OnBeforeHelm *OrderedConfig
OnAfterHelm *OrderedConfig
OnAfterDeleteHelm *OrderedConfig
AllowFailure bool
Queue string
Settings *HookConfigSettings
}
func (*HookConfig) Validate ¶
func (cfg *HookConfig) Validate() error
type HookConfigSettings ¶
type HookInput ¶
type HookInput struct {
Snapshots Snapshots
Values OutputPatchableValuesCollector
ConfigValues OutputPatchableValuesCollector
PatchCollector OutputPatchCollector
MetricsCollector MetricsCollector
DC DependencyContainer
Logger Logger
}
type HookMetadata ¶
type KubernetesClient ¶
type KubernetesConfig ¶
type KubernetesConfig struct {
// Name is a key in snapshots map.
Name string
// APIVersion of objects. "v1" is used if not set.
APIVersion string
// Kind of objects.
Kind string
// NameSelector used to subscribe on object by its name.
NameSelector *NameSelector
// NamespaceSelector used to subscribe on objects in namespaces.
NamespaceSelector *NamespaceSelector
// LabelSelector used to subscribe on objects by matching their labels.
LabelSelector *metav1.LabelSelector
// FieldSelector used to subscribe on objects by matching specific fields (the list of fields is narrow, see shell-operator documentation).
FieldSelector *FieldSelector
// ExecuteHookOnEvents is true by default. Set to false if only snapshot update is needed.
ExecuteHookOnEvents *bool
// ExecuteHookOnSynchronization is true by default. Set to false if only snapshot update is needed.
ExecuteHookOnSynchronization *bool
// WaitForSynchronization is true by default. Set to false if beforeHelm is not required this snapshot on start.
WaitForSynchronization *bool
// JQ filter to filter results from kubernetes objects
JqFilter string
// Allow to fail hook
AllowFailure *bool
ResynchronizationPeriod string
}
func (*KubernetesConfig) Validate ¶
func (cfg *KubernetesConfig) Validate() error
you must test JqFilter by yourself
type KubernetesOption ¶
type KubernetesOption interface {
Apply(optsApplier KubernetesOptionApplier)
}
type KubernetesOptionApplier ¶
type KubernetesOptionApplier interface {
WithSchemeBuilder(builder runtime.SchemeBuilder)
}
type Logger ¶
type Logger interface {
Debug(msg string, args ...any)
DebugContext(ctx context.Context, msg string, args ...any)
Error(msg string, args ...any)
ErrorContext(ctx context.Context, msg string, args ...any)
Fatal(msg string, args ...any)
Info(msg string, args ...any)
InfoContext(ctx context.Context, msg string, args ...any)
Log(ctx context.Context, level slog.Level, msg string, args ...any)
LogAttrs(ctx context.Context, level slog.Level, msg string, attrs ...slog.Attr)
Warn(msg string, args ...any)
WarnContext(ctx context.Context, msg string, args ...any)
Enabled(ctx context.Context, level slog.Level) bool
With(args ...any) *log.Logger
WithGroup(name string) *log.Logger
Named(name string) *log.Logger
SetLevel(level log.Level)
SetOutput(w io.Writer)
GetLevel() log.Level
Handler() slog.Handler
}
type MetricCollectorOption ¶
type MetricCollectorOption interface {
Apply(op MetricCollectorOptionApplier)
}
type MetricCollectorOptionApplier ¶
type MetricCollectorOptionApplier interface {
WithGroup(group string)
}
type MetricsCollector ¶
type MetricsCollector interface {
// Inc increments the specified Counter metric
Inc(name string, labels map[string]string, opts ...MetricCollectorOption)
// Add adds custom value for the specified Counter metric
Add(name string, value float64, labels map[string]string, opts ...MetricCollectorOption)
// Set specifies the custom value for the Gauge metric
Set(name string, value float64, labels map[string]string, opts ...MetricCollectorOption)
// Expire marks metric's group as expired
Expire(group string)
}
type NameSelector ¶
type NameSelector struct {
MatchNames []string
}
func (*NameSelector) Validate ¶
func (cfg *NameSelector) Validate() error
type NamespaceSelector ¶
type NamespaceSelector struct {
NameSelector *NameSelector
LabelSelector *metav1.LabelSelector
}
func (*NamespaceSelector) Validate ¶
func (cfg *NamespaceSelector) Validate() error
type OrderedConfig ¶
type OrderedConfig struct {
Order uint
}
type OutputMetricsCollector ¶
type OutputMetricsCollector interface {
MetricsCollector
Outputer
}
type OutputPatchCollector ¶
type OutputPatchCollector interface {
// Deprecated: use PatchWithMerge instead
PatchCollector
Outputer
}
type OutputPatchableValuesCollector ¶
type OutputPatchableValuesCollector interface {
PatchableValuesCollector
Outputer
}
type PatchCollector ¶
type PatchCollector interface {
// object must be Unstructured, map[string]any or runtime.Object
Create(object any)
// object must be Unstructured, map[string]any or runtime.Object
CreateIfNotExists(object any)
// object must be Unstructured, map[string]any or runtime.Object
CreateOrUpdate(object any)
// The object exists in the key-value store until the garbage collector
// deletes all the dependents whose ownerReference.blockOwnerDeletion=true
// from the key-value store. API sever will put the "foregroundDeletion"
// finalizer on the object, and sets its deletionTimestamp. This policy is
// cascading, i.e., the dependents will be deleted with Foreground.
Delete(apiVersion string, kind string, namespace string, name string)
// Deletes the object from the key-value store, the garbage collector will
// delete the dependents in the background.
DeleteInBackground(apiVersion string, kind string, namespace string, name string)
// Orphans the dependents.
DeleteNonCascading(apiVersion string, kind string, namespace string, name string)
// Deprecated: use PatchWithJSON instead
JSONPatch(jsonPatch any, apiVersion string, kind string, namespace string, name string, opts ...PatchCollectorOption)
// Deprecated: use PatchWithMerge instead
MergePatch(mergePatch any, apiVersion string, kind string, namespace string, name string, opts ...PatchCollectorOption)
// Deprecated: use PatchWithJQ instead
JQFilter(jqfilter string, apiVersion string, kind string, namespace string, name string, opts ...PatchCollectorOption)
// JSONPatch is a PatchType indicating the patch should be interpreted as a RFC6902 JSON Patch.
// This patch format requires specifying operations, paths, and values explicitly.
// See https://tools.ietf.org/html/rfc6902 for details.
PatchWithJSON(jsonPatch any, apiVersion string, kind string, namespace string, name string, opts ...PatchCollectorOption)
// MergePatch is a PatchType indicating the patch should be interpreted as a RFC7396 JSON Merge Patch.
// This patch format replaces elements at the object level rather than requiring explicit operations.
// See https://tools.ietf.org/html/rfc7396 for details.
PatchWithMerge(mergePatch any, apiVersion string, kind string, namespace string, name string, opts ...PatchCollectorOption)
// Mutate object with jq query
PatchWithJQ(jqfilter string, apiVersion string, kind string, namespace string, name string, opts ...PatchCollectorOption)
Operations() []PatchCollectorOperation
}
type PatchCollectorOperation ¶
type PatchCollectorOperation interface {
Description() string
}
There are 4 types of operations:
- createOperation to create or update object via Create and Update API calls. Unstructured, map[string]any or runtime.Object is required.
- deleteOperation to delete object via Delete API call
- patchOperation to modify object via Patch API call
- filterOperation to modify object via Get-filter-Update process
type PatchCollectorOption ¶
type PatchCollectorOption interface {
Apply(PatchCollectorOptionApplier)
}
type ReconcileFunc ¶
ReconcileFunc function which holds the main logic of the hook
type RegistryClient ¶
type RegistryOption ¶
type RegistryOption interface {
Apply(optsApplier RegistryOptionApplier)
}
type RegistryOptionApplier ¶
type ScheduleConfig ¶
type ScheduleConfig struct {
Name string
// Crontab is a schedule config in crontab format. (5 or 6 fields)
Crontab string
}
func (*ScheduleConfig) Validate ¶
func (cfg *ScheduleConfig) Validate() error
Source Files
¶
Click to show internal directories.
Click to hide internal directories.