commands

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2019 License: MIT Imports: 32 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// MustStopContainer tells us that we must stop the container before removing it
	MustStopContainer = iota
)

Variables

This section is empty.

Functions

func HasErrorCode

func HasErrorCode(err error, code int) bool

HasErrorCode is a function

func NewDummyAppConfig

func NewDummyAppConfig() *config.AppConfig

NewDummyAppConfig creates a new dummy AppConfig for testing

func NewDummyLog

func NewDummyLog() *logrus.Entry

NewDummyLog creates a new dummy Log for testing

func WrapError

func WrapError(err error) error

WrapError wraps an error for the sake of showing a stack trace at the top level the go-errors package, for some reason, does not return nil when you try to wrap a non-error, so we're just doing it here

Types

type CommandObject

type CommandObject struct {
	DockerCompose string
	Service       *Service
	Container     *Container
}

CommandObject is what we pass to our template resolvers when we are running a custom command. We do not guarantee that all fields will be populated: just the ones that make sense for the current context

type ComplexError

type ComplexError struct {
	Message string
	Code    int
	// contains filtered or unexported fields
}

ComplexError an error which carries a code so that calling code has an easier job to do adapted from https://medium.com/yakka/better-go-error-handling-with-xerrors-1987650e0c79

func (ComplexError) Error

func (ce ComplexError) Error() string

func (ComplexError) Format

func (ce ComplexError) Format(f fmt.State, c rune)

Format is a function

func (ComplexError) FormatError

func (ce ComplexError) FormatError(p xerrors.Printer) error

FormatError is a function

type Container

type Container struct {
	Name            string
	ServiceName     string
	ContainerNumber string // might make this an int in the future if need be

	// OneOff tells us if the container is just a job container or is actually bound to the service
	OneOff          bool
	ProjectName     string
	ID              string
	Container       types.Container
	DisplayString   string
	Client          *client.Client
	OSCommand       *OSCommand
	Config          *config.AppConfig
	Log             *logrus.Entry
	CLIStats        ContainerCliStat // for realtime we use the CLI, for long-term we use the client
	StatHistory     []RecordedStats
	Details         Details
	MonitoringStats bool
	DockerCommand   LimitedDockerCommand
	Tr              *i18n.TranslationSet
}

Container : A docker Container

func (*Container) Attach

func (c *Container) Attach() (*exec.Cmd, error)

Attach attaches the container

func (*Container) DetailsLoaded added in v0.2.1

func (c *Container) DetailsLoaded() bool

DetailsLoaded tells us whether we have yet loaded the details for a container. Because this is an asynchronous operation, sometimes we have the container before we have its details. Details is a struct, not a pointer to a struct, so it starts off with heaps of zero values. One of which is the container Image, which starts as a blank string. Given that every container should have an image, this is a good proxy to use

func (*Container) EraseOldHistory

func (c *Container) EraseOldHistory()

EraseOldHistory removes any history before the user-specified max duration

func (*Container) GetColor

func (c *Container) GetColor() color.Attribute

GetColor Container color

func (*Container) GetDisplayCPUPerc

func (c *Container) GetDisplayCPUPerc() string

GetDisplayCPUPerc colors the cpu percentage based on how extreme it is

func (*Container) GetDisplayStatus

func (c *Container) GetDisplayStatus() string

GetDisplayStatus returns the colored status of the container

func (*Container) GetDisplayStrings

func (c *Container) GetDisplayStrings(isFocused bool) []string

GetDisplayStrings returns the dispaly string of Container

func (*Container) Inspect

func (c *Container) Inspect() (types.ContainerJSON, error)

Inspect returns details about the container

func (*Container) PlotGraph

func (c *Container) PlotGraph(spec config.GraphConfig, width int) (string, error)

PlotGraph returns the plotted graph based on the graph spec and the stat history

func (*Container) ProducingLogs

func (c *Container) ProducingLogs() bool

ProducingLogs tells us whether we should bother checking a container's logs

func (*Container) Remove

func (c *Container) Remove(options types.ContainerRemoveOptions) error

Remove removes the container

func (*Container) RenderStats

func (c *Container) RenderStats(viewWidth int) (string, error)

RenderStats returns a string containing the rendered stats of the container

func (*Container) RenderTop

func (c *Container) RenderTop() (string, error)

RenderTop returns details about the container

func (*Container) Restart

func (c *Container) Restart() error

Restart restarts the container

func (*Container) Stop

func (c *Container) Stop() error

Stop stops the container

func (*Container) Top

Top returns process information

func (*Container) ViewLogs

func (c *Container) ViewLogs() (*exec.Cmd, error)

ViewLogs attaches to a subprocess viewing the container's logs

type ContainerCliStat

type ContainerCliStat struct {
	BlockIO   string `json:"BlockIO"`
	CPUPerc   string `json:"CPUPerc"`
	Container string `json:"Container"`
	ID        string `json:"ID"`
	MemPerc   string `json:"MemPerc"`
	MemUsage  string `json:"MemUsage"`
	Name      string `json:"Name"`
	NetIO     string `json:"NetIO"`
	PIDs      string `json:"PIDs"`
}

ContainerCliStat is a stat object returned by the CLI docker stat command

type ContainerStats

type ContainerStats struct {
	Read      time.Time `json:"read"`
	Preread   time.Time `json:"preread"`
	PidsStats struct {
		Current int `json:"current"`
	} `json:"pids_stats"`
	BlkioStats struct {
		IoServiceBytesRecursive []struct {
			Major int    `json:"major"`
			Minor int    `json:"minor"`
			Op    string `json:"op"`
			Value int    `json:"value"`
		} `json:"io_service_bytes_recursive"`
		IoServicedRecursive []struct {
			Major int    `json:"major"`
			Minor int    `json:"minor"`
			Op    string `json:"op"`
			Value int    `json:"value"`
		} `json:"io_serviced_recursive"`
		IoQueueRecursive       []interface{} `json:"io_queue_recursive"`
		IoServiceTimeRecursive []interface{} `json:"io_service_time_recursive"`
		IoWaitTimeRecursive    []interface{} `json:"io_wait_time_recursive"`
		IoMergedRecursive      []interface{} `json:"io_merged_recursive"`
		IoTimeRecursive        []interface{} `json:"io_time_recursive"`
		SectorsRecursive       []interface{} `json:"sectors_recursive"`
	} `json:"blkio_stats"`
	NumProcs     int `json:"num_procs"`
	StorageStats struct {
	} `json:"storage_stats"`
	CPUStats struct {
		CPUUsage struct {
			TotalUsage        int64   `json:"total_usage"`
			PercpuUsage       []int64 `json:"percpu_usage"`
			UsageInKernelmode int64   `json:"usage_in_kernelmode"`
			UsageInUsermode   int64   `json:"usage_in_usermode"`
		} `json:"cpu_usage"`
		SystemCPUUsage int64 `json:"system_cpu_usage"`
		OnlineCpus     int   `json:"online_cpus"`
		ThrottlingData struct {
			Periods          int `json:"periods"`
			ThrottledPeriods int `json:"throttled_periods"`
			ThrottledTime    int `json:"throttled_time"`
		} `json:"throttling_data"`
	} `json:"cpu_stats"`
	PrecpuStats struct {
		CPUUsage struct {
			TotalUsage        int64   `json:"total_usage"`
			PercpuUsage       []int64 `json:"percpu_usage"`
			UsageInKernelmode int64   `json:"usage_in_kernelmode"`
			UsageInUsermode   int64   `json:"usage_in_usermode"`
		} `json:"cpu_usage"`
		SystemCPUUsage int64 `json:"system_cpu_usage"`
		OnlineCpus     int   `json:"online_cpus"`
		ThrottlingData struct {
			Periods          int `json:"periods"`
			ThrottledPeriods int `json:"throttled_periods"`
			ThrottledTime    int `json:"throttled_time"`
		} `json:"throttling_data"`
	} `json:"precpu_stats"`
	MemoryStats struct {
		Usage    int `json:"usage"`
		MaxUsage int `json:"max_usage"`
		Stats    struct {
			ActiveAnon              int   `json:"active_anon"`
			ActiveFile              int   `json:"active_file"`
			Cache                   int   `json:"cache"`
			Dirty                   int   `json:"dirty"`
			HierarchicalMemoryLimit int64 `json:"hierarchical_memory_limit"`
			HierarchicalMemswLimit  int64 `json:"hierarchical_memsw_limit"`
			InactiveAnon            int   `json:"inactive_anon"`
			InactiveFile            int   `json:"inactive_file"`
			MappedFile              int   `json:"mapped_file"`
			Pgfault                 int   `json:"pgfault"`
			Pgmajfault              int   `json:"pgmajfault"`
			Pgpgin                  int   `json:"pgpgin"`
			Pgpgout                 int   `json:"pgpgout"`
			Rss                     int   `json:"rss"`
			RssHuge                 int   `json:"rss_huge"`
			TotalActiveAnon         int   `json:"total_active_anon"`
			TotalActiveFile         int   `json:"total_active_file"`
			TotalCache              int   `json:"total_cache"`
			TotalDirty              int   `json:"total_dirty"`
			TotalInactiveAnon       int   `json:"total_inactive_anon"`
			TotalInactiveFile       int   `json:"total_inactive_file"`
			TotalMappedFile         int   `json:"total_mapped_file"`
			TotalPgfault            int   `json:"total_pgfault"`
			TotalPgmajfault         int   `json:"total_pgmajfault"`
			TotalPgpgin             int   `json:"total_pgpgin"`
			TotalPgpgout            int   `json:"total_pgpgout"`
			TotalRss                int   `json:"total_rss"`
			TotalRssHuge            int   `json:"total_rss_huge"`
			TotalUnevictable        int   `json:"total_unevictable"`
			TotalWriteback          int   `json:"total_writeback"`
			Unevictable             int   `json:"unevictable"`
			Writeback               int   `json:"writeback"`
		} `json:"stats"`
		Limit int64 `json:"limit"`
	} `json:"memory_stats"`
	Name     string `json:"name"`
	ID       string `json:"id"`
	Networks struct {
		Eth0 struct {
			RxBytes   int `json:"rx_bytes"`
			RxPackets int `json:"rx_packets"`
			RxErrors  int `json:"rx_errors"`
			RxDropped int `json:"rx_dropped"`
			TxBytes   int `json:"tx_bytes"`
			TxPackets int `json:"tx_packets"`
			TxErrors  int `json:"tx_errors"`
			TxDropped int `json:"tx_dropped"`
		} `json:"eth0"`
	} `json:"networks"`
}

ContainerStats autogenerated at https://mholt.github.io/json-to-go/

func (*ContainerStats) CalculateContainerCPUPercentage

func (s *ContainerStats) CalculateContainerCPUPercentage() float64

CalculateContainerCPUPercentage calculates the cpu usage of the container as a percent of total CPU usage to calculate CPU usage, we take the increase in CPU time from the container since the last poll, divide that by the total increase in CPU time since the last poll, times by the number of cores, and times by 100 to get a percentage I'm not entirely sure why we need to multiply by the number of cores, but the numbers work

func (*ContainerStats) CalculateContainerMemoryUsage

func (s *ContainerStats) CalculateContainerMemoryUsage() float64

CalculateContainerMemoryUsage calculates the memory usage of the container as a percent of total available memory

type DerivedStats

type DerivedStats struct {
	CPUPercentage    float64
	MemoryPercentage float64
}

DerivedStats contains some useful stats that we've calculated based on the raw container stats that we got back from docker

type Details

type Details struct {
	ID      string    `json:"Id"`
	Created time.Time `json:"Created"`
	Path    string    `json:"Path"`
	Args    []string  `json:"Args"`
	State   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"`
	} `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         interface{} `json:"ExecIDs"`
	HostConfig      struct {
		Binds           []string `json:"Binds"`
		ContainerIDFile string   `json:"ContainerIDFile"`
		LogConfig       struct {
			Type   string `json:"Type"`
			Config struct {
			} `json:"Config"`
		} `json:"LogConfig"`
		NetworkMode  string `json:"NetworkMode"`
		PortBindings struct {
		} `json:"PortBindings"`
		RestartPolicy struct {
			Name              string `json:"Name"`
			MaximumRetryCount int    `json:"MaximumRetryCount"`
		} `json:"RestartPolicy"`
		AutoRemove           bool          `json:"AutoRemove"`
		VolumeDriver         string        `json:"VolumeDriver"`
		VolumesFrom          []interface{} `json:"VolumesFrom"`
		CapAdd               interface{}   `json:"CapAdd"`
		CapDrop              interface{}   `json:"CapDrop"`
		DNS                  interface{}   `json:"Dns"`
		DNSOptions           interface{}   `json:"DnsOptions"`
		DNSSearch            interface{}   `json:"DnsSearch"`
		ExtraHosts           interface{}   `json:"ExtraHosts"`
		GroupAdd             interface{}   `json:"GroupAdd"`
		IpcMode              string        `json:"IpcMode"`
		Cgroup               string        `json:"Cgroup"`
		Links                interface{}   `json:"Links"`
		OomScoreAdj          int           `json:"OomScoreAdj"`
		PidMode              string        `json:"PidMode"`
		Privileged           bool          `json:"Privileged"`
		PublishAllPorts      bool          `json:"PublishAllPorts"`
		ReadonlyRootfs       bool          `json:"ReadonlyRootfs"`
		SecurityOpt          interface{}   `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    interface{}   `json:"BlkioWeightDevice"`
		BlkioDeviceReadBps   interface{}   `json:"BlkioDeviceReadBps"`
		BlkioDeviceWriteBps  interface{}   `json:"BlkioDeviceWriteBps"`
		BlkioDeviceReadIOps  interface{}   `json:"BlkioDeviceReadIOps"`
		BlkioDeviceWriteIOps interface{}   `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              interface{}   `json:"Devices"`
		DeviceCgroupRules    interface{}   `json:"DeviceCgroupRules"`
		DiskQuota            int           `json:"DiskQuota"`
		KernelMemory         int           `json:"KernelMemory"`
		MemoryReservation    int           `json:"MemoryReservation"`
		MemorySwap           int           `json:"MemorySwap"`
		MemorySwappiness     interface{}   `json:"MemorySwappiness"`
		OomKillDisable       bool          `json:"OomKillDisable"`
		PidsLimit            int           `json:"PidsLimit"`
		Ulimits              interface{}   `json:"Ulimits"`
		CPUCount             int           `json:"CpuCount"`
		CPUPercent           int           `json:"CpuPercent"`
		IOMaximumIOps        int           `json:"IOMaximumIOps"`
		IOMaximumBandwidth   int           `json:"IOMaximumBandwidth"`
		MaskedPaths          []string      `json:"MaskedPaths"`
		ReadonlyPaths        []string      `json:"ReadonlyPaths"`
	} `json:"HostConfig"`
	GraphDriver struct {
		Data struct {
			LowerDir  string `json:"LowerDir"`
			MergedDir string `json:"MergedDir"`
			UpperDir  string `json:"UpperDir"`
			WorkDir   string `json:"WorkDir"`
		} `json:"Data"`
		Name string `json:"Name"`
	} `json:"GraphDriver"`
	Mounts []struct {
		Type        string `json:"Type"`
		Name        string `json:"Name,omitempty"`
		Source      string `json:"Source"`
		Destination string `json:"Destination"`
		Driver      string `json:"Driver,omitempty"`
		Mode        string `json:"Mode"`
		RW          bool   `json:"RW"`
		Propagation string `json:"Propagation"`
	} `json:"Mounts"`
	Config 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"`
		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      struct {
			APIBundle struct {
			} `json:"/api-bundle"`
			App struct {
			} `json:"/app"`
		} `json:"Volumes"`
		WorkingDir string            `json:"WorkingDir"`
		Entrypoint interface{}       `json:"Entrypoint"`
		OnBuild    interface{}       `json:"OnBuild"`
		Labels     map[string]string `json:"Labels"`
	} `json:"Config"`
	NetworkSettings struct {
		Bridge                 string `json:"Bridge"`
		SandboxID              string `json:"SandboxID"`
		HairpinMode            bool   `json:"HairpinMode"`
		LinkLocalIPv6Address   string `json:"LinkLocalIPv6Address"`
		LinkLocalIPv6PrefixLen int    `json:"LinkLocalIPv6PrefixLen"`
		Ports                  map[string][]struct {
			HostIP   string `json:"HostIP"`
			HostPort string `json:"HostPort"`
		} `json:"Ports"`
		SandboxKey             string      `json:"SandboxKey"`
		SecondaryIPAddresses   interface{} `json:"SecondaryIPAddresses"`
		SecondaryIPv6Addresses interface{} `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]struct {
			IPAMConfig          interface{} `json:"IPAMConfig"`
			Links               interface{} `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          interface{} `json:"DriverOpts"`
		} `json:"Networks"`
	} `json:"NetworkSettings"`
}

Details is a struct containing what we get back from `docker inspect` on a container

type DockerCommand

type DockerCommand struct {
	Log                    *logrus.Entry
	OSCommand              *OSCommand
	Tr                     *i18n.TranslationSet
	Config                 *config.AppConfig
	Client                 *client.Client
	InDockerComposeProject bool
	ShowExited             bool
	ErrorChan              chan error
	ContainerMutex         sync.Mutex
	ServiceMutex           sync.Mutex
	Services               []*Service
	Containers             []*Container
	// DisplayContainers is the array of containers we will display in the containers panel. If Gui.ShowAllContainers is false, this will only be those containers which aren't based on a service. This reduces clutter and duplication in the UI
	DisplayContainers []*Container
	Images            []*Image
	Volumes           []*Volume
}

DockerCommand is our main docker interface

func NewDockerCommand

func NewDockerCommand(log *logrus.Entry, osCommand *OSCommand, tr *i18n.TranslationSet, config *config.AppConfig, errorChan chan error) (*DockerCommand, error)

NewDockerCommand it runs docker commands

func NewDummyDockerCommand

func NewDummyDockerCommand() *DockerCommand

NewDummyDockerCommand creates a new dummy DockerCommand for testing

func NewDummyDockerCommandWithOSCommand

func NewDummyDockerCommandWithOSCommand(osCommand *OSCommand) *DockerCommand

NewDummyDockerCommandWithOSCommand creates a new dummy DockerCommand for testing

func (*DockerCommand) DockerComposeConfig

func (c *DockerCommand) DockerComposeConfig() string

DockerComposeConfig returns the result of 'docker-compose config'

func (*DockerCommand) GetContainers

func (c *DockerCommand) GetContainers() ([]*Container, error)

GetContainers gets the docker containers

func (*DockerCommand) GetServices

func (c *DockerCommand) GetServices() ([]*Service, error)

GetServices gets services

func (*DockerCommand) MonitorCLIContainerStats

func (c *DockerCommand) MonitorCLIContainerStats()

MonitorCLIContainerStats monitors a stream of container stats and updates the containers as each new stats object is received

func (*DockerCommand) MonitorClientContainerStats

func (c *DockerCommand) MonitorClientContainerStats()

MonitorClientContainerStats is a function

func (*DockerCommand) MonitorContainerStats

func (c *DockerCommand) MonitorContainerStats()

MonitorContainerStats is a function

func (*DockerCommand) NewCommandObject

func (c *DockerCommand) NewCommandObject(obj CommandObject) CommandObject

NewCommandObject takes a command object and returns a default command object with the passed command object merged in

func (*DockerCommand) PruneContainers

func (c *DockerCommand) PruneContainers() error

PruneContainers prunes containers

func (*DockerCommand) PruneImages

func (c *DockerCommand) PruneImages() error

PruneImages prunes images

func (*DockerCommand) PruneVolumes

func (c *DockerCommand) PruneVolumes() error

PruneVolumes prunes volumes

func (*DockerCommand) RefreshContainersAndServices

func (c *DockerCommand) RefreshContainersAndServices() error

RefreshContainersAndServices returns a slice of docker containers

func (*DockerCommand) RefreshImages added in v0.2.1

func (c *DockerCommand) RefreshImages() ([]*Image, error)

RefreshImages returns a slice of docker images

func (*DockerCommand) RefreshVolumes

func (c *DockerCommand) RefreshVolumes() error

RefreshVolumes gets the volumes and stores them

func (*DockerCommand) UpdateContainerDetails

func (c *DockerCommand) UpdateContainerDetails() error

UpdateContainerDetails attaches the details returned from docker inspect to each of the containers this contains a bit more info than what you get from the go-docker client

func (*DockerCommand) ViewAllLogs

func (c *DockerCommand) ViewAllLogs() (*exec.Cmd, error)

ViewAllLogs attaches to a subprocess viewing all the logs from docker-compose

type Image

type Image struct {
	Name          string
	Tag           string
	ID            string
	Image         types.ImageSummary
	Client        *client.Client
	OSCommand     *OSCommand
	Log           *logrus.Entry
	DockerCommand LimitedDockerCommand
}

Image : A docker Image

func (*Image) GetDisplayStrings

func (i *Image) GetDisplayStrings(isFocused bool) []string

GetDisplayStrings returns the display string of Image

func (*Image) Remove

func (i *Image) Remove(options types.ImageRemoveOptions) error

Remove removes the image

func (*Image) RenderHistory

func (i *Image) RenderHistory() (string, error)

RenderHistory renders the history of the image

type Layer

type Layer struct {
	types.ImageHistory
}

Layer is a layer in an image's history

func (*Layer) GetDisplayStrings

func (l *Layer) GetDisplayStrings(isFocused bool) []string

GetDisplayStrings returns the array of strings describing the layer

type LimitedDockerCommand

type LimitedDockerCommand interface {
	NewCommandObject(CommandObject) CommandObject
}

LimitedDockerCommand is a stripped-down DockerCommand with just the methods the container/service/image might need

type OSCommand

type OSCommand struct {
	Log      *logrus.Entry
	Platform *Platform
	Config   *config.AppConfig
	// contains filtered or unexported fields
}

OSCommand holds all the os commands

func NewDummyOSCommand

func NewDummyOSCommand() *OSCommand

NewDummyOSCommand creates a new dummy OSCommand for testing

func NewOSCommand

func NewOSCommand(log *logrus.Entry, config *config.AppConfig) *OSCommand

NewOSCommand os command runner

func (*OSCommand) AppendLineToFile

func (c *OSCommand) AppendLineToFile(filename, line string) error

AppendLineToFile adds a new line in file

func (*OSCommand) CreateTempFile

func (c *OSCommand) CreateTempFile(filename, content string) (string, error)

CreateTempFile writes a string to a new temp file and returns the file's name

func (*OSCommand) EditFile

func (c *OSCommand) EditFile(filename string) (*exec.Cmd, error)

EditFile opens a file in a subprocess using whatever editor is available, falling back to core.editor, VISUAL, EDITOR, then vi

func (*OSCommand) ExecutableFromString

func (c *OSCommand) ExecutableFromString(commandStr string) *exec.Cmd

ExecutableFromString takes a string like `docker ps -a` and returns an executable command for it

func (*OSCommand) FileExists

func (c *OSCommand) FileExists(path string) (bool, error)

FileExists checks whether a file exists at the specified path

func (*OSCommand) FileType

func (c *OSCommand) FileType(path string) string

FileType tells us if the file is a file, directory or other

func (*OSCommand) GetLazydockerPath

func (c *OSCommand) GetLazydockerPath() string

GetLazydockerPath returns the path of the currently executed file

func (*OSCommand) Kill

func (c *OSCommand) Kill(cmd *exec.Cmd) error

Kill kills a process. If the process has Setpgid == true, then we have anticipated that it might spawn its own child processes, so we've given it a process group ID (PGID) equal to its process id (PID) and given its child processes will inherit the PGID, we can kill that group, rather than killing the process itself.

func (*OSCommand) OpenFile

func (c *OSCommand) OpenFile(filename string) error

OpenFile opens a file with the given

func (c *OSCommand) OpenLink(link string) error

OpenLink opens a file with the given

func (*OSCommand) PipeCommands

func (c *OSCommand) PipeCommands(commandStrings ...string) error

PipeCommands runs a heap of commands and pipes their inputs/outputs together like A | B | C

func (*OSCommand) PrepareForChildren

func (c *OSCommand) PrepareForChildren(cmd *exec.Cmd)

PrepareForChildren sets Setpgid to true on the cmd, so that when we run it as a sideproject, we can kill its group rather than the process itself. This is because some commands, like `docker-compose logs` spawn multiple children processes, and killing the parent process isn't sufficient for killing those child processes. We set the group id here, and then in subprocess.go we check if the group id is set and if so, we kill the whole group rather than just the one process.

func (*OSCommand) PrepareSubProcess

func (c *OSCommand) PrepareSubProcess(cmdName string, commandArgs ...string) *exec.Cmd

PrepareSubProcess iniPrepareSubProcessrocess then tells the Gui to switch to it

func (*OSCommand) Quote

func (c *OSCommand) Quote(message string) string

Quote wraps a message in platform-specific quotation marks

func (*OSCommand) Remove

func (c *OSCommand) Remove(filename string) error

Remove removes a file or directory at the specified path

func (*OSCommand) RunCommand

func (c *OSCommand) RunCommand(command string) error

RunCommand runs a command and just returns the error

func (*OSCommand) RunCommandWithOutput

func (c *OSCommand) RunCommandWithOutput(command string) (string, error)

RunCommandWithOutput wrapper around commands returning their output and error

func (*OSCommand) RunCustomCommand

func (c *OSCommand) RunCustomCommand(command string) *exec.Cmd

RunCustomCommand returns the pointer to a custom command

func (*OSCommand) RunDirectCommand

func (c *OSCommand) RunDirectCommand(command string) (string, error)

RunDirectCommand wrapper around direct commands

func (*OSCommand) RunExecutable

func (c *OSCommand) RunExecutable(cmd *exec.Cmd) error

RunExecutable runs an executable file and returns an error if there was one

func (*OSCommand) RunExecutableWithOutput

func (c *OSCommand) RunExecutableWithOutput(cmd *exec.Cmd) (string, error)

RunExecutableWithOutput runs an executable file and returns its output

func (*OSCommand) RunPreparedCommand

func (c *OSCommand) RunPreparedCommand(cmd *exec.Cmd) error

RunPreparedCommand takes a pointer to an exec.Cmd and runs it this is useful if you need to give your command some environment variables before running it

func (*OSCommand) SetCommand

func (c *OSCommand) SetCommand(cmd func(string, ...string) *exec.Cmd)

SetCommand sets the command function used by the struct. To be used for testing only

func (*OSCommand) Unquote

func (c *OSCommand) Unquote(message string) string

Unquote removes wrapping quotations marks if they are present this is needed for removing quotes from staged filenames with spaces

type Platform

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

Platform stores the os state

type RecordedStats

type RecordedStats struct {
	ClientStats  ContainerStats
	DerivedStats DerivedStats
	RecordedAt   time.Time
}

RecordedStats contains both the container stats we've received from docker, and our own derived stats from those container stats. When configuring a graph, you're basically specifying the path of a value in this struct

type Service

type Service struct {
	Name          string
	ID            string
	OSCommand     *OSCommand
	Log           *logrus.Entry
	Container     *Container
	DockerCommand LimitedDockerCommand
}

Service : A docker Service

func (*Service) Attach

func (s *Service) Attach() (*exec.Cmd, error)

Attach attaches to the service

func (*Service) GetDisplayStrings

func (s *Service) GetDisplayStrings(isFocused bool) []string

GetDisplayStrings returns the dispaly string of Container

func (*Service) Remove

func (s *Service) Remove(options types.ContainerRemoveOptions) error

Remove removes the service's containers

func (*Service) RenderTop

func (s *Service) RenderTop() (string, error)

RenderTop renders the process list of the service

func (*Service) Restart

func (s *Service) Restart() error

Restart restarts the service

func (*Service) Stop

func (s *Service) Stop() error

Stop stops the service's containers

func (*Service) Top

Top returns process information

func (*Service) ViewLogs

func (s *Service) ViewLogs() (*exec.Cmd, error)

ViewLogs attaches to a subprocess viewing the service's logs

type Volume

type Volume struct {
	Name          string
	Volume        *types.Volume
	Client        *client.Client
	OSCommand     *OSCommand
	Log           *logrus.Entry
	DockerCommand LimitedDockerCommand
}

Volume : A docker Volume

func (*Volume) GetDisplayStrings

func (v *Volume) GetDisplayStrings(isFocused bool) []string

GetDisplayStrings returns the dispaly string of Container

func (*Volume) Remove

func (v *Volume) Remove(force bool) error

Remove removes the volume

Jump to

Keyboard shortcuts

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