client

package
v0.4.0-rc1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2018 License: MIT Imports: 20 Imported by: 0

README

Client

GoDoc

This package contains Inertia's clientside configuration and interface to remote Inertia daemons. It can be imported for use if you don't like the CLI - for example:

package main

import "github.com/ubclaunchpad/inertia/client"

func main() {
    // Set up Inertia
    config := client.NewConfig(
        "0.3.0", "inertia-deploy-test", "docker-compose",
    )
    
    // Add your remote
    config.AddRemote(&client.RemoteVPS{
        Name: "gcloud", // ...params
    })

    // Set up client, remote, and deploy your project
    cli, _ := client.NewClient("gcloud", config)
    cli.BootstrapRemote()
    cli.Up("git@github.com:ubclaunchpad/inertia.git", "", false)
}

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 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 Client added in v0.4.0

type Client struct {
	*RemoteVPS
	// contains filtered or unexported fields
}

Client manages a deployment

func NewClient added in v0.4.0

func NewClient(remoteName string, config *Config) (*Client, bool)

NewClient sets up a client to communicate to the daemon at the given named remote.

func (*Client) AddUser added in v0.4.0

func (c *Client) AddUser(username, password string, admin bool) (*http.Response, error)

AddUser adds an authorized user for access to Inertia Web

func (*Client) BootstrapRemote added in v0.4.0

func (c *Client) BootstrapRemote(repoName string) error

BootstrapRemote 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 (*Client) DaemonDown added in v0.4.0

func (c *Client) DaemonDown() error

DaemonDown brings the daemon down on the remote instance

func (*Client) DaemonUp added in v0.4.0

func (c *Client) DaemonUp(daemonVersion, host, daemonPort string) error

DaemonUp brings the daemon up on the remote instance.

func (*Client) Down added in v0.4.0

func (c *Client) Down() (*http.Response, error)

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

func (*Client) ListUsers added in v0.4.0

func (c *Client) ListUsers() (*http.Response, error)

ListUsers lists all users on the remote.

func (*Client) Logs added in v0.4.0

func (c *Client) Logs(stream bool, container string) (*http.Response, error)

Logs get logs of given container

func (*Client) RemoveUser added in v0.4.0

func (c *Client) RemoveUser(username string) (*http.Response, error)

RemoveUser prevents a user from accessing Inertia Web

func (*Client) Reset added in v0.4.0

func (c *Client) Reset() (*http.Response, error)

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

func (*Client) ResetUsers added in v0.4.0

func (c *Client) ResetUsers() (*http.Response, error)

ResetUsers resets all users on the remote.

func (*Client) Status added in v0.4.0

func (c *Client) Status() (*http.Response, error)

Status lists the currently active containers on the remote VPS instance

func (*Client) Up added in v0.4.0

func (c *Client) Up(gitRemoteURL, buildType string, stream bool) (*http.Response, error)

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

type Config

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

Config represents the current projects configuration.

func NewConfig

func NewConfig(version, project, buildType string) *Config

NewConfig sets up Inertia configuration with given properties

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(filePath string, writers ...io.Writer) error

Write writes configuration to Inertia config file at path. Optionally takes io.Writers.

type DaemonConfig

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

DaemonConfig contains parameters for the Daemon

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"`
	SSHPort string        `toml:"ssh_port"`
	Daemon  *DaemonConfig `toml:"daemon"`
}

RemoteVPS contains parameters for the VPS

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