go-mktmpio: github.com/mktmpio/go-mktmpio Index | Files | Directories

package mktmpio

import "github.com/mktmpio/go-mktmpio"

Package mktmpio provides easy access to the database servier provisioning services at https://mktmp.io/

Index

Package Files

client.go config.go instance.go meta.go

Constants

const (
    Copyright   = "Copyright Datajin Technologies, Inc. 2015,2016. All rights reserved."
    LicenseName = "Artistic-2.0"
    LicenseURL  = "http://opensource.org/licenses/Artistic-2.0"
)

exposed for package introspection and

const MKtmpioCfgFile = "~/.mktmpio.yml"

MKtmpioCfgFile is the path to the user's config

const MktmpioURL = "https://mktmp.io/api/v1"

MktmpioURL is the root of the current version of the mktmpio HTTP API

func ConfigPath Uses

func ConfigPath() string

ConfigPath returns the path to the user config file

type Client Uses

type Client struct {
    UserAgent string
    // contains filtered or unexported fields
}

Client provides authenticated API access for creating, listing, and destroying database servers.

func NewClient Uses

func NewClient(cfg *Config) (*Client, error)

NewClient creates a mktmpio Client using credentials loaded from the user config stored in ~/.mktmpio.yml

func (Client) Attach Uses

func (c Client) Attach(id string) (io.ReadWriteCloser, error)

Attach creates a remote shell for the instance identified by `id` and then returns a Reader and a Writer for communicating with it via a pseudo-TTY. The bytes read from the channel will include TTY control sequences. This type of connection is most appropriate for connecting directly to a local TTY.

func (Client) AttachStdio Uses

func (c Client) AttachStdio(id string) (io.WriteCloser, io.Reader, io.Reader, error)

AttachStdio creates a remote shell for the instance identified by `id` and returns an io.WriteCloser for that shell's stdin and an io.Reader for each of stdout and stderr on that shell. This is for non-interactive shells, like one would use for piping a script into a shell or for piping the output from.

func (Client) Create Uses

func (c Client) Create(service string) (*Instance, error)

Create creates a server of the type specified by `service`.

func (Client) Destroy Uses

func (c Client) Destroy(id string) error

Destroy shuts down and deletes the server identified by `id`.

func (Client) List Uses

func (c Client) List() ([]Instance, error)

List generates retrieves a list of curently running instances

func (*Client) SetLogger Uses

func (c *Client) SetLogger(logger *log.Logger)

SetLogger sets the logger to be used for verbose logging of errors

type Config Uses

type Config struct {
    Token string
    URL   string `yaml:",omitempty"`
    // contains filtered or unexported fields
}

Config contains the user config options used for accessing the mktmpio API.

func DefaultConfig Uses

func DefaultConfig() *Config

DefaultConfig returns a configuration with only the default values set

func EnvConfig Uses

func EnvConfig() *Config

EnvConfig returns a configuration with only values provided by environment variables

func FileConfig Uses

func FileConfig(cfgPath string) *Config

FileConfig returns a configuration with any values provided by the given YAML config file

func LoadConfig Uses

func LoadConfig() *Config

LoadConfig loads the configuration stored in `~/.mktmpio.yml`, returning it as a Config type instance.

func (*Config) Apply Uses

func (c *Config) Apply(b *Config) *Config

Apply creates a new Config with non-empty values from the provided Config overriding the options of the base Config

func (*Config) Save Uses

func (c *Config) Save(cfgPath string) error

Save stores the given configuration in ~/.mktmpio.yml, overwriting the current contents if the file exists.

func (Config) String Uses

func (c Config) String() string

type Instance Uses

type Instance struct {
    ID             string
    Host           string
    Port           int
    Error          string
    RemoteShell    shell
    Type           string
    Username       string
    Password       string
    ContainerShell []string
    // contains filtered or unexported fields
}

Instance represents a server that has been created on the mktmpio service.

func (*Instance) Cmd Uses

func (i *Instance) Cmd() *exec.Cmd

Cmd returns an exec.Cmd that is pre-populated with the command, arguments, and environment variables required for spawning a local shell connected to the remote server.

func (*Instance) Destroy Uses

func (i *Instance) Destroy() error

Destroy the server on the mktmpio service

func (*Instance) LoadEnv Uses

func (i *Instance) LoadEnv() error

LoadEnv modifies the current environment by setting environment variables that contain the host, port and credentials required for connecting to the remote server represented by the Instance.

Directories

PathSynopsis
stdcopy

Package mktmpio imports 17 packages (graph) and is imported by 1 packages. Updated 2018-08-04. Refresh now. Tools for package owners.