Documentation
¶
Overview ¶
Package dockerprovider implements the honey Docker Engine search backend.
Search modes (YAML mode or --docker-mode): containers, swarm, or both. Results are hosts.Record rows with provider "docker" and meta.kind container or swarm_task.
Daemon connections:
- Local or DOCKER_HOST (unix://, tcp://, https:// with optional TLS paths in config)
- Moby ssh:// (Engine SDK SSH; no Honey ~/.ssh/config integration)
- Honey SSH: via_local / via_ssh + socket + optional run_as (sudo -n -u … + docker system dial-stdio over an sshclient session; reuses TUI SSH when cached)
Auto-discover registers with searchrun.RegisterDockerDiscover. When HONEY_FEATURE_DOCKER_VIA_PROVIDERS=1 and --docker-discover-providers are set, searchrun runs a second pass over VM records from the already-filtered search (respecting --backends and --provider) and merges container rows.
Execution (terminals, parallel e, web exec, file browser) is wired through hostexec.SetDockerExecutor in internal/ui; the Moby client is github.com/moby/moby/client (API types in github.com/moby/moby/api).
Index ¶
- func ContainerIDFromRecord(containerID string) (string, error)
- func DefaultSocket(platform string) string
- func DialDockerCheck(user string, r hosts.Record, reg hostexec.Registry) error
- func DialSSH(hop SSHHop, defaultUser string) (*ssh.Client, func(), error)
- func DiscoverOnVMs(ctx context.Context, q hosts.Query, vms []hosts.Record) ([]hosts.Record, error)
- func DockerInteractiveShellCmd(dc *DockerNativeClient) []string
- func DockerShellQuote(s string) string
- func EffectiveDockerSSHUser(user string, r hosts.Record) string
- func FeatureDockerViaProviders() bool
- func ListOptionsForBackend(all bool) client.ContainerListOptions
- func NewAPIClient(ctx context.Context, b BackendConfig, opts APIClientOptions) (*client.Client, error)
- func NewAPIClientFromRuntime(ctx context.Context, rt DockerBackendRuntime, opts APIClientOptions) (*client.Client, error)
- func NewFactory(interactive InteractiveRunner) searchrun.ProviderFactory
- func NormalizeMode(mode string) string
- func NormalizePlatform(p string) string
- func RecordMetaBase(bc BackendConfig, hop SSHHop, discover bool) map[string]string
- func RegisterFlags(cmd *cobra.Command)
- func ResolveSocket(socket, platform string) string
- func RunAsProxyCommandForTest(runAs, socketPath string) string
- func VMRecordForHoneyDocker(r hosts.Record) (hosts.Record, bool)
- type APIClientOptions
- type BackendConfig
- type DialParams
- type DiscoverOpts
- type Docker
- type DockerBackendRuntime
- type DockerExecutor
- func (e *DockerExecutor) Dial(user string, r hosts.Record) (hostexec.HostClient, error)
- func (e *DockerExecutor) DialDockerClient(user string, r hosts.Record) (*client.Client, error)
- func (e *DockerExecutor) DialUpstream(_ context.Context, user string, r hosts.Record, address string) (net.Conn, error)
- func (e *DockerExecutor) RunInteractive(user string, r hosts.Record) error
- func (e *DockerExecutor) RunTunnel(context.Context, string, hosts.Record, string, io.Writer) error
- type DockerNativeClient
- func (c *DockerNativeClient) Close() error
- func (c *DockerNativeClient) Download(remotePath, localPath string) error
- func (c *DockerNativeClient) ExecInteractive(ctx context.Context, cmd []string, execEnv []string, stdin io.Reader, ...) error
- func (c *DockerNativeClient) IsWindowsContainer() bool
- func (c *DockerNativeClient) ListRemoteDir(dir string) ([]hostexec.RemoteFileEntry, error)
- func (c *DockerNativeClient) MkdirAllRemote(remotePath string) error
- func (c *DockerNativeClient) RemoveRemote(remotePath string, recursive bool) error
- func (c *DockerNativeClient) Run(cmd string) ([]byte, error)
- func (c *DockerNativeClient) RunWithStreams(cmd string, stdin io.Reader, stdout, stderr io.Writer) error
- func (c *DockerNativeClient) StatRemote(remotePath string) (hostexec.RemoteFileEntry, error)
- func (c *DockerNativeClient) Upload(localPath, remotePath string) error
- type DockerTerminalSize
- type InteractiveRunner
- type SSHHop
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainerIDFromRecord ¶
ContainerIDFromRecord returns the target container ID for exec/file ops.
func DefaultSocket ¶
DefaultSocket returns the default Engine socket path/URI for a platform.
func DialDockerCheck ¶ added in v0.3.3
DialDockerCheck verifies that a docker record can reach the Engine API (dial + close).
func DiscoverOnVMs ¶
DiscoverOnVMs lists Docker containers on cloud VM records from an earlier search pass. VMs are already scoped by --backends / --provider filters on the parent search.
func DockerInteractiveShellCmd ¶ added in v0.3.3
func DockerInteractiveShellCmd(dc *DockerNativeClient) []string
DockerInteractiveShellCmd returns the shell command for an interactive session.
func DockerShellQuote ¶ added in v0.3.3
DockerShellQuote returns a shell-safe single-quoted form of s.
func EffectiveDockerSSHUser ¶ added in v0.3.3
EffectiveDockerSSHUser returns the SSH user for docker transport resolution.
func FeatureDockerViaProviders ¶
func FeatureDockerViaProviders() bool
FeatureDockerViaProviders reports whether auto-discover on cloud VMs is enabled.
func ListOptionsForBackend ¶
func ListOptionsForBackend(all bool) client.ContainerListOptions
ListOptionsForBackend returns container list options for search.
func NewAPIClient ¶
func NewAPIClient(ctx context.Context, b BackendConfig, opts APIClientOptions) (*client.Client, error)
NewAPIClient builds a Moby client for the given backend settings.
func NewAPIClientFromRuntime ¶
func NewAPIClientFromRuntime(ctx context.Context, rt DockerBackendRuntime, opts APIClientOptions) (*client.Client, error)
NewAPIClientFromRuntime builds a client from hostexec runtime config.
func NewFactory ¶ added in v0.3.4
func NewFactory(interactive InteractiveRunner) searchrun.ProviderFactory
NewFactory returns a new factory for this provider. interactive (implemented in the ui package) is injected so resolver-created executors can run TTY sessions.
func NormalizeMode ¶
NormalizeMode returns containers, swarm, or both.
func NormalizePlatform ¶
NormalizePlatform returns linux or windows.
func RecordMetaBase ¶
func RecordMetaBase(bc BackendConfig, hop SSHHop, discover bool) map[string]string
RecordMetaBase returns common docker record meta for a backend connection.
func RegisterFlags ¶ added in v0.3.3
RegisterFlags adds Docker CLI flags to cmd.
func ResolveSocket ¶
ResolveSocket returns configured socket or platform default.
func RunAsProxyCommandForTest ¶
RunAsProxyCommandForTest returns the remote command used for run_as dial (tests).
Types ¶
type APIClientOptions ¶
type APIClientOptions struct {
SSHUser string
BorrowedSSH *ssh.Client
OwnsSSH bool // if true, close SSH on client close
VMRecord *hosts.Record
DiscoverOpts *DiscoverOpts
}
APIClientOptions optional SSH borrow and user for honey-ssh transport.
type BackendConfig ¶
type BackendConfig struct {
Name string
Host string
ViaLocal string
ViaSSH config.DockerViaSSH
Socket string
Platform string
SSHUser string
RunAs string
LocalBackends []config.LocalBackend
Mode string
AllContainers bool
TLSVerify bool
CACert string
Cert string
Key string
}
BackendConfig is the runtime settings for one docker backend (search + dial).
func BackendConfigFromYAML ¶
func BackendConfigFromYAML(e config.DockerBackend, locals []config.LocalBackend, sshUser string) BackendConfig
BackendConfigFromYAML converts a config entry to BackendConfig.
func (BackendConfig) ResolvedHost ¶
func (b BackendConfig) ResolvedHost() string
ResolvedHost returns the host URI stored on records for Moby-direct backends.
func (BackendConfig) UsesHoneySSH ¶
func (b BackendConfig) UsesHoneySSH() bool
UsesHoneySSH reports whether this backend dials Docker via Honey SSH + remote socket.
type DialParams ¶
DialParams describes how to dial the remote Engine socket over SSH.
func SocketDialParams ¶
func SocketDialParams(socket, platform string) (DialParams, error)
SocketDialParams maps a socket URI and platform to SSH dial network/address and Moby host URL.
type DiscoverOpts ¶
DiscoverOpts configures auto-discovery pass (feature-flag only).
type Docker ¶
type Docker struct {
Config BackendConfig
}
Docker implements hosts.Backend for Engine API search (local, Moby ssh://, or Honey SSH).
func (*Docker) BackendName ¶
BackendName returns the optional YAML backends.docker[].name value.
func (*Docker) CacheIdentity ¶
CacheIdentity scopes cache entries per docker backend configuration.
type DockerBackendRuntime ¶ added in v0.3.3
type DockerBackendRuntime struct {
Name string
Host string
ViaLocal string
ViaSSH config.DockerViaSSH
Socket string
Platform string
RunAs string
Transport string
LocalBackends []config.LocalBackend
TLSVerify bool
CACert string
Cert string
Key string
}
DockerBackendRuntime holds Docker API connection settings.
func BackendByName ¶ added in v0.3.3
func BackendByName(name string) (DockerBackendRuntime, bool)
BackendByName returns runtime config for a named Docker backend (empty name matches first entry).
type DockerExecutor ¶ added in v0.3.3
type DockerExecutor struct {
// contains filtered or unexported fields
}
DockerExecutor implements hostexec.Executor for Docker containers.
func (*DockerExecutor) Dial ¶ added in v0.3.3
func (e *DockerExecutor) Dial(user string, r hosts.Record) (hostexec.HostClient, error)
Dial connects to the Docker container and returns a DockerNativeClient.
func (*DockerExecutor) DialDockerClient ¶ added in v0.3.4
DialDockerClient builds a moby client from record metadata (transport resolution).
func (*DockerExecutor) DialUpstream ¶ added in v0.3.3
func (e *DockerExecutor) DialUpstream(_ context.Context, user string, r hosts.Record, address string) (net.Conn, error)
DialUpstream connects to a port inside the container via nc/socat.
func (*DockerExecutor) RunInteractive ¶ added in v0.3.3
func (e *DockerExecutor) RunInteractive(user string, r hosts.Record) error
RunInteractive delegates to the injected InteractiveRunner.
type DockerNativeClient ¶ added in v0.3.3
DockerNativeClient implements hostexec.HostClient via the Docker Engine API.
func (*DockerNativeClient) Close ¶ added in v0.3.3
func (c *DockerNativeClient) Close() error
Close closes the underlying Docker client connection.
func (*DockerNativeClient) Download ¶ added in v0.3.3
func (c *DockerNativeClient) Download(remotePath, localPath string) error
Download copies a file from the container to localPath.
func (*DockerNativeClient) ExecInteractive ¶ added in v0.3.3
func (c *DockerNativeClient) ExecInteractive( ctx context.Context, cmd []string, execEnv []string, stdin io.Reader, stdout io.Writer, cols, rows int, resizeCh <-chan DockerTerminalSize, ) error
ExecInteractive runs a TTY exec with bidirectional I/O and optional resize events.
func (*DockerNativeClient) IsWindowsContainer ¶ added in v0.3.3
func (c *DockerNativeClient) IsWindowsContainer() bool
IsWindowsContainer reports whether the container runs Windows.
func (*DockerNativeClient) ListRemoteDir ¶ added in v0.3.3
func (c *DockerNativeClient) ListRemoteDir(dir string) ([]hostexec.RemoteFileEntry, error)
ListRemoteDir lists files in dir inside the container.
func (*DockerNativeClient) MkdirAllRemote ¶ added in v0.3.3
func (c *DockerNativeClient) MkdirAllRemote(remotePath string) error
MkdirAllRemote creates remotePath (and parents) inside the container.
func (*DockerNativeClient) RemoveRemote ¶ added in v0.3.3
func (c *DockerNativeClient) RemoveRemote(remotePath string, recursive bool) error
RemoveRemote deletes remotePath inside the container; recursive removes directories.
func (*DockerNativeClient) Run ¶ added in v0.3.3
func (c *DockerNativeClient) Run(cmd string) ([]byte, error)
Run executes cmd in the container and returns combined stdout.
func (*DockerNativeClient) RunWithStreams ¶ added in v0.3.3
func (c *DockerNativeClient) RunWithStreams(cmd string, stdin io.Reader, stdout, stderr io.Writer) error
RunWithStreams executes cmd in the container with the provided I/O streams.
func (*DockerNativeClient) StatRemote ¶ added in v0.3.3
func (c *DockerNativeClient) StatRemote(remotePath string) (hostexec.RemoteFileEntry, error)
StatRemote returns metadata for remotePath inside the container.
func (*DockerNativeClient) Upload ¶ added in v0.3.3
func (c *DockerNativeClient) Upload(localPath, remotePath string) error
Upload copies a local file into the container at remotePath.
type DockerTerminalSize ¶ added in v0.3.3
DockerTerminalSize is a cols/rows pair for docker exec resize.
type InteractiveRunner ¶ added in v0.3.4
type InteractiveRunner interface {
RunInteractive(user string, r hosts.Record, reg hostexec.Registry) error
}
InteractiveRunner runs an interactive TTY session against a Docker container. It is implemented in the ui package and injected via NewFactory to keep dockerprovider a leaf package (ui imports dockerprovider, not vice versa).
type SSHHop ¶
SSHHop is a resolved SSH target for Honey SSH transport to Docker.
func ResolveSSHHop ¶
ResolveSSHHop resolves SSH settings from backend config, optional local backends, or a VM record.
func (SSHHop) RecordHostURI ¶
RecordHostURI returns a stable label stored on docker records.