internal

package
v0.0.0-...-c74c510 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigFileName = "ahab.json"

ConfigFileName holds the name of the config file

View Source
const ContainerUserName = "ahab"

ContainerUserName is the username of the user created in the container

View Source
const UserConfigFilePath = ".config/ahab/config.json"

UserConfigFilePath holds the path of the user's config file, relative to their home dir

Variables

View Source
var Version string

Version holds the build-time ahab version

Functions

func DisplaySessionType

func DisplaySessionType() (sessionType string)

DisplaySessionType returns the host's session type (x11, wayland, etc.)

func Docker

func Docker(opts *[]string) (cmd *exec.Cmd)

Docker generates a Docker command

func DockerCmd

func DockerCmd(opts *[]string) error

DockerCmd prints a function, runs it, and attatches the output to the user's terminal

func DockerOutput

func DockerOutput(opts *[]string) ([]byte, error)

DockerOutput runs a docker function behind the scenes and returns the output

func DockerXHostAuth

func DockerXHostAuth() error

DockerXHostAuth gives the docker user xhost access so containerized apps can run on the host's WM TODO: check if the Docker user already has access before re-granting access

func ListContainers

func ListContainers(verbose bool) error

ListContainers executes a docker command to list all containers

func ListImages

func ListImages(verbose bool) error

ListImages executes a docker command to list all images

func ListVolumes

func ListVolumes() error

ListVolumes executes a docker command to list all images

func ParseStatus

func ParseStatus(code int) string

ParseStatus returns the readable string of the passed container status 0 - not found 1 - created 2 - restarting 3 - running 4 - removing 5 - paused 6 - exited 7 - dead

func PrintDockerHelp

func PrintDockerHelp(cmdArgs *[]string, dockerCmd string, helpString string) (helpRequested bool, err error)

PrintDockerHelp parses args for a help flag, printing a help menu and running corresponding docker help command if requested

Types

type Configuration

type Configuration struct {
	AhabVersion       string            `json:"ahab"`
	BuildContext      string            `json:"buildContext"`
	Command           string            `json:"command"`
	Dockerfile        string            `json:"dockerfile"`
	Entrypoint        string            `json:"entrypoint"`
	Environment       []string          `json:"environment"`
	Hostname          string            `json:"hostname"`
	ImageURI          string            `json:"image"`
	Init              []string          `json:"init"`
	Name              string            `json:"name"`
	Options           []string          `json:"options"`
	Permissions       PermConfiguration `json:"permissions"`
	RestartAfterSetup bool              `json:"restartAfterSetup"`
	ShareDisplay      bool              `json:"shareDisplay"`
	User              string            `json:"user"`
	Volumes           []string          `json:"volumes"`
	Workdir           string            `json:"workdir"`
}

Configuration contains docker config fields

type Container

type Container struct {
	Fields   *Configuration
	FilePath string
}

Container contains all information regarding a container's configuration

func GetContainer

func GetContainer() (*Container, error)

GetContainer retrieves all container info relative to the working directory

func (*Container) Cmd

func (container *Container) Cmd(command string) error

Cmd runs a container command in the form docker [command] [container name]

func (*Container) Create

func (container *Container) Create(startContainer bool) error

Create creates & prepares the container, leaving at "created" status if start is false

func (*Container) Down

func (container *Container) Down() (err error)

Down stops and removes the container

func (*Container) Name

func (container *Container) Name() string

Name fetches the container name

func (*Container) Prop

func (container *Container) Prop(fieldID string) (string, error)

Prop fetches a container property using Docker

func (*Container) Status

func (container *Container) Status() (int, error)

Status returns a code corresponding to the status of the container 0 - not found 1 - created 2 - restarting 3 - running 4 - removing 5 - paused 6 - exited 7 - dead

func (*Container) Up

func (container *Container) Up() error

Up creates and starts the container

type PermConfiguration

type PermConfiguration struct {
	CmdSet  string   `json:"cmdSet"`
	Disable bool     `json:"disable"`
	Groups  []string `json:"groups"`
}

PermConfiguration contains information regarding container user permissions setup

type UserConfiguration

type UserConfiguration struct {
	Environment  []string `json:"environment"`
	Options      []string `json:"options"`
	HideCommands bool     `json:"hideCommands"`
	Volumes      []string `json:"volumes"`
}

UserConfiguration contains global user config fields

func UserConfig

func UserConfig() (userConfig *UserConfiguration, err error)

UserConfig finds and parses the user's docker config file If the user's config is not found, an empty userConfig is returned

Jump to

Keyboard shortcuts

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