client

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2018 License: MIT Imports: 20 Imported by: 2

README

Client

GoDoc

This package contains Inertia's clientside configuration and interface to remote Inertia daemons.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NoInertiaRemote is used to warn about missing inertia remote
	NoInertiaRemote = "No inertia remote"
)

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func GetConfigFilePath

func GetConfigFilePath() (string, error)

GetConfigFilePath returns the absolute path of the config file.

func InitializeInertiaProject

func InitializeInertiaProject(version, buildType string) error

InitializeInertiaProject creates the inertia config folder and returns an error if we're not in a git project.

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Config

type Config struct {
	Version   string       `toml:"inertia"`
	Project   string       `toml:"project-name"`
	BuildType string       `toml:"build-type"`
	Remotes   []*RemoteVPS `toml:"remote"`
	Writer    io.Writer    `toml:"-"`
}

Config represents the current projects configuration.

func GetProjectConfigFromDisk

func GetProjectConfigFromDisk() (*Config, error)

GetProjectConfigFromDisk returns the current project's configuration. If an .inertia folder is not found, it returns an error.

func (*Config) AddRemote

func (config *Config) AddRemote(remote *RemoteVPS)

AddRemote adds a remote to configuration

func (*Config) GetRemote

func (config *Config) GetRemote(name string) (*RemoteVPS, bool)

GetRemote retrieves a remote by name

func (*Config) RemoveRemote

func (config *Config) RemoveRemote(name string) bool

RemoveRemote removes remote with given name

func (*Config) Write

func (config *Config) Write() error

Write writes configuration to Inertia config file.

type DaemonConfig

type DaemonConfig struct {
	Port    string `toml:"port"`
	SSHPort string `toml:"ssh_port"`
	Token   string `toml:"token"`
	Secret  string `toml:"secret"`
}

DaemonConfig contains parameters for the Daemon

type Deployment

type Deployment struct {
	*RemoteVPS
	Repository *git.Repository
	Auth       string
	Project    string
	BuildType  string
}

Deployment manages a deployment

func GetDeployment

func GetDeployment(name string) (*Deployment, error)

GetDeployment returns the local deployment setup

func (*Deployment) AddUser added in v0.3.0

func (d *Deployment) AddUser(username, password string, admin bool) (*http.Response, error)

AddUser adds an authorized user for access to Inertia Web

func (*Deployment) Down

func (d *Deployment) Down() (*http.Response, error)

Down brings the project down on the remote VPS instance specified in the configuration object.

func (*Deployment) ListUsers added in v0.3.0

func (d *Deployment) ListUsers() (*http.Response, error)

ListUsers lists all users on the remote.

func (*Deployment) Logs

func (d *Deployment) Logs(stream bool, container string) (*http.Response, error)

Logs get logs of given container

func (*Deployment) RemoveUser added in v0.3.0

func (d *Deployment) RemoveUser(username string) (*http.Response, error)

RemoveUser prevents a user from accessing Inertia Web

func (*Deployment) Reset

func (d *Deployment) Reset() (*http.Response, error)

Reset shuts down deployment and deletes the contents of the deployment's project directory

func (*Deployment) ResetUsers added in v0.3.0

func (d *Deployment) ResetUsers() (*http.Response, error)

ResetUsers resets all users on the remote.

func (*Deployment) Status

func (d *Deployment) Status() (*http.Response, error)

Status lists the currently active containers on the remote VPS instance

func (*Deployment) Up

func (d *Deployment) Up(buildType string, stream bool) (*http.Response, error)

Up brings the project up on the remote VPS instance specified in the deployment object.

type RemoteVPS

type RemoteVPS struct {
	Name   string        `toml:"name"`
	IP     string        `toml:"IP"`
	User   string        `toml:"user"`
	PEM    string        `toml:"pemfile"`
	Branch string        `toml:"branch"`
	Daemon *DaemonConfig `toml:"daemon"`
}

RemoteVPS contains parameters for the VPS

func (*RemoteVPS) Bootstrap

func (remote *RemoteVPS) Bootstrap(runner SSHSession, name string, config *Config) error

Bootstrap configures a remote vps for continuous deployment by installing docker, starting the daemon and building a public-private key-pair. It outputs configuration information for the user.

func (*RemoteVPS) DaemonDown

func (remote *RemoteVPS) DaemonDown(session SSHSession) error

DaemonDown brings the daemon down on the remote instance

func (*RemoteVPS) DaemonUp

func (remote *RemoteVPS) DaemonUp(session SSHSession, daemonVersion, host, daemonPort string) error

DaemonUp brings the daemon up on the remote instance.

func (*RemoteVPS) GetHost

func (remote *RemoteVPS) GetHost() string

GetHost creates the user@IP string.

func (*RemoteVPS) GetIPAndPort

func (remote *RemoteVPS) GetIPAndPort() string

GetIPAndPort creates the IP:Port string.

type SSHRunner

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

SSHRunner runs commands over SSH and captures results.

func NewSSHRunner

func NewSSHRunner(r *RemoteVPS) *SSHRunner

NewSSHRunner returns a new SSHRunner

func (*SSHRunner) Run

func (runner *SSHRunner) Run(cmd string) (*bytes.Buffer, *bytes.Buffer, error)

Run runs a command remotely.

func (*SSHRunner) RunSession added in v0.1.1

func (runner *SSHRunner) RunSession() error

RunSession sets up a SSH shell to the remote

func (*SSHRunner) RunStream added in v0.1.1

func (runner *SSHRunner) RunStream(cmd string, interactive bool) error

RunStream remotely executes given command, streaming its output and opening up an optionally interactive session

type SSHSession

type SSHSession interface {
	Run(cmd string) (*bytes.Buffer, *bytes.Buffer, error)
	RunStream(cmd string, interactive bool) error
	RunSession() error
}

SSHSession can run remote commands over SSH

Jump to

Keyboard shortcuts

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