dockercntrl

package module
v0.0.0-...-c1ef799 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: MIT Imports: 21 Imported by: 2

Documentation

Overview

Packager dockercntrl gives limited nebula-specific control to the docker deamon. It's structures can be used to pass containers via JSON.

Index

Constants

View Source
const (
	LABEL = "nebula-id"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Id      *uuid.UUID `json:"nebula_id,omitempty"`
	Image   string     `json:"image"`
	Cmd     []string   `json:"command"`
	Tty     bool       `json:"tty"`
	Name    string     `json:"name"`
	Limits  *Limits    `json:"limits"`
	Env     []string   `json:"env"`
	Port    int        `json:"port"`
	Storage bool       `json:"storage"`
	// contains filtered or unexported fields
}

Config represents the configuration to build a new container.

func (*Config) AddDeamonMount

func (c *Config) AddDeamonMount()

func (*Config) AddMount

func (c *Config) AddMount(name string)

type Container

type Container struct {
	ID            string `json:"Id"`
	State         *State
	Names         []string
	Configuration *Config
	Image         string
	Command       string
}

Container holds the data required to identify and adjust a docker container.

type IpInfo

type IpInfo struct {
	Ip   string `json:"ip"`
	City string `json:"city"`
	Loc  string `json:"loc"`
}

type Limits

type Limits struct {
	CPUShares int64 `json:"cpushares"`
}

Limits hold the set of limits for a given container.

type Network

type Network struct {
	ID string
}

type State

type State struct {
	Context context.Context
	Client  *client.Client
	// TODO: switch to sdk
	HttpUnix *http.Client
}

State holds the structs required to manipulate the docker daemon

func New

func New() (*State, error)

Construct a new State

func (*State) AttachContainerNetwork

func (s *State) AttachContainerNetwork(container *Container, network *Network) error

func (*State) AttachNetwork

func (s *State) AttachNetwork(container_name string, network string) error

revised version api request

func (*State) BeaconCreateOverlay

func (s *State) BeaconCreateOverlay(containerName string, overlayName string) (string, string, error)
Beacon create overlay network

Input: containerName overlayName Return: token, beacon_ip, error

func (*State) BeaconCreateSpinnerOverlay

func (s *State) BeaconCreateSpinnerOverlay(overlayName string) error
Beacon create overlay network

for a new joined spinner

func (*State) Create

func (s *State) Create(configuration *Config) (*Container, error)

Create builds a docker container

func (*State) CreateOverlay

func (s *State) CreateOverlay(name string) (int, error)

create overlay network

func (*State) CreateSwarm

func (s *State) CreateSwarm(myIp string) (int, error)

initialize the swarm

func (*State) GetNetwork

func (s *State) GetNetwork() (*Network, error)

func (*State) GetSwarmInfo

func (s *State) GetSwarmInfo() (int, *SwarmInfo, error)

get swarm info

func (*State) JoinOverlay

func (s *State) JoinOverlay(containerName, overlayName string) error

join the overlay (already join the swarm)

func (*State) JoinSwarm

func (s *State) JoinSwarm(myIp, token, managerIp string) (int, error)

join the swarm

func (*State) JoinSwarmAndOverlay

func (s *State) JoinSwarmAndOverlay(token string, ip string, containerName, overlayName string) error

Captain/Spinner join the overlay network join the swarm first given target token, ip, overlay name and self_container_name

func (*State) Kill

func (s *State) Kill(cont *Container) error

Kill immediately ends a docker container

func (*State) List

func (s *State) List() ([]*Container, error)

List returns all nebula-specific docker containers, determined by docker label

func (*State) NetworkConnect

func (s *State) NetworkConnect(container *Container) error

func (*State) NetworkCreate

func (s *State) NetworkCreate() (Network, error)

func (*State) NetworkList

func (s *State) NetworkList() ([]Network, error)

func (*State) Pull

func (s *State) Pull(config *Config) (*string, error)

Pull pulls the associated image into cache

func (*State) Remove

func (s *State) Remove(cont *Container) error

Remove clears a docker container from the docker deamon

func (*State) Run

func (s *State) Run(c *Container) (*string, error)

Run runs a built docker container. It follows the execution to display logs at the end of execution.

func (*State) VolumeCreate

func (s *State) VolumeCreate(name string) error

Creates a Volume

type SwarmInfo

type SwarmInfo struct {
	Id         string            `json:"ID"`
	JoinTokens map[string]string `json:"JoinTokens"`
}

Jump to

Keyboard shortcuts

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