dockerprovider

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 20 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainerIDFromRecord

func ContainerIDFromRecord(containerID string) (string, error)

ContainerIDFromRecord returns the target container ID for exec/file ops.

func DefaultSocket

func DefaultSocket(platform string) string

DefaultSocket returns the default Engine socket path/URI for a platform.

func DialSSH

func DialSSH(hop SSHHop, defaultUser string) (*ssh.Client, func(), error)

DialSSH opens an SSH client using Honey's sshclient stack.

func DiscoverOnVMs

func DiscoverOnVMs(ctx context.Context, q hosts.Query, vms []hosts.Record) ([]hosts.Record, error)

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 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 hostexec.DockerBackendRuntime, opts APIClientOptions) (*client.Client, error)

NewAPIClientFromRuntime builds a client from hostexec runtime config.

func NormalizeMode

func NormalizeMode(mode string) string

NormalizeMode returns containers, swarm, or both.

func NormalizePlatform

func NormalizePlatform(p string) string

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 ResolveSocket

func ResolveSocket(socket, platform string) string

ResolveSocket returns configured socket or platform default.

func RunAsProxyCommandForTest

func RunAsProxyCommandForTest(runAs, socketPath string) string

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

type DialParams struct {
	Network string
	Address string
	HostURL string
}

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

type DiscoverOpts struct {
	Socket   string
	Platform string
	RunAs    string
}

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

func (d *Docker) BackendName() string

BackendName returns the optional YAML backends.docker[].name value.

func (*Docker) CacheIdentity

func (d *Docker) CacheIdentity() string

CacheIdentity scopes cache entries per docker backend configuration.

func (*Docker) ID

func (d *Docker) ID() string

ID returns the honey backend identifier ("docker").

func (*Docker) Search

func (d *Docker) Search(ctx context.Context, q hosts.Query) ([]hosts.Record, error)

Search lists containers and/or swarm tasks from the configured Engine endpoint.

type SSHHop

type SSHHop struct {
	Host         string
	Port         int
	User         string
	IdentityFile string
}

SSHHop is a resolved SSH target for Honey SSH transport to Docker.

func ResolveSSHHop

func ResolveSSHHop(bc BackendConfig, vm *hosts.Record) (SSHHop, bool, error)

ResolveSSHHop resolves SSH settings from backend config, optional local backends, or a VM record.

func (SSHHop) HopRecord

func (h SSHHop) HopRecord() hosts.Record

HopRecord builds a hosts.Record used for ClientCache key lookup.

func (SSHHop) RecordHostURI

func (h SSHHop) RecordHostURI() string

RecordHostURI returns a stable label stored on docker records.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL