client

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2019 License: MIT Imports: 20 Imported by: 0

README

Client

GoDoc

This package contains Inertia's clientside 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/cfg"
    "github.com/ubclaunchpad/inertia/client"
)

func main() {
    // Set up Inertia configuration
    config := cfg.NewConfig("0.3.0", "inertia-deploy-test", /* ... */)

    // Add your remote
    config.AddRemote(&cfg.RemoteVPS{Name: "gcloud", /* ... */ })

    // 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

Overview

Package client provides the interface through which Inertia communicates with a serverside daemon

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.4.0

type Client struct {
	*cfg.RemoteVPS

	SSH SSHSession
	// contains filtered or unexported fields
}

Client manages a deployment

func NewClient added in v0.4.0

func NewClient(remoteName, keyPassphrase string, config *cfg.Config, out ...io.Writer) (*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(version string) error

DaemonUp brings the daemon up on the remote instance.

func (*Client) DisableTotp added in v0.5.0

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

DisableTotp disables Totp for a given user

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) EnableTotp added in v0.5.0

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

EnableTotp enables Totp for a given user

func (*Client) ListEnv added in v0.4.0

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

ListEnv lists environment variables currently set on remote

func (*Client) ListUsers added in v0.4.0

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

ListUsers lists all users on the remote.

func (*Client) LogIn added in v0.5.0

func (c *Client) LogIn(user, password, totp string) (*http.Response, error)

LogIn gets an access token for the user with the given credentials. Use "" for totp if none is required.

func (*Client) Logs added in v0.4.0

func (c *Client) Logs(container string, entries int) (*http.Response, error)

Logs get logs of given container

func (*Client) LogsWebSocket added in v0.4.0

func (c *Client) LogsWebSocket(container string, entries int) (SocketReader, error)

LogsWebSocket opens a websocket connection to given container's logs

func (*Client) Prune added in v0.4.1

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

Prune clears Docker ReadFiles on this remote.

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

func (c *Client) SetSSLVerification(verify bool)

SetSSLVerification toggles whether client should verify all SSL communications. This requires a signed certificate to be in use on your daemon.

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) Token added in v0.5.0

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

Token generates token on this remote.

func (*Client) UninstallInertia added in v0.5.0

func (c *Client) UninstallInertia() error

UninstallInertia removes the inertia/ directory on the remote instance

func (*Client) Up added in v0.4.0

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

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

func (*Client) UpdateEnv added in v0.4.0

func (c *Client) UpdateEnv(name, value string, encrypt, remove bool) (*http.Response, error)

UpdateEnv updates environment variable

type SSHRunner

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

SSHRunner runs commands over SSH and captures results.

func NewSSHRunner

func NewSSHRunner(r *cfg.RemoteVPS, keyPassphrase string) *SSHRunner

NewSSHRunner returns a new SSHRunner

func (*SSHRunner) CopyFile added in v0.4.0

func (r *SSHRunner) CopyFile(file io.Reader, remotePath string, permissions string) error

CopyFile copies given reader to remote

func (*SSHRunner) Run

func (r *SSHRunner) Run(cmd string) (cmdout *bytes.Buffer, cmderr *bytes.Buffer, err error)

Run runs a command remotely.

func (*SSHRunner) RunSession added in v0.1.1

func (r *SSHRunner) RunSession(commands ...string) error

RunSession sets up a SSH shell to the remote

func (*SSHRunner) RunStream added in v0.1.1

func (r *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(commands ...string) error
	CopyFile(f io.Reader, remotePath string, permissions string) error
}

SSHSession can run remote commands over SSH

type SocketReader added in v0.4.0

type SocketReader interface {
	ReadMessage() (messageType int, p []byte, err error)
	Close() error
}

SocketReader is an interface to a websocket connection

Directories

Path Synopsis
Package internal provides compiled scripts and other internal assets
Package internal provides compiled scripts and other internal assets

Jump to

Keyboard shortcuts

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