Documentation
¶
Index ¶
- Variables
- func GetDefaultClient() (client.APIClient, error)
- func GetDefaultClientWithContext(ctx context.Context) (client.APIClient, error)
- func NewBackendService(manager Manager, logger logger.Logger) compute.BackendService
- func SetDefaultManager(m Manager)
- type BackendService
- func (s *BackendService) Create(ctx context.Context, req compute.ComputeInstanceRequest) (*compute.ComputeInstance, error)
- func (s *BackendService) Delete(ctx context.Context, id string, force bool) error
- func (s *BackendService) Get(ctx context.Context, id string) (*compute.ComputeInstance, error)
- func (s *BackendService) GetBackendInfo(ctx context.Context) (*compute.BackendInfo, error)
- func (s *BackendService) GetBackendType() compute.ComputeBackend
- func (s *BackendService) GetResourceUsage(ctx context.Context, id string) (*compute.ResourceUsage, error)
- func (s *BackendService) GetSupportedInstanceTypes() []compute.ComputeInstanceType
- func (s *BackendService) List(ctx context.Context, opts compute.ComputeInstanceListOptions) ([]*compute.ComputeInstance, error)
- func (s *BackendService) Pause(ctx context.Context, id string) error
- func (s *BackendService) Restart(ctx context.Context, id string, force bool) error
- func (s *BackendService) Start(ctx context.Context, id string) error
- func (s *BackendService) Stop(ctx context.Context, id string, force bool) error
- func (s *BackendService) Unpause(ctx context.Context, id string) error
- func (s *BackendService) Update(ctx context.Context, id string, update compute.ComputeInstanceUpdate) (*compute.ComputeInstance, error)
- func (s *BackendService) UpdateResourceLimits(ctx context.Context, id string, resources compute.ComputeResources) error
- func (s *BackendService) ValidateConfig(ctx context.Context, config compute.ComputeInstanceConfig) error
- type ClientConfig
- type ClientManager
- func (m *ClientManager) Close() error
- func (m *ClientManager) GetClient() (client.APIClient, error)
- func (m *ClientManager) GetConfig() ClientConfig
- func (m *ClientManager) GetWithContext(ctx context.Context) (client.APIClient, error)
- func (m *ClientManager) IsClosed() bool
- func (m *ClientManager) IsInitialized() bool
- func (m *ClientManager) Ping(ctx context.Context) (types.Ping, error)
- type ClientOption
- func WithAPIVersion(version string) ClientOption
- func WithHost(host string) ClientOption
- func WithLogger(logger logger.Logger) ClientOption
- func WithRequestTimeout(timeout time.Duration) ClientOption
- func WithRetry(count int, delay time.Duration) ClientOption
- func WithTLSConfig(certPath, keyPath, caPath string) ClientOption
- func WithTLSVerify(verify bool) ClientOption
- type Manager
Constants ¶
This section is empty.
Variables ¶
var ( ErrNilOption = errors.New("nil option provided to client configuration") ErrInvalidHost = errors.New("invalid Docker host specification") ErrMissingTLSConfig = errors.New("TLS verification enabled but certificate paths not provided") ErrInvalidTLSCert = errors.New("invalid or inaccessible TLS certificate") ErrInvalidTLSKey = errors.New("invalid or inaccessible TLS key") ErrInvalidTLSCA = errors.New("invalid or inaccessible TLS CA certificate") ErrConnectionFailed = errors.New("failed to connect to Docker daemon") ErrClientNotInitialized = errors.New("Docker client not initialized") ErrClientClosed = errors.New("Docker client manager has been closed") ErrInvalidAPIVersion = errors.New("invalid Docker API version format") ErrContextCanceled = errors.New("context was canceled while operating Docker client") ErrEmptyOption = errors.New("empty value provided for required option") ErrTLSConfigValidation = errors.New("TLS configuration validation failed") ErrCertificateExpired = errors.New("TLS certificate has expired") ErrCertificateNotYetValid = errors.New("TLS certificate is not yet valid") )
Common errors with detailed descriptions for better error handling.
Functions ¶
func GetDefaultClient ¶
GetDefaultClient returns a client from the default manager.
func GetDefaultClientWithContext ¶
GetDefaultClientWithContext returns a client from the default manager with context.
func NewBackendService ¶
func NewBackendService(manager Manager, logger logger.Logger) compute.BackendService
NewBackendService creates a new Docker backend service.
func SetDefaultManager ¶
func SetDefaultManager(m Manager)
SetDefaultManager sets the default manager instance.
Types ¶
type BackendService ¶
type BackendService struct {
// contains filtered or unexported fields
}
BackendService implements the compute.BackendService interface for Docker.
func (*BackendService) Create ¶
func (s *BackendService) Create(ctx context.Context, req compute.ComputeInstanceRequest) (*compute.ComputeInstance, error)
Create creates a new Docker container.
func (*BackendService) Get ¶
func (s *BackendService) Get(ctx context.Context, id string) (*compute.ComputeInstance, error)
Get retrieves a Docker container by ID.
func (*BackendService) GetBackendInfo ¶
func (s *BackendService) GetBackendInfo(ctx context.Context) (*compute.BackendInfo, error)
GetBackendInfo returns information about the Docker backend.
func (*BackendService) GetBackendType ¶
func (s *BackendService) GetBackendType() compute.ComputeBackend
GetBackendType returns the backend type.
func (*BackendService) GetResourceUsage ¶
func (s *BackendService) GetResourceUsage(ctx context.Context, id string) (*compute.ResourceUsage, error)
GetResourceUsage gets current resource usage for a container.
func (*BackendService) GetSupportedInstanceTypes ¶
func (s *BackendService) GetSupportedInstanceTypes() []compute.ComputeInstanceType
GetSupportedInstanceTypes returns supported instance types.
func (*BackendService) List ¶
func (s *BackendService) List(ctx context.Context, opts compute.ComputeInstanceListOptions) ([]*compute.ComputeInstance, error)
List retrieves Docker containers based on options.
func (*BackendService) Pause ¶
func (s *BackendService) Pause(ctx context.Context, id string) error
Pause pauses a Docker container.
func (*BackendService) Start ¶
func (s *BackendService) Start(ctx context.Context, id string) error
Start starts a Docker container.
func (*BackendService) Unpause ¶
func (s *BackendService) Unpause(ctx context.Context, id string) error
Unpause unpauses a Docker container.
func (*BackendService) Update ¶
func (s *BackendService) Update(ctx context.Context, id string, update compute.ComputeInstanceUpdate) (*compute.ComputeInstance, error)
Update updates a Docker container.
func (*BackendService) UpdateResourceLimits ¶
func (s *BackendService) UpdateResourceLimits(ctx context.Context, id string, resources compute.ComputeResources) error
UpdateResourceLimits updates resource limits for a container.
func (*BackendService) ValidateConfig ¶
func (s *BackendService) ValidateConfig(ctx context.Context, config compute.ComputeInstanceConfig) error
ValidateConfig validates a compute instance configuration for Docker.
type ClientConfig ¶
type ClientConfig struct {
Logger logger.Logger
Headers map[string]string
DialContext func(ctx context.Context, network, addr string) (net.Conn, error)
Host string
APIVersion string
TLSCertPath string
TLSKeyPath string
TLSCAPath string
TLSCipherSuites []uint16
KeepAlive time.Duration
MaxIdleConns int
TLSHandshakeTimeout time.Duration
ConnectionTimeout time.Duration
IdleConnTimeout time.Duration
ResponseHeaderTimeout time.Duration
ExpectContinueTimeout time.Duration
PingTimeout time.Duration
RetryDelay time.Duration
ConnectionIdleTimeout time.Duration
MaxIdleConnsPerHost int
MaxConnsPerHost int
RetryCount int
RequestTimeout time.Duration
TLSMinVersion uint16
TLSMaxVersion uint16
TLSVerify bool
TLSPreferServerCipherSuites bool
}
ClientConfig represents the configuration for the Docker client.
func DefaultClientConfig ¶
func DefaultClientConfig() ClientConfig
DefaultClientConfig returns the default client configuration.
type ClientManager ¶
type ClientManager struct {
// contains filtered or unexported fields
}
ClientManager manages Docker clients.
func NewManager ¶
func NewManager(opts ...ClientOption) (*ClientManager, error)
NewManager creates a new Docker client manager.
func (*ClientManager) Close ¶
func (m *ClientManager) Close() error
Close closes the managed Docker client.
func (*ClientManager) GetClient ¶
func (m *ClientManager) GetClient() (client.APIClient, error)
GetClient returns a thread-safe Docker API client wrapper.
func (*ClientManager) GetConfig ¶
func (m *ClientManager) GetConfig() ClientConfig
GetConfig returns a copy of the current client configuration.
func (*ClientManager) GetWithContext ¶
GetWithContext returns a thread-safe Docker API client wrapper with context.
func (*ClientManager) IsClosed ¶
func (m *ClientManager) IsClosed() bool
IsClosed checks if the client manager has been closed.
func (*ClientManager) IsInitialized ¶
func (m *ClientManager) IsInitialized() bool
IsInitialized checks if the client manager has successfully initialized.
type ClientOption ¶
type ClientOption func(*ClientConfig) error
ClientOption represents a functional option for configuring the Docker client.
func WithAPIVersion ¶
func WithAPIVersion(version string) ClientOption
WithAPIVersion sets the Docker API version.
func WithRequestTimeout ¶
func WithRequestTimeout(timeout time.Duration) ClientOption
WithRequestTimeout sets the request timeout.
func WithRetry ¶
func WithRetry(count int, delay time.Duration) ClientOption
WithRetry sets retry parameters.
func WithTLSConfig ¶
func WithTLSConfig(certPath, keyPath, caPath string) ClientOption
WithTLSConfig sets the complete TLS configuration.
func WithTLSVerify ¶
func WithTLSVerify(verify bool) ClientOption
WithTLSVerify enables TLS verification.
type Manager ¶
type Manager interface {
// GetClient returns a thread-safe Docker API client wrapper
GetClient() (client.APIClient, error)
// GetWithContext returns a thread-safe Docker API client wrapper with the specified context
GetWithContext(ctx context.Context) (client.APIClient, error)
// Ping checks the connectivity with the Docker daemon
Ping(ctx context.Context) (types.Ping, error)
// Close closes all clients and releases resources
Close() error
// IsInitialized checks if the client is initialized
IsInitialized() bool
// IsClosed checks if the client is closed
IsClosed() bool
// GetConfig returns the client configuration
GetConfig() ClientConfig
}
Manager is the interface for Docker client operations.
func DefaultManager ¶
func DefaultManager() Manager
DefaultManager returns the singleton manager instance.