lctrld

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddGenesisAccounts

func AddGenesisAccounts(settings config.Schema, evt *model.Event, runCommand CommandRunner) (err error)

AddGenesisAccounts runs gaiad add-genesis-account with the created addresses and default initial balances

func CollectGenesisTxs

func CollectGenesisTxs(settings config.Schema, evt *model.Event, runCommand CommandRunner) (err error)

CollectGenesisTxs is run on every node's config directory from the single directory where the genesis transactions were placed before. In the end, only the first node's genesis.json will be used.

func ConfigurePayload

func ConfigurePayload(settings config.Schema, evt *model.Event, cmdRunner CommandRunner) (err error)

ConfigurePayload is a wrapper function that runs all the needed steps to generate a payload's configuration and fills out the evt object with said information.

func CreateEvent

func CreateEvent(settings config.Schema, evt *model.Event) (err error)

CreateEvent creates the event home and the event descriptor

func DeployPayload

func DeployPayload(settings config.Schema, evt *model.Event, cmdRunner CommandRunner, dmc DockerMachineInterface) (err error)

DeployPayload tells the provisioned machines to run the configured docker image

func DestroyEvent

func DestroyEvent(settings config.Schema, evt *model.Event, cmdRunner CommandRunner) (err error)

DestroyEvent destroy an existing event

func DownloadPayloadBinary

func DownloadPayloadBinary(settings config.Schema, evt *model.Event, runCommand CommandRunner) (err error)

DownloadPayloadBinary downloads a copy of the payload binaries to the host running lctrld to generate the config files for the provisioned machines

func EditConfigs

func EditConfigs(settings config.Schema, evt *model.Event, runCommand CommandRunner) (err error)

EditConfigs edits the config.toml of every node to have the same persistent_peers.

func GenerateFaucetConfig

func GenerateFaucetConfig(settings config.Schema, evt *model.Event, runCommand CommandRunner) (err error)

GenerateFaucetConfig generates a configuration for the faucet given what it knows about the event

func GenerateKeys

func GenerateKeys(settings config.Schema, evt *model.Event, runCommand CommandRunner) (*model.Event, error)

GenerateKeys generates keys for each genesis account (this includes validator accounts). The specific command is gaiacli keys add validatoremail/some other name -o json --keyring-backend test --home.... for each node.

func GenesisTxs

func GenesisTxs(settings config.Schema, evt *model.Event, runCommand CommandRunner) (err error)

GenesisTxs runs gentx to turn accounts into validator accounts and outputs the genesis transactions into a single folder.

func GetEventByID

func GetEventByID(settings config.Schema, ID string) (event model.Event, err error)

GetEventByID retrieve an event by name

func InitDaemon

func InitDaemon(settings config.Schema, evt *model.Event, runCommand CommandRunner) (*model.Event, error)

InitDaemon runs gaiad init burnerchain --home state.DaemonConfigDir and gaiad tendermint show-node-id

func InspectEvent

func InspectEvent(settings config.Schema, evt *model.Event, cmdRunner CommandRunner) (err error)

InspectEvent inspect status of the infrastructure for an event

func InstallDockerMachine

func InstallDockerMachine(settings config.Schema) (err error)

InstallDockerMachine setup docker machine environment

func ListEvents

func ListEvents(settings config.Schema) (events []model.Event, err error)

ListEvents list available events

func LoadEvent

func LoadEvent(settings config.Schema, evtID string) (evt *model.Event, err error)

LoadEvent returns the Event model of the specified event ID

func Provision

func Provision(settings config.Schema, evt *model.Event, cmdRunner CommandRunner, dmc DockerMachineInterface) (err error)

Provision provision the infrastructure for the event

func RereadDockerMachineInfo

func RereadDockerMachineInfo(settings config.Schema, evt *model.Event, dmc DockerMachineInterface) (event *model.Event, err error)

RereadDockerMachineInfo is useful when docker-machine failed during 'create', and a human fixed the problem, and wants to continue

func RunCommand

func RunCommand(command, envVars []string) (out string, err error)

RunCommand runs a command

func SetupWorkspace

func SetupWorkspace(settings config.Schema) (err error)

SetupWorkspace setup the workspace for the service

func StoreEvent

func StoreEvent(settings config.Schema, evt *model.Event) (err error)

StoreEvent saves the Event model to a file

Types

type CommandRunner

type CommandRunner func([]string, []string) (string, error)

CommandRunner func type allows for mocking out RunCommand()

type DockerMachineConfig

type DockerMachineConfig struct {
	EventID  string
	Settings config.Schema
}

DockerMachineConfig holds information that lets lctrld read the state of a docker-machine provisioning

func NewDockerMachineConfig

func NewDockerMachineConfig(settings config.Schema, eventID string) *DockerMachineConfig

NewDockerMachineConfig ensures that all fields of a DockerMachineConfig are filled out

func (*DockerMachineConfig) HomeDir

func (dmc *DockerMachineConfig) HomeDir(machineN string) string

HomeDir returns the path of a docker-machine instance home, e.g. /tmp/workspace/evts/drop-xxx/.docker/machine/machines/drop-xxx-0/

func (*DockerMachineConfig) ReadConfig

func (dmc *DockerMachineConfig) ReadConfig(machineN string) (mc *model.MachineConfig, err error)

ReadConfig return configuration of a docker machine

type DockerMachineConfigFormat

type DockerMachineConfigFormat struct {
	ConfigVersion int `json:"ConfigVersion"`
	Driver        struct {
		IPAddress      string `json:"IPAddress"`
		MachineName    string `json:"MachineName"`
		SSHUser        string `json:"SSHUser"`
		SSHPort        int    `json:"SSHPort"`
		SSHKeyPath     string `json:"SSHKeyPath"`
		StorePath      string `json:"StorePath"`
		SwarmMaster    bool   `json:"SwarmMaster"`
		SwarmHost      string `json:"SwarmHost"`
		SwarmDiscovery string `json:"SwarmDiscovery"`
		VBoxManager    struct {
		} `json:"VBoxManager"`
		HostInterfaces struct {
		} `json:"HostInterfaces"`
		CPU                 int    `json:"CPU"`
		Memory              int    `json:"Memory"`
		DiskSize            int    `json:"DiskSize"`
		NatNicType          string `json:"NatNicType"`
		Boot2DockerURL      string `json:"Boot2DockerURL"`
		Boot2DockerImportVM string `json:"Boot2DockerImportVM"`
		HostDNSResolver     bool   `json:"HostDNSResolver"`
		HostOnlyCIDR        string `json:"HostOnlyCIDR"`
		HostOnlyNicType     string `json:"HostOnlyNicType"`
		HostOnlyPromiscMode string `json:"HostOnlyPromiscMode"`
		UIType              string `json:"UIType"`
		HostOnlyNoDHCP      bool   `json:"HostOnlyNoDHCP"`
		NoShare             bool   `json:"NoShare"`
		DNSProxy            bool   `json:"DNSProxy"`
		NoVTXCheck          bool   `json:"NoVTXCheck"`
		ShareFolder         string `json:"ShareFolder"`
	} `json:"Driver"`
	DriverName  string `json:"DriverName"`
	HostOptions struct {
		Driver        string `json:"Driver"`
		Memory        int    `json:"Memory"`
		Disk          int    `json:"Disk"`
		EngineOptions struct {
			ArbitraryFlags   []interface{} `json:"ArbitraryFlags"`
			DNS              interface{}   `json:"Dns"`
			GraphDir         string        `json:"GraphDir"`
			Env              []interface{} `json:"Env"`
			Ipv6             bool          `json:"Ipv6"`
			InsecureRegistry []interface{} `json:"InsecureRegistry"`
			Labels           []interface{} `json:"Labels"`
			LogLevel         string        `json:"LogLevel"`
			StorageDriver    string        `json:"StorageDriver"`
			SelinuxEnabled   bool          `json:"SelinuxEnabled"`
			TLSVerify        bool          `json:"TlsVerify"`
			RegistryMirror   []interface{} `json:"RegistryMirror"`
			InstallURL       string        `json:"InstallURL"`
		} `json:"EngineOptions"`
		SwarmOptions struct {
			IsSwarm            bool          `json:"IsSwarm"`
			Address            string        `json:"Address"`
			Discovery          string        `json:"Discovery"`
			Agent              bool          `json:"Agent"`
			Master             bool          `json:"Master"`
			Host               string        `json:"Host"`
			Image              string        `json:"Image"`
			Strategy           string        `json:"Strategy"`
			Heartbeat          int           `json:"Heartbeat"`
			Overcommit         int           `json:"Overcommit"`
			ArbitraryFlags     []interface{} `json:"ArbitraryFlags"`
			ArbitraryJoinFlags []interface{} `json:"ArbitraryJoinFlags"`
			Env                interface{}   `json:"Env"`
			IsExperimental     bool          `json:"IsExperimental"`
		} `json:"SwarmOptions"`
		AuthOptions struct {
			CertDir              string        `json:"CertDir"`
			CaCertPath           string        `json:"CaCertPath"`
			CaPrivateKeyPath     string        `json:"CaPrivateKeyPath"`
			CaCertRemotePath     string        `json:"CaCertRemotePath"`
			ServerCertPath       string        `json:"ServerCertPath"`
			ServerKeyPath        string        `json:"ServerKeyPath"`
			ClientKeyPath        string        `json:"ClientKeyPath"`
			ServerCertRemotePath string        `json:"ServerCertRemotePath"`
			ServerKeyRemotePath  string        `json:"ServerKeyRemotePath"`
			ClientCertPath       string        `json:"ClientCertPath"`
			ServerCertSANs       []interface{} `json:"ServerCertSANs"`
			StorePath            string        `json:"StorePath"`
		} `json:"AuthOptions"`
	} `json:"HostOptions"`
	Name string `json:"Name"`
}

DockerMachineConfigFormat is the structure of .docker/machine/machines/<MACHINE NAME>/config.json, which describes a deployed VM's configuration

type DockerMachineInterface

type DockerMachineInterface interface {
	HomeDir(string) string
	ReadConfig(string) (*model.MachineConfig, error)
}

DockerMachineInterface is a mocking interface for functions that need to read docker-machine config files

Jump to

Keyboard shortcuts

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