koble

package
v0.0.0-...-743f219 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2022 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEFAULT_STARTUP = `#!/bin/bash

# Machine.startup - generated by koble machine add
# This is a script that will run when the machine boots

`
View Source
var (
	Koanf = koanf.New(".")
)
View Source
var MAXPRINTWIDTH = 100
View Source
var SHARED_STARTUP = `` /* 180-byte string literal not displayed */
View Source
var VERSION = "0.0.1"

Functions

func BindFlag

func BindFlag(confKey string, f *flag.Flag)

func MachineInfoToStringArr

func MachineInfoToStringArr(machines []driver.MachineInfo, showNS bool) (mlist [][]string, headers []string)

func NetInfoToStringArr

func NetInfoToStringArr(networks []driver.NetInfo, showLab bool) (nlist [][]string, headers []string)

func Reexec

func Reexec()

func RenderTable

func RenderTable(headers []string, list [][]string)

func SaveLab

func SaveLab(lab *Lab) error

Types

type Config

type Config struct {
	// Driver options
	Driver DriverConfig `koanf:"driver"`
	// Verbose (loglevel = Debug)
	Verbosity int `koanf:"verbose"`
	// Quiet (loglevel = error)
	Quiet bool `koanf:"quiet"`
	// Terminal to use, additional terminals and options
	Terminal TermConfig `koanf:"terminal"`
	// Term option overrides
	TermOpts map[string]string `koanf:"term_opts"`
	// whether to launch machines for machine / lab start
	Launch LaunchConfig `koanf:"launch"`
	// Use plain output, e.g. no spinners, no prompts
	// default is false
	NonInteractive bool `koanf:"noninteractive"`
	// Do not use colour in output
	// default is false
	NoColor bool `koanf:"nocolor"`
	// namespace to use when not in a lab
	// default is "GLOBAL"
	Namespace string `koanf:"namespace" validate:"alphanum,max=32"`
	// Wait (if -1 no wait, run in background) is how long in seconds to wait
	// for machines to startup / exit before giving timeout error
	// default is 300
	Wait time.Duration `koanf:"wait"`
	// Amount of memory in MB to use for each machine
	// default is 128
	Machine MachineConfig `koanf:"machine"`
}

type DriverConfig

type DriverConfig struct {
	// Name of driver to use
	Name string `koanf:"name"`
	// extra config, top level key should be driver name
	ExtraConf map[string]interface{} `koanf:"extra,remain"`
}

type InitOpts

type InitOpts struct {
	Name        string
	Description string
	Authors     []string
	Emails      []string
	Webs        []string
}

type Koble

type Koble struct {
	Lab            Lab
	LabRoot        string
	InitialWorkDir string
	Config         Config
	Driver         driver.Driver
}

func Load

func Load() (*Koble, error)

func (*Koble) AddMachineToLab

func (nk *Koble) AddMachineToLab(name string, conf driver.MachineConfig) error

func (*Koble) AddNetworkToLab

func (nk *Koble) AddNetworkToLab(name string, conf driver.NetConfig) error

redo with new viper config

func (*Koble) AttachToMachine

func (nk *Koble) AttachToMachine(machine, term string) error

func (*Koble) Cleanup

func (nk *Koble) Cleanup() (err error)

Return to initial working directory from labroot

func (*Koble) DestroyMachine

func (nk *Koble) DestroyMachine(machine string, out io.Writer) error

func (*Koble) Exec

func (nk *Koble) Exec(machine, command, user string,
	detach bool, workdir string) error

func (*Koble) ForMachine

func (nk *Koble) ForMachine(headerFunc func(string) string, titlePref string, filterList []string, toRun func(name string, mconf driver.MachineConfig, out output.Output) error) error

func (*Koble) GetMachineList

func (nk *Koble) GetMachineList(mlist []string,
	all bool) (machines []driver.Machine, err error)

func (*Koble) InitLab

func (nk *Koble) InitLab(options InitOpts) error

func (*Koble) LabDestroy

func (nk *Koble) LabDestroy(mlist []string) error

func (*Koble) LabInfo

func (nk *Koble) LabInfo() error

func (*Koble) LabRemove

func (nk *Koble) LabRemove(mlist []string) error

func (*Koble) LabStart

func (nk *Koble) LabStart(mlist []string) error

func (*Koble) LabStop

func (nk *Koble) LabStop(mlist []string, force bool) error

func (*Koble) LaunchInTerm

func (nk *Koble) LaunchInTerm(machine, terminal, command string) error

func (*Koble) ListMachines

func (nk *Koble) ListMachines(all, json bool) error

func (*Koble) ListNetworks

func (nk *Koble) ListNetworks(all, json bool) error

func (*Koble) MachineInfo

func (nk *Koble) MachineInfo(name string, json bool) error

func (*Koble) MachineLogs

func (nk *Koble) MachineLogs(machine string, follow bool, tail int) error

func (*Koble) NetworkInfo

func (nk *Koble) NetworkInfo(name string, json bool) error

func (*Koble) RemoveMachine

func (nk *Koble) RemoveMachine(name string, out io.Writer) error

func (*Koble) Shell

func (nk *Koble) Shell(machine, user, workdir string) error

func (*Koble) StartMachine

func (nk *Koble) StartMachine(name string, conf driver.MachineConfig,
	attachTerm string, out io.Writer) error

func (*Koble) StartNetwork

func (nk *Koble) StartNetwork(name string, conf driver.NetConfig) error

func (*Koble) StopMachine

func (nk *Koble) StopMachine(name string, force bool, out io.Writer) error

type Lab

type Lab struct {
	Name         string                          `koanf:"-" validate:"alphanum,max=30"`
	Directory    string                          `koanf:"-"`
	CreatedAt    string                          `koanf:"created_at" validate:"datetime=02-01-2006"`
	KobleVersion string                          `koanf:"koble_version"`
	Description  string                          `koanf:"description"`
	Authors      []string                        `koanf:"authors"`
	Emails       []string                        `koanf:"emails" validate:"dive,email"`
	Webs         []string                        `koanf:"web" validate:"dive,url"`
	Machines     map[string]driver.MachineConfig `koanf:"machines"`
	Networks     map[string]driver.NetConfig     `koanf:"networks" mapstructure:"networks"`
}

func (*Lab) Header

func (lab *Lab) Header(titlePref string) string

type LaunchConfig

type LaunchConfig struct {
	MachineStart bool `koanf:"machine_start"`
	LabStart     bool `koanf:"lab_start"`
}

type LaunchOptions

type LaunchOptions struct {
	Command   string
	Machine   string
	Lab       string
	Namespace string
	Options   map[string]string
}

type MachineConfig

type MachineConfig struct {
	// Amount of memory in MB to use for each machine
	// default is 128
	MachineMemory int `koanf:"memory"`
}

type TermConfig

type TermConfig struct {
	// name of default terminal to open
	// by default this is gnome
	Default string `koanf:"default"`
	// name of terminal to use for attach commands
	// by default this uses the terminal set for 'default'
	Attach string `koanf:"attach"`
	// name of terminal to use for shell commands
	// by default this uses the terminal set for 'default'
	Shell string `koanf:"shell"`
	// name of terminal to use for shell commands
	// by default this is set to 'this' (no terminal)
	Exec string `koanf:"exec"`
	// name of terminal to use for attaching on machine start
	// by default this uses the terminal set for 'default'
	MachineStart string `koanf:"machine_start"`
	// name of terminal to use for attaching on lab start
	// by default this uses the terminal set for 'default'
	LabStart string `koanf:"lab_start"`
	// extra terminal command and option definitions
	Terminals map[string]Terminal `koanf:"terminals,remain"`
}

type Terminal

type Terminal struct {
	Command []string          `koanf:"command"`
	Options map[string]string `koanf:"options"`
}

Jump to

Keyboard shortcuts

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