docker

package
v0.0.0-...-27647ab Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: BSD-3-Clause Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CliCmd

func CliCmd(ctx context.Context, args ...string) ([]byte, error)

func GetComposeName

func GetComposeName(n string) string

func MatchComposeName

func MatchComposeName(h, n string) bool

Types

type CliCmdError

type CliCmdError struct {
	Message string
}

func (CliCmdError) Error

func (e CliCmdError) Error() string

type ComposeConfig

type ComposeConfig struct {
	Version string `json:"version"`

	Services map[string]*ComposeService

	X map[string]any `json:"-"`
}

func ReadComposeConfig

func ReadComposeConfig(paths []string) (*ComposeConfig, error)

type ComposeService

type ComposeService struct {
	Image    string `json:"image"`
	Platform string `json:"platform"`
	Restart  string `json:"restart"`

	Environment map[string]string `json:"environment"`

	Expose []string `json:"expose"`
	Ports  []string `json:"ports"`

	X map[string]any `json:"-"`
}

type Inspect

type Inspect struct {
	Id      string    `json:"Id"`
	Created time.Time `json:"Created"`

	Path string   `json:"Path"`
	Args []string `json:"Args"`

	State InspectState `json:"State"`

	Image string `json:"Image"`

	ResolvConfPath string `json:"ResolvConfPath"`
	HostnamePath   string `json:"HostnamePath"`
	HostsPath      string `json:"HostsPath"`
	LogPath        string `json:"LogPath"`

	Name string `json:"Name"`

	RestartCount int `json:"RestartCount"`

	Driver   string `json:"Driver"`
	Platform string `json:"Platform"`

	MountLabel   string `json:"MountLabel"`
	ProcessLabel string `json:"ProcessLabel"`

	AppArmorProfile string `json:"AppArmorProfile"`

	ExecIDs any `json:"ExecIDs"`

	HostConfig InspectHostConfig `json:"HostConfig"`

	Mounts []InspectMount `json:"Mounts"`

	Config InspectConfig `json:"Config"`

	NetworkSettings InspectNetworkSettings `json:"NetworkSettings"`

	X map[string]any `json:"-"`
}

type InspectConfig

type InspectConfig struct {
	Hostname   string `json:"Hostname"`
	Domainname string `json:"Domainname"`

	User string `json:"User"`

	AttachStdin  bool `json:"AttachStdin"`
	AttachStdout bool `json:"AttachStdout"`
	AttachStderr bool `json:"AttachStderr"`

	ExposedPorts map[string]any `json:"ExposedPorts"`

	Tty       bool `json:"Tty"`
	OpenStdin bool `json:"OpenStdin"`
	StdinOnce bool `json:"StdinOnce"`

	Env   []string `json:"Env"`
	Cmd   []string `json:"Cmd"`
	Image string   `json:"Image"`

	Volumes    map[string]any `json:"Volumes"`
	WorkingDir string         `json:"WorkingDir"`
	Entrypoint []string       `json:"Entrypoint"`

	OnBuild any `json:"OnBuild"`

	Labels map[string]string `json:"Labels"`

	StopSignal string `json:"StopSignal"`

	X map[string]any `json:"-"`
}

type InspectHostConfig

type InspectHostConfig struct {
	Binds       []any  `json:"Binds"`
	NetworkMode string `json:"NetworkMode"`

	PortBindings map[string][]InspectHostConfigPortBinding `json:"PortBindings"`

	RestartPolicy InspectHostConfigRestartPolicy `json:"RestartPolicy"`

	AutoRemove bool `json:"AutoRemove"`

	VolumeDriver string `json:"VolumeDriver"`
	VolumesFrom  any    `json:"VolumesFrom"`

	CapAdd       any    `json:"CapAdd"`
	CapDrop      any    `json:"CapDrop"`
	CgroupnsMode string `json:"CgroupnsMode"`

	Dns        []any `json:"Dns"`
	DnsOptions []any `json:"DnsOptions"`
	DnsSearch  []any `json:"DnsSearch"`

	ExtraHosts      []any  `json:"ExtraHosts"`
	GroupAdd        any    `json:"GroupAdd"`
	IpcMode         string `json:"IpcMode"`
	Cgroup          string `json:"Cgroup"`
	Links           any    `json:"Links"`
	OomScoreAdj     int    `json:"OomScoreAdj"`
	PidMode         string `json:"PidMode"`
	Privileged      bool   `json:"Privileged"`
	PublishAllPorts bool   `json:"PublishAllPorts"`
	ReadonlyRootfs  bool   `json:"ReadonlyRootfs"`
	SecurityOpt     any    `json:"SecurityOpt"`
	UtsMode         string `json:"UTSMode"`
	UsernsMode      string `json:"UsernsMode"`
	ShmSize         int    `json:"ShmSize"`
	Runtime         string `json:"Runtime"`
	ConsoleSize     []int  `json:"ConsoleSize"`
	Isolation       string `json:"Isolation"`
	CpuShares       int    `json:"CpuShares"`
	Memory          int    `json:"Memory"`
	NanoCpus        int    `json:"NanoCpus"`
	CgroupParent    string `json:"CgroupParent"`

	BlkioWeight          int `json:"BlkioWeight"`
	BlkioWeightDevice    any `json:"BlkioWeightDevice"`
	BlkioDeviceReadBps   any `json:"BlkioDeviceReadBps"`
	BlkioDeviceWriteBps  any `json:"BlkioDeviceWriteBps"`
	BlkioDeviceReadIops  any `json:"BlkioDeviceReadIOps"`
	BlkioDeviceWriteIops any `json:"BlkioDeviceWriteIOps"`

	CpuPeriod          int    `json:"CpuPeriod"`
	CpuQuota           int    `json:"CpuQuota"`
	CpuRealtimePeriod  int    `json:"CpuRealtimePeriod"`
	CpuRealtimeRuntime int    `json:"CpuRealtimeRuntime"`
	CpusetCpus         string `json:"CpusetCpus"`
	CpusetMems         string `json:"CpusetMems"`

	Devices           any `json:"Devices"`
	DeviceCgroupRules any `json:"DeviceCgroupRules"`
	DeviceRequests    any `json:"DeviceRequests"`
	KernelMemory      int `json:"KernelMemory"`
	KernelMemoryTcp   int `json:"KernelMemoryTCP"`

	MemoryReservation int `json:"MemoryReservation"`
	MemorySwap        int `json:"MemorySwap"`
	MemorySwappiness  any `json:"MemorySwappiness"`

	OomKillDisable any `json:"OomKillDisable"`

	PidsLimit any `json:"PidsLimit"`
	Ulimits   any `json:"Ulimits"`

	CpuCount   int `json:"CpuCount"`
	CpuPercent int `json:"CpuPercent"`

	IoMaximumIops      int `json:"IOMaximumIOps"`
	IoMaximumBandwidth int `json:"IOMaximumBandwidth"`

	Mounts []InspectHostConfigMount `json:"Mounts"`

	MaskedPaths   []string `json:"MaskedPaths"`
	ReadonlyPaths []string `json:"ReadonlyPaths"`

	X map[string]any `json:"-"`
}

type InspectHostConfigMount

type InspectHostConfigMount struct {
	Type   string `json:"Type"`
	Source string `json:"Source"`
	Target string `json:"Target"`

	X map[string]any `json:"-"`
}

type InspectHostConfigPortBinding

type InspectHostConfigPortBinding struct {
	HostIp   string `json:"HostIp"`
	HostPort string `json:"HostPort"`

	X map[string]any `json:"-"`
}

type InspectHostConfigRestartPolicy

type InspectHostConfigRestartPolicy struct {
	Name              string `json:"Name"`
	MaximumRetryCount int    `json:"MaximumRetryCount"`

	X map[string]any `json:"-"`
}

type InspectMount

type InspectMount struct {
	Type        string `json:"Type"`
	Name        string `json:"Name"`
	Source      string `json:"Source"`
	Destination string `json:"Destination"`
	Driver      string `json:"Driver"`
	Mode        string `json:"Mode"`
	Rw          bool   `json:"RW"`
	Propagation string `json:"Propagation"`

	X map[string]any `json:"-"`
}

type InspectNetwork

type InspectNetwork struct {
	IpamConfig          any      `json:"IPAMConfig"`
	Links               any      `json:"Links"`
	Aliases             []string `json:"Aliases"`
	NetworkId           string   `json:"NetworkID"`
	EndpointId          string   `json:"EndpointID"`
	Gateway             string   `json:"Gateway"`
	IpAddress           string   `json:"IPAddress"`
	IpPrefixLen         int      `json:"IPPrefixLen"`
	Ipv6Gateway         string   `json:"IPv6Gateway"`
	GlobalIpv6Address   string   `json:"GlobalIPv6Address"`
	GlobalIpv6PrefixLen int      `json:"GlobalIPv6PrefixLen"`
	MacAddress          string   `json:"MacAddress"`
	DriverOpts          any      `json:"DriverOpts"`

	X map[string]any `json:"-"`
}

type InspectNetworkSettings

type InspectNetworkSettings struct {
	Bridge      string `json:"Bridge"`
	SandboxID   string `json:"SandboxID"`
	HairpinMode bool   `json:"HairpinMode"`

	LinkLocalIpv6Address   string `json:"LinkLocalIPv6Address"`
	LinkLocalIpv6PrefixLen int    `json:"LinkLocalIPv6PrefixLen"`

	Ports map[string][]InspectNetworkSettingsPort `json:"Ports"`

	SandboxKey string `json:"SandboxKey"`

	SecondaryIpAddresses   any `json:"SecondaryIPAddresses"`
	SecondaryIpv6Addresses any `json:"SecondaryIPv6Addresses"`

	EndpointID string `json:"EndpointID"`

	Gateway string `json:"Gateway"`

	GlobalIpv6Address   string `json:"GlobalIPv6Address"`
	GlobalIpv6PrefixLen int    `json:"GlobalIPv6PrefixLen"`

	IpAddress   string `json:"IPAddress"`
	IpPrefixLen int    `json:"IPPrefixLen"`
	Ipv6Gateway string `json:"IPv6Gateway"`

	MacAddress string `json:"MacAddress"`

	Networks map[string]InspectNetwork `json:"Networks"`

	X map[string]any `json:"-"`
}

type InspectNetworkSettingsPort

type InspectNetworkSettingsPort struct {
	HostIp   string `json:"HostIp"`
	HostPort string `json:"HostPort"`

	X map[string]any `json:"-"`
}

type InspectState

type InspectState struct {
	Status     string    `json:"Status"`
	Running    bool      `json:"Running"`
	Paused     bool      `json:"Paused"`
	Restarting bool      `json:"Restarting"`
	OomKilled  bool      `json:"OOMKilled"`
	Dead       bool      `json:"Dead"`
	Pid        int       `json:"Pid"`
	ExitCode   int       `json:"ExitCode"`
	Error      string    `json:"Error"`
	StartedAt  time.Time `json:"StartedAt"`
	FinishedAt time.Time `json:"FinishedAt"`

	X map[string]any `json:"-"`
}

type Inspects

type Inspects []*Inspect

func CliInspect

func CliInspect(ctx context.Context, ids []string) (Inspects, error)

func CliInspectAll

func CliInspectAll(ctx context.Context) (Inspects, error)

type Ps

type Ps struct {
	Command      string `json:"Command"`
	CreatedAt    string `json:"CreatedAt"`
	ID           string `json:"ID"`
	Image        string `json:"Image"`
	Labels       string `json:"Labels"`
	LocalVolumes string `json:"LocalVolumes"`
	Mounts       string `json:"Mounts"`
	Names        string `json:"Names"`
	Networks     string `json:"Networks"`
	Ports        string `json:"Ports"`
	RunningFor   string `json:"RunningFor"`
	Size         string `json:"Size"`
	State        string `json:"State"`
	Status       string `json:"Status"`

	X map[string]any `json:"-"`
}

type Pss

type Pss []*Ps

func CliPs

func CliPs(ctx context.Context) (Pss, error)

func (Pss) Ids

func (pss Pss) Ids() []string

type Service

type Service struct {
	Name string

	Host  string
	Ports map[int]int

	Ps      *Ps
	Inspect *Inspect
	Compose *ComposeService
}

type ServiceLocator

type ServiceLocator struct {
	// contains filtered or unexported fields
}

func NewServiceLocator

func NewServiceLocator(cfg ServiceLocatorConfig) *ServiceLocator

func (*ServiceLocator) Compose

func (sl *ServiceLocator) Compose() *ComposeConfig

func (*ServiceLocator) Inspects

func (sl *ServiceLocator) Inspects() Inspects

func (*ServiceLocator) Locate

func (sl *ServiceLocator) Locate(name string) *Service

func (*ServiceLocator) Pss

func (sl *ServiceLocator) Pss() Pss

type ServiceLocatorConfig

type ServiceLocatorConfig struct {
	Timeout      time.Duration
	ComposePaths []string
}

func DefaultServiceLocatorConfig

func DefaultServiceLocatorConfig() ServiceLocatorConfig

Jump to

Keyboard shortcuts

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