Documentation
¶
Overview ¶
Package serviceclass provides Kubernetes CRD-based ServiceClass management with full lifecycle operations and status tracking.
Overview ¶
This package implements ServiceClass management using Kubernetes Custom Resource Definitions (CRDs). ServiceClasses define templates for creating and managing service instances with standardized lifecycle operations, health monitoring, and dependency management.
Architecture ¶
The package follows the muster API Service Locator Pattern:
- Adapter: Implements the ServiceClassManager interface from internal/api
- Client Integration: Uses the unified MusterClient interface for data access
- CRD Management: Handles Kubernetes ServiceClass resources with proper validation
- Status Tracking: Dynamically calculates tool availability and service readiness
Key Features ¶
- Complete CRUD operations for ServiceClass resources
- Dynamic tool availability checking and status population
- Kubernetes-native storage with CRD support
- Fallback to filesystem mode when CRDs are unavailable
- Comprehensive argument validation and templating support
- Health check configuration and monitoring
- Dependency resolution between ServiceClasses
Usage Example ¶
// Create and register the adapter
adapter, err := serviceclass.NewAdapter()
if err != nil {
log.Fatal("Failed to create ServiceClass adapter:", err)
}
defer adapter.Close()
// Register with the API layer (required by Service Locator Pattern)
adapter.Register()
// Access via API layer (recommended)
manager := api.GetServiceClassManager()
serviceClass, err := manager.GetServiceClass("my-service")
Type Conversions ¶
The package handles conversion between:
- Kubernetes CRD types (pkg/apis/muster/v1alpha1)
- Internal API types (internal/api)
- Raw YAML/JSON representations
Error Handling ¶
All operations return structured errors with proper context:
- ServiceClassNotFoundError: When a ServiceClass doesn't exist
- ValidationError: When ServiceClass definition is invalid
- KubernetesError: When underlying Kubernetes operations fail
Thread Safety ¶
The Adapter is thread-safe and can be used concurrently across multiple goroutines. The underlying Kubernetes client handles connection pooling and request management.
Performance Considerations ¶
- Status population happens on every read operation for accuracy - Tool availability is checked dynamically via the aggregator - Large ServiceClass lists are processed in batches where possible - Client connections are reused and properly managed
Package serviceclass provides ServiceClass management functionality.
Index ¶
- type Adapter
- func (a *Adapter) Close() error
- func (a *Adapter) ExecuteTool(ctx context.Context, toolName string, args map[string]interface{}) (*api.CallToolResult, error)
- func (a *Adapter) GetHealthCheckConfig(name string) (enabled bool, interval time.Duration, failureThreshold, successThreshold int, ...)
- func (a *Adapter) GetHealthCheckTool(name string) (toolName string, args map[string]interface{}, ...)
- func (a *Adapter) GetRestartTool(name string) (toolName string, args map[string]interface{}, outputs map[string]string, ...)
- func (a *Adapter) GetServiceClass(name string) (*api.ServiceClass, error)
- func (a *Adapter) GetServiceDependencies(name string) ([]string, error)
- func (a *Adapter) GetStartTool(name string) (toolName string, args map[string]interface{}, outputs map[string]string, ...)
- func (a *Adapter) GetStopTool(name string) (toolName string, args map[string]interface{}, outputs map[string]string, ...)
- func (a *Adapter) GetTools() []api.ToolMetadata
- func (a *Adapter) IsServiceClassAvailable(name string) bool
- func (a *Adapter) ListServiceClasses() []api.ServiceClass
- func (a *Adapter) Register()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter provides ServiceClass management functionality using the unified client
func NewAdapterWithClient ¶
func NewAdapterWithClient(musterClient client.MusterClient, namespace string) *Adapter
NewAdapterWithClient creates a new adapter with a specific client (for testing)
func (*Adapter) ExecuteTool ¶
func (a *Adapter) ExecuteTool(ctx context.Context, toolName string, args map[string]interface{}) (*api.CallToolResult, error)
ExecuteTool executes a tool by name
func (*Adapter) GetHealthCheckConfig ¶
func (*Adapter) GetHealthCheckTool ¶
func (*Adapter) GetRestartTool ¶
func (*Adapter) GetServiceClass ¶
func (a *Adapter) GetServiceClass(name string) (*api.ServiceClass, error)
GetServiceClass retrieves a specific ServiceClass by name
func (*Adapter) GetServiceDependencies ¶
func (*Adapter) GetStartTool ¶
func (a *Adapter) GetStartTool(name string) (toolName string, args map[string]interface{}, outputs map[string]string, err error)
Tool-specific getter methods for orchestrator compatibility
func (*Adapter) GetStopTool ¶
func (*Adapter) GetTools ¶
func (a *Adapter) GetTools() []api.ToolMetadata
GetTools returns all tools this provider offers
func (*Adapter) IsServiceClassAvailable ¶
IsServiceClassAvailable checks if a ServiceClass is available
func (*Adapter) ListServiceClasses ¶
func (a *Adapter) ListServiceClasses() []api.ServiceClass
ListServiceClasses returns all ServiceClasses with their status populated