README

go-mktmpio Build Status GoDoc Go Report Card

Go client for mktmp.io service. Unless you are trying to integrate mktmpio into your unit tests for your go project, you probably want the mktmpio cli.

Usage

See API documentation.

This software is copyright © Datajin Technologies, Inc. 2015,2017 and Open Source under the terms of Artistic License 2.0 that can be found in the LICENSE file.

Use of the mktmpio service is subject to the mktmpio Privacy Policy and mktmpio Terms of Service policy.


Copyright © Datajin Technologies, Inc. 2015,2017. All rights reserved.

Expand ▾ Collapse ▴

Documentation

Overview

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

    Index

    Constants

    View Source
    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

      View Source
      const MKtmpioCfgFile = "~/.mktmpio.yml"

        MKtmpioCfgFile is the path to the user's config

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

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

          Variables

          This section is empty.

          Functions

          func ConfigPath

          func ConfigPath() string

            ConfigPath returns the path to the user config file

            Types

            type Client

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

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

              func NewClient

              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

                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

                  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

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

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

                      func (Client) Destroy

                      func (c Client) Destroy(id string) error

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

                        func (Client) List

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

                          List generates retrieves a list of curently running instances

                          func (*Client) SetLogger

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

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

                            type Config

                            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

                              func DefaultConfig() *Config

                                DefaultConfig returns a configuration with only the default values set

                                func EnvConfig

                                func EnvConfig() *Config

                                  EnvConfig returns a configuration with only values provided by environment variables

                                  func FileConfig

                                  func FileConfig(cfgPath string) *Config

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

                                    func LoadConfig

                                    func LoadConfig() *Config

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

                                      func (*Config) Apply

                                      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

                                        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

                                          func (c Config) String() string

                                          type Instance

                                          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

                                            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

                                              func (i *Instance) Destroy() error

                                                Destroy the server on the mktmpio service

                                                func (*Instance) LoadEnv

                                                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

                                                  Path Synopsis