model

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultProvider = "hetzner"
)

defaults TODO: this will have to be moved somewhere else

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Name           string         `json:"name"`
	Address        string         `json:"address"`
	Mnemonic       string         `json:"mnemonic"`
	GenesisBalance string         `json:"genesis_balance"`
	Validator      bool           `json:"validator"`
	Faucet         bool           `json:"faucet"`
	ConfigLocation ConfigLocation `json:"config_location"`
}

Account represents an Account for a Event

type ConfigLocation

type ConfigLocation struct {
	CLIConfigDir    string `json:"CLIConfigDir"`
	DaemonConfigDir string `json:"DaemonConfigDir"`
}

ConfigLocation holds the paths to the configuration files for the Cosmos-SDK based node and CLI.

type Event

type Event struct {
	TokenSymbol string              `json:"token_symbol"` // token symbool
	Owner       string              `json:"owner"`        // email address of the owner
	Accounts    map[string]*Account `json:"accounts"`
	Provider    string              `json:"provider"` // provider for provisioning
	CreatedOn   time.Time           `json:"created_on"`
	StartsOn    time.Time           `json:"starts_on"`
	EndsOn      time.Time           `json:"ends_on"`
	State       map[string]*Machine `json:"state"`
	Payload     PayloadLocation     `json:"payload"`
}

Event maintain the status of an event

func LoadEvent

func LoadEvent(path string) (evt *Event, err error)

LoadEvent is a convenience function that ensures you don't have to manually create an empty models.Event{} struct and use NewEvent() all the time

func NewEvent

func NewEvent(symbol, owner, provider string, genesisAccounts []GenesisAccount, payload PayloadLocation) (e *Event)

NewEvent helper for a new event

func (*Event) ExtraAccounts

func (e *Event) ExtraAccounts() (a []*Account)

ExtraAccounts returns Event.Accounts excluding accounts that are validators

func (*Event) FaucetAccount

func (e *Event) FaucetAccount() (a *Account)

FaucetAccount returns the first Account found with Faucet = true

func (*Event) FormatAmount

func (e *Event) FormatAmount(a uint64) string

FormatAmount print the amount in a human readable format

func (*Event) Hash

func (e *Event) Hash() string

Hash Generate the event hash

func (*Event) ID

func (e *Event) ID() string

ID generate a event identifier (determinitstic)

func (*Event) NodeID

func (e *Event) NodeID(n int) string

NodeID generate a node identifier (determinitstic)

func (*Event) Validators

func (e *Event) Validators() (v []string, a []*Account)

Validators returns the names (emails) of the validators

func (*Event) ValidatorsCount

func (e *Event) ValidatorsCount() int

ValidatorsCount returns the number of validators

type EventRequest

type EventRequest struct {
	TokenSymbol     string           `yaml:"token_symbol" json:"token_symbol"`
	GenesisAccounts []GenesisAccount `yaml:"genesis_accounts" json:"genesis_accounts"`
	PayloadLocation PayloadLocation  `yaml:"payload_location" json:"payload,omitempty"`
	Owner           string           `yaml:"owner" json:"owner,omitempty"`
	Provider        string           `yaml:"provider" json:"provider,omitempty"`
}

EventRequest holds metadata about the event, including how the genesis.json should be setup

func LoadEventRequestFromFile

func LoadEventRequestFromFile(path string) (eq *EventRequest, err error)

LoadEventRequestFromFile is as convenience function to unmarshal a EventRequest from a YAML file

type GenesisAccount

type GenesisAccount struct {
	Name           string `yaml:"name" json:"name"`
	GenesisBalance string `yaml:"genesis_balance" json:"genesis_balance"`
	Validator      bool   `yaml:"validator" json:"validator"`
	Faucet         bool   `yaml:"faucet" json:"faucet"`
}

GenesisAccount is the configuration of accounts present in the genesis block

type Machine added in v1.0.1

type Machine struct {
	N                string               `json:"N"`
	EventID          string               `json:"EventID"`
	DriverName       string               `json:"DriverName"`
	TendermintNodeID string               `json:"TendermintNodeID"`
	Instance         MachineNetworkConfig `json:"Instance"`
	// contains filtered or unexported fields
}

Machine holds the configuration of a Machine

func (*Machine) HomeDir added in v1.0.1

func (m *Machine) HomeDir() string

HomeDir returns the path of a docker-machine instance home, e.g. /tmp/workspace/evts/drop-xxx/.docker/machine/machines/drop-xxx-0/ TODO: reconcile with duplicate logic from lctrld/common.go

func (*Machine) ID added in v1.0.1

func (m *Machine) ID() string

ID joins the EventID and N, e.g. EventID is evtx-d97517a3673688070aef, N is 1, then it will return evtx-d97517a3673688070aef-1

func (*Machine) TendermintPeerNodeID added in v1.0.1

func (m *Machine) TendermintPeerNodeID() string

TendermintPeerNodeID returns <[email protected]....:26656> which is used in specifying peers to connect to in the daemon's config.toml file

type MachineNetworkConfig added in v1.0.1

type MachineNetworkConfig 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"`
}

MachineNetworkConfig holds information read from docker-machine about the deployed VM's network settings

type PayloadLocation

type PayloadLocation struct {
	DockerImage string `mapstructure:"docker_image" yaml:"docker_image" json:"docker_image"`
	BinaryURL   string `mapstructure:"binary_url" yaml:"binary_url" json:"binary_url"`
	BinaryPath  string `mapstructure:"binary_path" yaml:"binary_path" json:"binary_path"`
	DaemonPath  string `mapstructure:"daemon_path" yaml:"daemon_path" json:"daemon_path"`
	CLIPath     string `mapstructure:"cli_path" yaml:"cli_path" json:"cli_path"`
}

PayloadLocation holds metadata about the copy of the launchpayload that is stored on the machine running LaunchControlD

func NewDefaultPayloadLocation added in v1.0.1

func NewDefaultPayloadLocation() PayloadLocation

NewDefaultPayloadLocation is a placeholder to help code refactoring and reduce import cycles

Jump to

Keyboard shortcuts

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