containerui

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package containerui is the part of the Docker and Podman extensions that is the same for both (SPEC §10.20, step 18.2): the side bar view with its sections (Containers grouped by Compose project, Images by repository, Networks, Volumes and, for Docker, Contexts), the actions of the items, the logs in a panel tab, the documents (inspect, history, files of a container) in editor tabs, the form that runs an image, the confirmations before anything is removed, and the view that says an engine is missing. It talks to the engine through containerapi and to Emetos through the extension API only.

An extension is made of a Config: New(cfg) is its extension.Extension. extensions/containers (Docker) is the first user; Podman (step 18.4) is the second and adds its Pods and Connections through the same Config.

Ported from vscode-containers (Container Tools, MIT): the view containers and the order of the sections (package.json contributes.views), the titles and ids of the commands (contributes.commands, with the prefix of the extension in place of vscode-containers), the menus of the items (menus view/item/context and view/title), the labels, descriptions and state icons of the tree items (src/tree/containers, images, networks, volumes and contexts) and the texts of the confirmations (src/commands). Not built: the registries view, the properties that configure the explorer, the tooltips, the outdated-image check, Azure, Copilot and the walkthrough.

The threads: Activate, the command handlers, the callbacks of the API and Build run on the UI thread, where every field of the extension is used. The goroutines (the connection, the lists, the event stream, the logs, exec, pulls) hand their results to the UI thread with API.Post.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainersListed

func ContainersListed(x extension.Extension) bool

ContainersListed tells whether the extension made by New has read the list of containers from its engine. It is for the tests of other packages that need the extension to know its containers before they run a command on one (the tests of Connect to Database, SPEC §10.24); call it on the UI thread, which in a test is the goroutine that pumps the fake API.

func IsDatabaseImage

func IsDatabaseImage(image string) bool

IsDatabaseImage tells whether an image is one the database extensions know (a menu item is offered for such containers only).

func Manifest

func Manifest(cfg Config) extension.Manifest

Manifest declares what the extension of a Config contributes: the view container with its sections, the panel view for the logs, the editor kinds, the commands with their palette entries and the actions in the headers of the views.

func New

func New(cfg Config) extension.Extension

New returns the Factory-made extension of a Config.

Types

type Config

type Config struct {
	// Kind is the engine, containerapi.KindDocker or containerapi.KindPodman.
	Kind containerapi.Kind
	// ID is the id of the extension (emetos.containers); the ids of its container, views, editor kind and context keys start
	// with it.
	ID string
	// Name is the name of the extension on the Extensions page and of the view container ("Containers"), Engine the name of the
	// engine in texts ("Docker").
	Name, Engine string
	// Description says in one sentence what the extension does.
	Description string
	// Prefix starts the ids of the commands and of the settings: containers (containers.containers.start, containers.host).
	Prefix string
	// Icon is the Codicon of the icon in the activity bar, Order its place there.
	Icon  string
	Order int
	// Contexts adds the Contexts section and the context picker (Docker).
	Contexts bool
	// Pods adds what only Podman has (step 18.4): the Pods section, the containers grouped under their pod, the commands on pods,
	// Generate Kube YAML, Play Kube, Kube Down and Generate Quadlet. Connections adds the Connections section and its picker
	// (`podman system connection list`).
	Pods, Connections bool
	// MenuTitlePrefix starts the title of the items this extension adds to the Explorer and editor menus ("Podman: "), so that two
	// container extensions that offer the same command on a Dockerfile can be told apart in the menu. Empty adds nothing.
	MenuTitlePrefix string
	// FirstRunNote is the note at the top of the Containers section until the user dismisses it: what the access to the engine
	// means.
	FirstRunNote string
	// ListFilters narrow what the views list: the engine does the filtering, so the extension never sees the rest. A test against the
	// user's own engine lists only what it made itself (the label dev.emetos.test=1); a normal extension has none.
	ListFilters ListFilters
	// CLI is the command line program that Build Image, Push and Compose run (docker, podman); empty is the one of Kind.
	CLI string
	// ComposeFallback is the stand-alone Compose program used when CLI has no compose command (docker-compose, podman-compose);
	// empty is the one of Kind.
	ComposeFallback string
	// LanguageServers declares the language servers of the Dockerfile and Compose languages (step 18.3) when they are found on
	// PATH. DockerfileServer and ComposeServer are their programs (docker-langserver, docker-compose-langserver) and are only
	// changed by tests.
	LanguageServers                 bool
	DockerfileServer, ComposeServer string
	// LookPath finds a program on PATH; nil is exec.LookPath. A test gives one that finds its fake programs.
	LookPath func(name string) (string, error)
	// Environ is the environment the programs run in; nil is os.Environ().
	Environ func() []string
	// Dial finds the engine; nil is containerapi.Find.
	Dial DialFunc
	// Getenv reads the environment for Find; nil is os.Getenv. A test passes a map.
	Getenv func(string) string
	// Debounce is how long the refresh waits after an event of the engine so that a burst of them is one refresh; 0 is 150 ms.
	Debounce time.Duration
	// EventsRetry is how long the extension waits before it opens a lost event stream again; 0 is one second.
	EventsRetry time.Duration
	// Now is the clock the ages are counted from; nil is time.Now.
	Now func() time.Time
}

Config says what an extension that uses this package is: which engine, which ids and which sections.

func (Config) BuildFinishedTopic

func (c Config) BuildFinishedTopic() string

BuildFinishedTopic is the topic of the event published when a build ended: {image, ok}.

func (Config) ChangedTopic

func (c Config) ChangedTopic() string

ChangedTopic is the topic of the event published after a refresh that changed something.

func (Config) Command

func (c Config) Command(name string) string

Command is the id of a command of the extension: Command("containers.start") is containers.containers.start for Docker.

func (Config) ComposeServerPathSetting

func (c Config) ComposeServerPathSetting() string

ComposeServerPathSetting is the key of the setting that holds the path of the Compose language server.

func (Config) ConnectDatabaseTopic

func (c Config) ConnectDatabaseTopic() string

ConnectDatabaseTopic is the topic of the event Connect to Database publishes: the id of the extension and ".connectDatabase" (emetos.containers.connectDatabase, emetos.podman.connectDatabase).

func (Config) ContainerID

func (c Config) ContainerID() string

ContainerID is the id of the view container of the side bar.

func (Config) DockerfileServerPathSetting

func (c Config) DockerfileServerPathSetting() string

DockerfileServerPathSetting and ComposeServerPathSetting are the keys of the settings that hold the path of the language servers.

func (Config) DocumentKind

func (c Config) DocumentKind() string

DocumentKind is the id of the editor kind that shows a read-only text (inspect, history, a file of a container).

func (Config) HostSetting

func (c Config) HostSetting() string

HostSetting is the key of the setting that names the engine.

func (Config) LogsViewID

func (c Config) LogsViewID() string

LogsViewID is the id of the panel view that shows the logs and the output of commands.

func (Config) RunKind

func (c Config) RunKind() string

RunKind is the id of the editor kind of the form that runs an image.

func (Config) ViewID

func (c Config) ViewID(section string) string

ViewID is the id of the view of a section.

type DatabaseTarget

type DatabaseTarget struct {
	// Engine is the id of the engine: postgres, mysql (also for MariaDB), sqlserver, mongodb or redis (also for Valkey).
	Engine string `json:"engine"`
	// Name is the name of the container, which names the connection.
	Name string `json:"name"`
	// Host and Port are where the server's port is published.
	Host string `json:"host"`
	Port int    `json:"port"`
	// User and Database are the user and the database the image creates; empty when the image has no such thing.
	User     string `json:"user,omitempty"`
	Database string `json:"database,omitempty"`
}

DatabaseTarget is the payload of the event: the engine of the database extensions and where and as whom to connect.

func DatabaseTargetOf

func DatabaseTargetOf(info *containerapi.ContainerInspect, engineHost string) (DatabaseTarget, error)

DatabaseTargetOf makes the target of Connect to Database from the inspect of a container. engineHost is the host of the engine when it is on another computer (tcp://), else empty: a port published on every address is reached there, otherwise on this computer's loopback address. It fails with ContainerUIDatabaseImageUnknown (the image is none of SPEC §10.24's), ContainerUIDatabaseNotRunning and ContainerUIDatabasePortNotPublished (the server's port is not published on the host).

type DialFunc

type DialFunc func(ctx context.Context, opts containerapi.FindOptions) (*containerapi.Found, error)

DialFunc finds the engine and connects to it. containerapi.Find is the real one; a test gives one that returns the Client of a fake engine.

type ListFilters

type ListFilters struct {
	// Containers, Images, Networks, Volumes and Pods are the filters in the form the engines take (containerapi.Filters).
	Containers, Images, Networks, Volumes, Pods containerapi.Filters
}

ListFilters are the filters of the lists of the four sections.

Jump to

Keyboard shortcuts

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