Documentation
¶
Overview ¶
registration package for K8s client-go based tools/handlers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Execute ¶
func Execute(ctx context.Context, name string, clientset *kubernetes.Clientset, namespace string) (interface{}, error)
Executes a specific handler by name by implementing the core logic.
- Looks up handler by name using Get().
- Calls handler.Execute() with provided parameters.
Args:
ctx - Context for cancellation/timeout control.
name - Name of the handler to execute.
clientset - Kubernetes client for API interactions.
namespace - Target namespace for handler operations.
Returns:
- Handler output (interface{}) if execution succeeds.
- Error if handler is not found or fails during execution.
Security:
Ensure handler implementations avoid exposing sensitive
Kubernetes data (e.g., Secret contents, credentials).
func List ¶
Provides all registered handlers with their descriptions.
Safe concurrent access via read lock.
Returns: A map where with hey as handler name and value as handler description.
Use Case:Useful for dynamically discovering available handlers
(e.g., listing via CLI or API endpoints).
func Register ¶
func Register(handler Handler)
Adds a new handler implementation to the global registry. - Acquires write lock for thread-safe registration. - Panics if a handler with the same name already exists. - Logs registration success to standard output. - Safe — does not execute handler logic, only stores references.
Args:An instance implementing the Handler interface.
Types ¶
type Handler ¶
type Handler interface {
Name() string
Execute(ctx context.Context, clientset *kubernetes.Clientset, namespace string) (interface{}, error)
Description() string
}
Defines a standard contract for all handler implementations
that can be registered and executed via this registry.
Each handler must implement:
- Name() string → Returns a unique handler name.
- Description() string → Describes what the handler does.
- Execute(...) → Executes the handler logic.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Manages all registered handler instances and provides
thread-safe access and execution. Handlers can self-register
at package init time, allowing for modular and extensible system design.
Fields:
- handlers : Map of handler name → handler instance.
- mu : RWMutex for concurrency-safe access.
Click to show internal directories.
Click to hide internal directories.