providers

package
v0.0.0-...-c456e04 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package providers defines the interfaces that LazySSH provider implementations must conform to.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(id string, f Factory)

Register registers a provider factory.

Types

type Factories

type Factories map[string]Factory

Factories is an index of Factory objects by Machine type name.

var (
	FactoryMap Factories
)

type Factory

type Factory interface {
	NewProvider(target string, hclBlock hcl.Body) (Provider, error)
}

Factory produces a Provider for a specific type of Machine, based on 'target' configuration provided by the user.

type Machine

type Machine struct {
	// ModActive messages indicate activity on the Machine. A message +1
	// indicates a new forwarded TCP connection is opened, and a message -1
	// indicates a TCP connection was closed.
	ModActive chan int8
	// Translate messages are requests to translate SSH direct-tcpip parameters
	// to a Dialer address. The provider should not process/reply to these
	// messages until it has verified connectivity to the Machine.
	Translate chan *TranslateMsg
	// Stop messages are sent by the Manager to request the Machine immediately
	// shut down.
	Stop chan struct{}
	// State can be used by the provider to store machine-specific state.
	State interface{}
}

Machine represents a running machine, and holds channels via which the Provider receives commands from the Manager.

type Provider

type Provider interface {
	// IsShared indicates if multiple connections to the same target will not
	// start a new Machine if one is already running.
	//
	// Called from the Manager message loop goroutine, and should not block.
	IsShared() bool

	// RunMachine is responsible for managing the entire Machine lifecycle.
	//
	// Runs on a dedicated goroutine per machine, so is free to block.
	//
	// Typically, the Provider will immediately make external calls to start the
	// machine, wait for proper connectivity to the Machine, then go into a loop
	// processing the messages on the various channels on the Machine struct.
	//
	// Once the Provider determines there is no more activity via ModActive
	// messages, or when it receives a Stop message, it exits the message loop
	// and makes the necessary external calls to stop the machine again.
	// Specifically, this method should not return without stopping the machine.
	RunMachine(mach *Machine)
}

Provider is responsible for managing the Machine lifecycle.

Structs implementing Provider encapsulate parsed and validated 'target' configuration, and are created by the associated Factory for the type of Machine requested.

Note that methods on Provider may be called from different goroutines. See the documentation of each method for details.

type Providers

type Providers map[string]Provider

Providers is an index of configured Provider instances by Machine type name.

type TranslateMsg

type TranslateMsg struct {
	// Addr is the address the SSH client wants to connect to. It contains user
	// input verbatim, so may be a IP address, hostname, etc.
	Addr string
	// Port is the TCP port the SSH client wants to connect to.
	Port uint16
	// Reply is the channel the translation result is sent to. The result is a
	// Dailer address used to make the actual TCP connection to the Machine. The
	// provider should not send a reply until it has verified connectivity to the
	// Machine.
	Reply chan string
}

TranslateMsg is the type sent on the Machine Translate channel.

Directories

Path Synopsis
Implements the 'aws_ec2' target type, which uses AWS SDK to create and terminate EC2 virtual machines.
Implements the 'aws_ec2' target type, which uses AWS SDK to create and terminate EC2 virtual machines.
Implements the 'forward' type, which is essentially a dummy that doesn't really make any external calls, but simply forwards connections to a fixed address.
Implements the 'forward' type, which is essentially a dummy that doesn't really make any external calls, but simply forwards connections to a fixed address.
Implements the 'hcloud' target type, which uses HCLOUD SDK to create and terminate hcloud virtual machines.
Implements the 'hcloud' target type, which uses HCLOUD SDK to create and terminate hcloud virtual machines.
Implements the 'virtualbox' target type, which uses the VirtualBox CLI to start/stop existing virtual machines.
Implements the 'virtualbox' target type, which uses the VirtualBox CLI to start/stop existing virtual machines.

Jump to

Keyboard shortcuts

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