README
¶
Client
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 (
"context"
"github.com/ubclaunchpad/inertia/cfg"
"github.com/ubclaunchpad/inertia/client"
"github.com/ubclaunchpad/inertia/client/bootstrap"
)
func main() {
// set up a client to your remote
inertia, _ := client.NewClient(
&cfg.Remote{
Version: "v0.6.0",
Name: "gcloud",
IP: "my.host.addr",
/* ... */
},
client.Options{ /* ... */ })
// bootstrap your remote
bootstrap.Bootstrap(inertia, bootstrap.Options{ /* ... */ })
// deploy your project!
inertia.Up(context.Background(), client.UpRequest{
Project: "my-project",
URL: "git@github.com:me/project.git",
Profile: cfg.Profile{
Name: "default",
Branch: "master",
Build: &cfg.Build{
Type: cfg.DockerCompose,
BuildFilePath: "Dockerfile",
},
},
})
}
Documentation
¶
Overview ¶
Package client provides the interface through which Inertia communicates with a serverside daemon
Index ¶
- Variables
- type AuthenticateRequest
- type Client
- func (c *Client) Down(ctx context.Context) error
- func (c *Client) GetSSHClient() (*SSHClient, error)
- func (c *Client) GetUserClient() *UserClient
- func (c *Client) ListEnv(ctx context.Context) ([]string, error)
- func (c *Client) Logs(ctx context.Context, req LogsRequest) ([]string, error)
- func (c *Client) LogsWithOutput(ctx context.Context, req LogsRequest) error
- func (c *Client) Prune(ctx context.Context) error
- func (c *Client) Reset(ctx context.Context) error
- func (c *Client) Status(ctx context.Context) (*api.DeploymentStatus, error)
- func (c *Client) Token(ctx context.Context) (token string, err error)
- func (c *Client) Up(ctx context.Context, req UpRequest) error
- func (c *Client) UpWithOutput(ctx context.Context, req UpRequest) error
- func (c *Client) UpdateEnv(ctx context.Context, name, value string, encrypt, remove bool) error
- func (c *Client) WithDebug(debug bool)
- func (c *Client) WithWriter(out io.Writer)
- type LogsRequest
- type Options
- type SSHClient
- func (s *SSHClient) AssignAPIToken() error
- func (s *SSHClient) DaemonDown() error
- func (s *SSHClient) DaemonUp() error
- func (s *SSHClient) GenerateKeys() (string, error)
- func (s *SSHClient) GetRunner() runner.SSHSession
- func (s *SSHClient) InstallDocker() error
- func (s *SSHClient) UninstallInertia() error
- type SocketReader
- type UpRequest
- type UserClient
- func (u *UserClient) AddUser(ctx context.Context, username, password string, admin bool) error
- func (u *UserClient) Authenticate(ctx context.Context, req AuthenticateRequest) (token string, err error)
- func (u *UserClient) DisableTotp(ctx context.Context) error
- func (u *UserClient) EnableTotp(ctx context.Context, username, password string) (*api.TotpResponse, error)
- func (u *UserClient) ListUsers(ctx context.Context) ([]string, error)
- func (u *UserClient) RemoveUser(ctx context.Context, username string) error
- func (u *UserClient) ResetUsers(ctx context.Context) error
Constants ¶
Variables ¶
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
Functions ¶
Types ¶
type AuthenticateRequest ¶
AuthenticateRequest denotes options for authenticating with the Inertia daemon
type Client ¶
Client manages a deployment
func (*Client) Down ¶
Down brings the project down on the remote VPS instance specified in the configuration object.
func (*Client) GetSSHClient ¶
GetSSHClient instantiates an SSH client for Inertia-related commands
func (*Client) GetUserClient ¶
func (c *Client) GetUserClient() *UserClient
GetUserClient instantiates an API client for Inertia user management commands
func (*Client) LogsWithOutput ¶
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) Reset ¶
Reset shuts down deployment and deletes the contents of the deployment's project directory
func (*Client) Up ¶
Up brings the project up on the remote VPS instance specified in the deployment object.
func (*Client) UpWithOutput ¶
UpWithOutput blocks and streams 'up' output to the client's io.Writer
func (*Client) WithWriter ¶
WithWriter sets the given io.Writer as the client's default output
type LogsRequest ¶
LogsRequest denotes parameters for log querying
type Options ¶
type Options struct { SSH runner.SSHOptions Out io.Writer Debug bool }
Options denotes configuration options for a Client
type SSHClient ¶
type SSHClient struct {
// contains filtered or unexported fields
}
SSHClient implements Inertia's SSH commands
func (*SSHClient) AssignAPIToken ¶
AssignAPIToken generates an API token and assigns it to client.Remote
func (*SSHClient) DaemonDown ¶
DaemonDown brings the daemon down on the remote instance
func (*SSHClient) GenerateKeys ¶
GenerateKeys creates a public-private key-pair on the remote vps and returns the public key.
func (*SSHClient) GetRunner ¶
func (s *SSHClient) GetRunner() runner.SSHSession
GetRunner returns the SSH client's underlying session
func (*SSHClient) InstallDocker ¶
InstallDocker installs docker on a remote vps.
func (*SSHClient) UninstallInertia ¶
UninstallInertia removes the inertia/ directory on the remote instance
type SocketReader ¶
SocketReader is an interface to a websocket connection
type UserClient ¶
type UserClient struct {
// contains filtered or unexported fields
}
UserClient is used to access Inertia's /user APIs
func NewUserClient ¶
func NewUserClient(c *Client) *UserClient
NewUserClient instantiates a new client for user management functions
func (*UserClient) Authenticate ¶
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 ¶
func (u *UserClient) DisableTotp(ctx context.Context) error
DisableTotp disables Totp for a given user
func (*UserClient) EnableTotp ¶
func (u *UserClient) EnableTotp(ctx context.Context, username, password string) (*api.TotpResponse, error)
EnableTotp enables Totp for a given user
func (*UserClient) ListUsers ¶
func (u *UserClient) ListUsers(ctx context.Context) ([]string, error)
ListUsers lists all users on the remote.
func (*UserClient) RemoveUser ¶
func (u *UserClient) RemoveUser(ctx context.Context, username string) error
RemoveUser prevents a user from accessing Inertia Web
func (*UserClient) ResetUsers ¶
func (u *UserClient) ResetUsers(ctx context.Context) error
ResetUsers resets all users on the remote.
Directories
¶
Path | Synopsis |
---|---|
Package bootstrap provides Inertia's remote bootstrapping script, based off of inertia/client.Client
|
Package bootstrap provides Inertia's remote bootstrapping script, based off of inertia/client.Client |
Package runner provides the Inertia client's low-level SSH command runner
|
Package runner provides the Inertia client's low-level SSH command runner |
mocks
Package mocks provides mocked implmentations of interfaces in client/runner Code generated by counterfeiter.
|
Package mocks provides mocked implmentations of interfaces in client/runner Code generated by counterfeiter. |
Package internal provides compiled scripts and other internal assets
|
Package internal provides compiled scripts and other internal assets |