cluster

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NotCreated status of a machine
	NotCreated = "Not created"
	// Stopped status of a machine
	Stopped = "Stopped"
	// Running status of a machine
	Running = "Running"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	// contains filtered or unexported fields
}

Cluster is a running cluster.

func New

func New(conf config.Config) (*Cluster, error)

New creates a new cluster. It takes as input the description of the cluster and its machines.

func NewFromFile

func NewFromFile(path string) (*Cluster, error)

NewFromFile creates a new Cluster from a YAML serialization of its configuration available in the provided file.

func NewFromYAML

func NewFromYAML(data []byte) (*Cluster, error)

NewFromYAML creates a new Cluster from a YAML serialization of its configuration available in the provided string.

func (*Cluster) Create

func (c *Cluster) Create() error

Create creates the cluster.

func (*Cluster) CreateMachine

func (c *Cluster) CreateMachine(machine *Machine, i int) error

CreateMachine creates and starts a new machine in the cluster.

func (*Cluster) Delete

func (c *Cluster) Delete() error

Delete deletes the cluster.

func (*Cluster) DeleteMachine

func (c *Cluster) DeleteMachine(machine *Machine, i int) error

DeleteMachine remove a Machine from the cluster.

func (*Cluster) Inspect

func (c *Cluster) Inspect(hostnames []string) ([]*Machine, error)

Inspect will generate information about running or stopped machines.

func (*Cluster) Name

func (c *Cluster) Name() string

Name returns the cluster name.

func (*Cluster) NewMachine

func (c *Cluster) NewMachine(spec *config.Machine) *Machine

NewMachine creates a new Machine in the cluster.

func (*Cluster) SSH

func (c *Cluster) SSH(nodename string, username string, remoteArgs ...string) error

SSH logs into the name machine with SSH.

func (*Cluster) Save

func (c *Cluster) Save(path string) error

Save writes the Cluster configure to a file.

func (*Cluster) SetKeyStore

func (c *Cluster) SetKeyStore(keyStore *KeyStore) *Cluster

SetKeyStore provides a store where to persist public keys for this Cluster.

func (*Cluster) Start

func (c *Cluster) Start(machineNames []string) error

Start starts the machines in cluster.

func (*Cluster) StartMachines

func (c *Cluster) StartMachines(machineNames []string) error

StartMachines starts specific machines(s) in cluster

func (*Cluster) Stop

func (c *Cluster) Stop(machineNames []string) error

Stop stops the machines in cluster.

type Container

type Container struct {
	ID string
}

Container represents a running machine.

type Formatter

type Formatter interface {
	Format(io.Writer, []*Machine) error
}

Formatter formats a slice of machines and outputs the result in a given format.

type JSONFormatter

type JSONFormatter struct{}

JSONFormatter formats a slice of machines into a JSON and outputs it to stdout.

func (JSONFormatter) Format

func (JSONFormatter) Format(w io.Writer, machines []*Machine) error

Format will output to stdout in JSON format.

func (JSONFormatter) FormatSingle

func (JSONFormatter) FormatSingle(w io.Writer, m *Machine) error

FormatSingle is a json formatter for a single machine.

type KeyStore

type KeyStore struct {
	// contains filtered or unexported fields
}

KeyStore is a store for public keys.

func NewKeyStore

func NewKeyStore(basePath string) *KeyStore

NewKeyStore creates a new KeyStore

func (*KeyStore) Get

func (s *KeyStore) Get(name string) ([]byte, error)

Get retrieves a key from the store.

func (*KeyStore) Init

func (s *KeyStore) Init() error

Init initializes the key store, creating the store directory if needed.

func (*KeyStore) Remove

func (s *KeyStore) Remove(name string) error

Remove removes a key from the store.

func (*KeyStore) Store

func (s *KeyStore) Store(name, key string) error

Store adds the key to the store.

type Machine

type Machine struct {
	// contains filtered or unexported fields
}

Machine is a single machine.

func (*Machine) ContainerName

func (m *Machine) ContainerName() string

ContainerName is the name of the running container corresponding to this Machine.

func (*Machine) HostPort

func (m *Machine) HostPort(containerPort int) (int, error)

HostPort returns the host port corresponding to the given container port.

func (*Machine) Hostname

func (m *Machine) Hostname() string

Hostname is the machine hostname.

func (*Machine) IsCreated

func (m *Machine) IsCreated() bool

IsCreated returns if a machine is has been created. A created machine could either be running or stopped.

func (*Machine) IsStarted

func (m *Machine) IsStarted() bool

IsStarted returns if a machine is currently started or not.

func (*Machine) Status

func (m *Machine) Status() *MachineStatus

Status returns the machine status.

type MachineStatus

type MachineStatus struct {
	Container       string            `json:"container"`
	State           string            `json:"state"`
	Spec            *config.Machine   `json:"spec,omitempty"`
	Ports           []port            `json:"ports"`
	Hostname        string            `json:"hostname"`
	Image           string            `json:"image"`
	Command         string            `json:"cmd"`
	IP              string            `json:"ip"`
	RuntimeNetworks []*RuntimeNetwork `json:"runtimeNetworks,omitempty"`
}

MachineStatus is the runtime status of a Machine.

type RuntimeNetwork

type RuntimeNetwork struct {
	// Name of the network
	Name string `json:"name,omitempty"`
	// IP of the container
	IP string `json:"ip,omitempty"`
	// Mask of the network
	Mask string `json:"mask,omitempty"`
	// Gateway of the network
	Gateway string `json:"gateway,omitempty"`
}

RuntimeNetwork contains information about the network

func NewRuntimeNetworks

func NewRuntimeNetworks(networks map[string]*network.EndpointSettings) []*RuntimeNetwork

NewRuntimeNetworks returns a slice of networks

type TableFormatter

type TableFormatter struct{}

TableFormatter formats a slice of machines into a colored table like output and prints that to stdout.

func (TableFormatter) Format

func (TableFormatter) Format(w io.Writer, machines []*Machine) error

Format will output to stdout in table format.

Jump to

Keyboard shortcuts

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