inertia: Index | Files | Directories

package client

import ""

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


Package Files

client.go doc.go socket.go sshc.go users.go util.go


var (
    // ErrNeedTotp is used to indicate that a 2FA-enabled user has not provided a TOTP
    ErrNeedTotp = errors.New("TOTP is needed for user")
var MinDaemonVersion = semver.Version{Major: 0, Minor: 6, Patch: 2}

MinDaemonVersion is the minimum inertiad version supported by this library

type AuthenticateRequest Uses

type AuthenticateRequest struct {
    User     string
    Password string
    TOTP     string

AuthenticateRequest denotes options for authenticating with the Inertia daemon

type Client Uses

type Client struct {
    Remote *cfg.Remote
    // contains filtered or unexported fields

Client manages a deployment

func NewClient Uses

func NewClient(remote *cfg.Remote, opts Options) (*Client, error)

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

func (*Client) Down Uses

func (c *Client) Down(ctx context.Context) error

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

func (*Client) GetSSHClient Uses

func (c *Client) GetSSHClient() (*SSHClient, error)

GetSSHClient instantiates an SSH client for Inertia-related commands

func (*Client) GetUserClient Uses

func (c *Client) GetUserClient() *UserClient

GetUserClient instantiates an API client for Inertia user management commands

func (*Client) ListEnv Uses

func (c *Client) ListEnv(ctx context.Context) ([]string, error)

ListEnv lists environment variables currently set on remote

func (*Client) Logs Uses

func (c *Client) Logs(ctx context.Context, req LogsRequest) ([]string, error)

Logs get logs of given container

func (*Client) LogsWithOutput Uses

func (c *Client) LogsWithOutput(ctx context.Context, req LogsRequest) error

LogsWithOutput opens a websocket connection to given container's logs and streams it to the given io.Writer

func (*Client) Prune Uses

func (c *Client) Prune(ctx context.Context) error

Prune clears Docker ReadFiles on this remote.

func (*Client) Reset Uses

func (c *Client) Reset(ctx context.Context) error

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

func (*Client) Status Uses

func (c *Client) Status(ctx context.Context) (*api.DeploymentStatusWithVersions, error)

Status lists the currently active containers on the remote VPS instance

func (*Client) Token Uses

func (c *Client) Token(ctx context.Context) (token string, err error)

Token generates token on this remote.

func (*Client) Up Uses

func (c *Client) Up(ctx context.Context, req UpRequest) error

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

func (*Client) UpWithOutput Uses

func (c *Client) UpWithOutput(ctx context.Context, req UpRequest) error

UpWithOutput blocks and streams 'up' output to the client's io.Writer

func (*Client) UpdateEnv Uses

func (c *Client) UpdateEnv(ctx context.Context, name, value string, encrypt, remove bool) error

UpdateEnv updates environment variable

func (*Client) WithDebug Uses

func (c *Client) WithDebug(debug bool)

WithDebug sets the client's debug mode

func (*Client) WithWriter Uses

func (c *Client) WithWriter(out io.Writer)

WithWriter sets the given io.Writer as the client's default output

type LogsRequest Uses

type LogsRequest struct {
    Container string
    Entries   int

LogsRequest denotes parameters for log querying

type Options Uses

type Options struct {
    SSH   runner.SSHOptions
    Out   io.Writer
    Debug bool

Options denotes configuration options for a Client

type SSHClient Uses

type SSHClient struct {
    // contains filtered or unexported fields

SSHClient implements Inertia's SSH commands

func (*SSHClient) AssignAPIToken Uses

func (s *SSHClient) AssignAPIToken() error

AssignAPIToken generates an API token and assigns it to client.Remote

func (*SSHClient) DaemonDown Uses

func (s *SSHClient) DaemonDown() error

DaemonDown brings the daemon down on the remote instance

func (*SSHClient) DaemonUp Uses

func (s *SSHClient) DaemonUp() error

DaemonUp brings the daemon up on the remote instance.

func (*SSHClient) GenerateKeys Uses

func (s *SSHClient) GenerateKeys() (string, error)

GenerateKeys creates a public-private key-pair on the remote vps and returns the public key.

func (*SSHClient) GetRunner Uses

func (s *SSHClient) GetRunner() runner.SSHSession

GetRunner returns the SSH client's underlying session

func (*SSHClient) InstallDocker Uses

func (s *SSHClient) InstallDocker() error

InstallDocker installs docker on a remote vps.

func (*SSHClient) UninstallInertia Uses

func (s *SSHClient) UninstallInertia() error

UninstallInertia removes the inertia/ directory on the remote instance

type SocketReader Uses

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

SocketReader is an interface to a websocket connection

type UpRequest Uses

type UpRequest struct {
    Project string
    URL     string
    Profile cfg.Profile

UpRequest declares parameters for project deployment

type UserClient Uses

type UserClient struct {
    // contains filtered or unexported fields

UserClient is used to access Inertia's /user APIs

func NewUserClient Uses

func NewUserClient(c *Client) *UserClient

NewUserClient instantiates a new client for user management functions

func (*UserClient) AddUser Uses

func (u *UserClient) AddUser(ctx context.Context, username, password string, admin bool) error

AddUser adds an authorized user for access to Inertia Web

func (*UserClient) Authenticate Uses

func (u *UserClient) Authenticate(ctx context.Context, req AuthenticateRequest) (token string, err error)

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

func (*UserClient) DisableTotp Uses

func (u *UserClient) DisableTotp(ctx context.Context) error

DisableTotp disables Totp for a given user

func (*UserClient) EnableTotp Uses

func (u *UserClient) EnableTotp(ctx context.Context, username, password string) (*api.TotpResponse, error)

EnableTotp enables Totp for a given user

func (*UserClient) ListUsers Uses

func (u *UserClient) ListUsers(ctx context.Context) ([]string, error)

ListUsers lists all users on the remote.

func (*UserClient) RemoveUser Uses

func (u *UserClient) RemoveUser(ctx context.Context, username string) error

RemoveUser prevents a user from accessing Inertia Web

func (*UserClient) ResetUsers Uses

func (u *UserClient) ResetUsers(ctx context.Context) error

ResetUsers resets all users on the remote.


bootstrapPackage bootstrap provides Inertia's remote bootstrapping script, based off of inertia/client.Client
internalPackage internal provides compiled scripts and other internal assets
runnerPackage runner provides the Inertia client's low-level SSH command runner
runner/mocksPackage mocks provides mocked implmentations of interfaces in client/runner

Package client imports 21 packages (graph) and is imported by 8 packages. Updated 2021-01-14. Refresh now. Tools for package owners.