Documentation
¶
Overview ¶
Package shared provides shared utilities and base types for WhaleTUI.
Index ¶
- func TruncName(name string, maxLen int) string
- type BaseService
- type BaseView
- func (bv *BaseView[T]) ClearSearch()
- func (bv *BaseView[T]) GetHeaders() []string
- func (bv *BaseView[T]) GetItems() []T
- func (bv *BaseView[T]) GetSearchTerm() string
- func (bv *BaseView[T]) GetSelectedItem() *T
- func (bv *BaseView[T]) GetTable() *tview.Table
- func (bv *BaseView[T]) GetTitle() string
- func (bv *BaseView[T]) GetUI() SharedUIInterface
- func (bv *BaseView[T]) GetView() tview.Primitive
- func (bv *BaseView[T]) IsSearchActive() bool
- func (bv *BaseView[T]) Refresh()
- func (bv *BaseView[T]) RefreshFormatter(ui SharedUIInterface)
- func (bv *BaseView[T]) Search(searchTerm string)
- func (bv *BaseView[T]) SetColumnTypes(columnTypes []string)
- func (bv *BaseView[T]) SetFormatter(formatter *utils.TableFormatter)
- func (bv *BaseView[T]) SetItems(items []T)
- func (bv *BaseView[T]) ShowConfirmDialog(message string, onConfirm func())
- func (bv *BaseView[T]) ShowDetails(item T)
- func (bv *BaseView[T]) ShowItemDetails(item T, inspectData map[string]any, err error)
- type Commit
- type CommonOperations
- func (co *CommonOperations) AttachContainer(ctx context.Context, id string) (any, error)
- func (co *CommonOperations) ExecContainer(ctx context.Context, id string, command []string, tty bool) (string, error)
- func (co *CommonOperations) GetContainerLogs(ctx context.Context, id string) (string, error)
- func (co *CommonOperations) RemoveContainer(ctx context.Context, id string, force bool) error
- func (co *CommonOperations) RestartContainer(ctx context.Context, id string, timeout *time.Duration) error
- func (co *CommonOperations) StartContainer(ctx context.Context, id string) error
- func (co *CommonOperations) StopContainer(ctx context.Context, id string, timeout *time.Duration) error
- type Container
- type ContainerDetails
- type DockerInfo
- type DockerInfoService
- type IPAM
- type IPAMConfig
- type Image
- type ImageConfig
- type ImageDetails
- type ImageHistory
- type Mount
- type Network
- type NetworkContainer
- type NetworkDetails
- type NetworkSettings
- type Plugins
- type Port
- type ServiceFactoryInterface
- type SharedUIInterface
- type SwarmNode
- type SwarmService
- type Volume
- type VolumeDetails
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BaseService ¶
type BaseService[T any] struct { // Callbacks for specific behavior ListFunc func(*docker.Client, context.Context) ([]T, error) RemoveFunc func(*docker.Client, context.Context, string, bool) error InspectFunc func(*docker.Client, context.Context, string) (map[string]any, error) // contains filtered or unexported fields }
BaseService provides common functionality for all Docker resource services
func NewBaseService ¶
func NewBaseService[T any](client *docker.Client, resourceName string) *BaseService[T]
NewBaseService creates a new base service with common functionality
func (*BaseService[T]) List ¶
func (bs *BaseService[T]) List(ctx context.Context) ([]T, error)
List retrieves all resources using the provided list function
func (*BaseService[T]) ValidateClient ¶
func (bs *BaseService[T]) ValidateClient() error
ValidateClient checks if the Docker client is initialized
type BaseView ¶
type BaseView[T any] struct { // Callbacks for specific behavior ListItems func(ctx context.Context) ([]T, error) FormatRow func(item T) []string GetRowColor func(item T) tcell.Color // Optional: custom row colors GetItemID func(item T) string GetItemName func(item T) string HandleKeyPress func(key rune, item T) ShowDetailsCallback func(item T) GetActions func() map[rune]string // contains filtered or unexported fields }
BaseView provides common functionality for all Docker resource views
func NewBaseView ¶
func NewBaseView[T any](ui SharedUIInterface, viewName string, headers []string) *BaseView[T]
NewBaseView creates a new base view with common functionality
func (*BaseView[T]) ClearSearch ¶ added in v0.5.0
func (bv *BaseView[T]) ClearSearch()
ClearSearch clears the search and shows all items
func (*BaseView[T]) GetHeaders ¶
GetHeaders returns the table headers for testing purposes
func (*BaseView[T]) GetItems ¶
func (bv *BaseView[T]) GetItems() []T
GetItems returns the items for testing purposes
func (*BaseView[T]) GetSearchTerm ¶ added in v0.5.0
GetSearchTerm returns the current search term
func (*BaseView[T]) GetSelectedItem ¶
func (bv *BaseView[T]) GetSelectedItem() *T
GetSelectedItem returns the currently selected item from the table
func (*BaseView[T]) GetUI ¶
func (bv *BaseView[T]) GetUI() SharedUIInterface
GetUI returns the UI interface for this view
func (*BaseView[T]) IsSearchActive ¶ added in v0.5.0
IsSearchActive returns whether search is currently active
func (*BaseView[T]) Refresh ¶
func (bv *BaseView[T]) Refresh()
Refresh updates the view by fetching and displaying the latest items
func (*BaseView[T]) RefreshFormatter ¶ added in v0.3.0
func (bv *BaseView[T]) RefreshFormatter(ui SharedUIInterface)
RefreshFormatter updates the formatter with the latest theme configuration
func (*BaseView[T]) SetColumnTypes ¶ added in v0.3.0
SetColumnTypes sets the column types for character limit formatting
func (*BaseView[T]) SetFormatter ¶ added in v0.3.0
func (bv *BaseView[T]) SetFormatter(formatter *utils.TableFormatter)
SetFormatter sets the table formatter for character limits
func (*BaseView[T]) SetItems ¶ added in v0.5.1
func (bv *BaseView[T]) SetItems(items []T)
SetItems sets the items for testing purposes
func (*BaseView[T]) ShowConfirmDialog ¶
ShowConfirmDialog displays a confirmation dialog with the given message and callback
func (*BaseView[T]) ShowDetails ¶
func (bv *BaseView[T]) ShowDetails(item T)
ShowDetails shows details for the selected item
type CommonOperations ¶
type CommonOperations struct {
// contains filtered or unexported fields
}
CommonOperations provides reusable Docker operations
func NewCommonOperations ¶
func NewCommonOperations(client *docker.Client) *CommonOperations
NewCommonOperations creates a new common operations helper
func (*CommonOperations) AttachContainer ¶
AttachContainer is a reusable attach operation
func (*CommonOperations) ExecContainer ¶
func (co *CommonOperations) ExecContainer( ctx context.Context, id string, command []string, tty bool, ) (string, error)
ExecContainer is a reusable exec operation
func (*CommonOperations) GetContainerLogs ¶
GetContainerLogs is a reusable logs operation
func (*CommonOperations) RemoveContainer ¶
RemoveContainer is a reusable remove operation
func (*CommonOperations) RestartContainer ¶
func (co *CommonOperations) RestartContainer( ctx context.Context, id string, timeout *time.Duration, ) error
RestartContainer is a reusable restart operation
func (*CommonOperations) StartContainer ¶
func (co *CommonOperations) StartContainer(ctx context.Context, id string) error
StartContainer is a reusable start operation
func (*CommonOperations) StopContainer ¶
func (co *CommonOperations) StopContainer( ctx context.Context, id string, timeout *time.Duration, ) error
StopContainer is a reusable stop operation
type Container ¶
type Container struct {
ID string `json:"id"`
Name string `json:"name"`
Image string `json:"image"`
Status string `json:"status"`
Created time.Time `json:"created"`
Ports []string `json:"ports"`
SizeRw int64 `json:"size_rw"`
SizeRootFs int64 `json:"size_root_fs"`
Labels map[string]string `json:"labels"`
State string `json:"state"`
NetworkMode string `json:"network_mode"`
Mounts []string `json:"mounts"`
}
Container represents a Docker container
type ContainerDetails ¶
type ContainerDetails struct {
Container
Command string `json:"command"`
Args []string `json:"args"`
WorkingDir string `json:"working_dir"`
Entrypoint []string `json:"entrypoint"`
Environment []string `json:"environment"`
Labels map[string]string `json:"labels"`
Mounts []Mount `json:"mounts"`
NetworkSettings NetworkSettings `json:"network_settings"`
}
ContainerDetails represents detailed container information
type DockerInfo ¶
type DockerInfo struct {
Containers int `json:"containers"`
Images int `json:"images"`
Volumes int `json:"volumes"`
Networks int `json:"networks"`
Version string `json:"version"`
APIVersion string `json:"api_version"`
OS string `json:"os"`
Architecture string `json:"architecture"`
KernelVersion string `json:"kernel_version"`
GoVersion string `json:"go_version"`
Driver string `json:"driver"`
DriverStatus [][]string `json:"driver_status"`
Plugins Plugins `json:"plugins"`
MemoryLimit bool `json:"memory_limit"`
SwapLimit bool `json:"swap_limit"`
KernelMemory bool `json:"kernel_memory"`
CPUCfsQuota bool `json:"cpu_cfs_quota"`
CPUCfsPeriod bool `json:"cpu_cfs_period"`
CPUSet bool `json:"cpu_set"`
IPv4Forwarding bool `json:"ipv4_forwarding"`
BridgeNfIptables bool `json:"bridge_nf_iptables"`
BridgeNfIP6tables bool `json:"bridge_nf_ip6tables"`
Debug bool `json:"debug"`
NFd int `json:"nfd"`
NGoroutines int `json:"ngoroutines"`
SystemTime string `json:"system_time"`
LoggingDriver string `json:"logging_driver"`
CgroupDriver string `json:"cgroup_driver"`
OperatingSystem string `json:"operating_system"`
OSType string `json:"os_type"`
IndexServerAddress string `json:"index_server_address"`
RegistryConfigs map[string]any `json:"registry_configs"`
InsecureRegistries []string `json:"insecure_registries"`
RegistryMirrors []string `json:"registry_mirrors"`
Experimental bool `json:"experimental"`
ServerVersion string `json:"server_version"`
ClusterStore string `json:"cluster_store"`
ClusterAdvertise string `json:"cluster_advertise"`
DefaultRuntime string `json:"default_runtime"`
LiveRestoreEnabled bool `json:"live_restore_enabled"`
Isolation string `json:"isolation"`
InitBinary string `json:"init_binary"`
ContainerdCommit Commit `json:"containerd_commit"`
RuncCommit Commit `json:"runc_commit"`
InitCommit Commit `json:"init_commit"`
SecurityOptions []string `json:"security_options"`
ProductLicense string `json:"product_license"`
Warnings []string `json:"warnings"`
ConnectionMethod string `json:"connection_method"`
}
DockerInfo represents Docker system information
func (*DockerInfo) GetConnectionMethod ¶ added in v0.4.0
func (d *DockerInfo) GetConnectionMethod() string
GetConnectionMethod returns the connection method used
func (*DockerInfo) GetLoggingDriver ¶ added in v0.4.0
func (d *DockerInfo) GetLoggingDriver() string
GetLoggingDriver returns the logging driver
func (*DockerInfo) GetOperatingSystem ¶ added in v0.4.0
func (d *DockerInfo) GetOperatingSystem() string
GetOperatingSystem returns the operating system
func (*DockerInfo) GetVersion ¶ added in v0.4.0
func (d *DockerInfo) GetVersion() string
GetVersion returns the Docker version
type DockerInfoService ¶
type DockerInfoService interface {
GetDockerInfo(ctx context.Context) (*DockerInfo, error)
}
DockerInfoService defines the interface for Docker system information
func NewDockerInfoService ¶
func NewDockerInfoService(client *docker.Client) DockerInfoService
NewDockerInfoService creates a new Docker info service
type IPAM ¶
type IPAM struct {
Driver string `json:"driver"`
Options map[string]string `json:"options"`
Config []IPAMConfig `json:"config"`
}
IPAM represents IP Address Management configuration
type IPAMConfig ¶
type IPAMConfig struct {
Subnet string `json:"subnet"`
IPRange string `json:"ip_range"`
Gateway string `json:"gateway"`
}
IPAMConfig represents IPAM configuration
type Image ¶
type Image struct {
ID string `json:"id"`
RepoTags []string `json:"repo_tags"`
Created time.Time `json:"created"`
Size string `json:"size"`
VirtualSize int64 `json:"virtual_size"`
Labels map[string]string `json:"labels"`
ParentID string `json:"parent_id"`
}
Image represents a Docker image
type ImageConfig ¶
type ImageConfig struct {
User string `json:"user"`
WorkingDir string `json:"working_dir"`
Entrypoint []string `json:"entrypoint"`
Cmd []string `json:"cmd"`
Environment []string `json:"environment"`
ExposedPorts map[string]struct{} `json:"exposed_ports"`
Volumes map[string]struct{} `json:"volumes"`
Labels map[string]string `json:"labels"`
}
ImageConfig represents image configuration
type ImageDetails ¶
type ImageDetails struct {
Image
Architecture string `json:"architecture"`
OS string `json:"os"`
Author string `json:"author"`
Comment string `json:"comment"`
Config ImageConfig `json:"config"`
History []ImageHistory `json:"history"`
Labels map[string]string `json:"labels"`
}
ImageDetails represents detailed image information
type ImageHistory ¶
type ImageHistory struct {
Created time.Time `json:"created"`
CreatedBy string `json:"created_by"`
Comment string `json:"comment"`
EmptyLayer bool `json:"empty_layer"`
}
ImageHistory represents image layer history
type Mount ¶
type Mount struct {
Type string `json:"type"`
Source string `json:"source"`
Destination string `json:"destination"`
ReadOnly bool `json:"read_only"`
}
Mount represents a container mount
type Network ¶
type Network struct {
ID string `json:"id"`
Name string `json:"name"`
Driver string `json:"driver"`
Scope string `json:"scope"`
IPAM IPAM `json:"ipam"`
Internal bool `json:"internal"`
Attachable bool `json:"attachable"`
Ingress bool `json:"ingress"`
EnableIPv6 bool `json:"enable_ipv6"`
Options map[string]string `json:"options"`
Labels map[string]string `json:"labels"`
Created time.Time `json:"created"`
}
Network represents a Docker network
type NetworkContainer ¶
type NetworkContainer struct {
Name string `json:"name"`
EndpointID string `json:"endpoint_id"`
MacAddress string `json:"mac_address"`
IPv4Address string `json:"ipv4_address"`
IPv6Address string `json:"ipv6_address"`
Labels map[string]string `json:"labels"`
NetworkID string `json:"network_id"`
DriverOpts map[string]string `json:"driver_opts"`
IPAMConfig map[string]string `json:"ipam_config"`
}
NetworkContainer represents a container in a network
type NetworkDetails ¶
type NetworkDetails struct {
Network
Containers map[string]NetworkContainer `json:"containers"`
}
NetworkDetails represents detailed network information
type NetworkSettings ¶
type NetworkSettings struct {
IPAddress string `json:"ip_address"`
Gateway string `json:"gateway"`
Ports map[string][]Port `json:"ports"`
Networks map[string]Network `json:"networks"`
}
NetworkSettings represents container network configuration
type Plugins ¶
type Plugins struct {
Volume []string `json:"volume"`
Network []string `json:"network"`
Authorization []string `json:"authorization"`
Log []string `json:"log"`
}
Plugins represents Docker plugins information
type ServiceFactoryInterface ¶
type ServiceFactoryInterface interface {
GetContainerService() any
GetImageService() any
GetVolumeService() any
GetNetworkService() any
GetDockerInfoService() any
GetLogsService() any
GetSwarmServiceService() any
GetSwarmNodeService() any
GetCurrentService() any
SetCurrentService(serviceName string)
IsServiceAvailable(serviceName string) bool
IsContainerServiceAvailable() bool
}
ServiceFactoryInterface defines minimal interface for services
type SharedUIInterface ¶ added in v0.5.0
type SharedUIInterface interface {
// Basic UI methods
// Advanced UI methods
// Service methods
GetThemeManager() *config.ThemeManager
}
SharedUIInterface defines the interface that views need from the UI
type SwarmNode ¶
type SwarmNode struct {
ID string
Hostname string
Role string // manager or worker
Availability string // active, pause, drain
Status string // ready, down, unknown
ManagerStatus string // leader, reachable, unreachable (for manager nodes)
EngineVersion string
Address string
CPUs int64
Memory int64
Labels map[string]string
}
SwarmNode represents a Docker Swarm node
type SwarmService ¶
type SwarmService struct {
ID string
Name string
Image string
Mode string // replicated or global
Replicas string // e.g., "3/3" for replicated, "global" for global
Ports []string
CreatedAt time.Time
UpdatedAt time.Time
Status string // running, updating, failed, etc.
}
SwarmService represents a Docker Swarm service
type Volume ¶
type Volume struct {
Name string `json:"name"`
Driver string `json:"driver"`
Mountpoint string `json:"mountpoint"`
CreatedAt time.Time `json:"created_at"`
Status map[string]any `json:"status"`
Labels map[string]string `json:"labels"`
Scope string `json:"scope"`
Size string `json:"size"`
}
Volume represents a Docker volume
type VolumeDetails ¶
VolumeDetails represents detailed volume information
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package interfaces provides shared interface definitions for WhaleTUI.
|
Package interfaces provides shared interface definitions for WhaleTUI. |