arukas

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2016 License: MIT Imports: 18 Imported by: 0

README

Arukas CLI

Circle CI

The Arukas CLI is used to manage Arukas apps from the command line.

Binary Releases

The official binary of Arukas CLI: https://github.com/arukasio/cli/releases/

Dockerized

A dockerized version of Arukas CLI: https://hub.docker.com/r/arukasio/arukas/

Setup

You can overload and customize specific variables when running scripts.

Simply create .env with the environment variables you need, for example, ARUKAS_JSON_API_TOKEN and ARUKAS_JSON_API_SECRET

# .env
ARUKAS_JSON_API_TOKEN=YOUR_API_TOKEN
ARUKAS_JSON_API_SECRET=YOUR_API_SECRET

You can look at .env.sample for other variables used by this application.

License

This project is licensed under the terms of the MIT license.

Documentation

Index

Examples

Constants

View Source
const VERSION = "v0.1.3"

VERSION is cli version.

Variables

View Source
var ExitCode = 0

ExitCode is exit code.

Functions

func PrintTsvln

func PrintTsvln(values ...interface{})

PrintTsvln print Tab-separated values line.

func Run

func Run(args []string) int

Run arukas

Example
runCommand([]string{"arukas", "run", "nginx:latest", "--instances", "1", "--mem", "256", "-p", "80:tcp"})
Output:

ID	IMAGE	CREATED	STATUS	NAME	ENDPOINT
2b21fe34-328f-4d7e-8678-726d9eff2b7f	nginx:latest	2015-10-19T15:05:34.843+09:00	interrupted	stopped-container	stopped-container.arukascloud.io

func RunTest

func RunTest(args []string) int

RunTest arukas

func SelectResources

func SelectResources(data TmpJSON, resourceType string) map[string][]map[string]interface{}

SelectResources returns the type filter value of TmpJSON.

func SplitTSV

func SplitTSV(str string) []string

SplitTSV return splited Tab-separated values.

func ToTSV

func ToTSV(values []interface{}) string

ToTSV return Tab-separated values.

Types

type App

type App struct {
	ID          string     `json:"-"`
	Name        string     `json:"name"`
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"-"`
	ContainerID string     `json:"-"`
	Container   *Container `json:"-"`
	User        *User      `json:"-"`
}

App represents a application data in struct variables.

func (App) GetID

func (a App) GetID() string

GetID returns a stringified of an ID.

func (*App) SetID

func (a *App) SetID(ID string) error

SetID to satisfy jsonapi.UnmarshalIdentifier interface.

func (*App) SetToOneReferenceID

func (a *App) SetToOneReferenceID(name, ID string) error

SetToOneReferenceID sets the reference ID and satisfies the jsonapi.UnmarshalToOneRelations interface

type AppSet

type AppSet struct {
	App       App
	Container Container
}

AppSet represents a application data in struct variables.

func (AppSet) MarshalJSON

func (as AppSet) MarshalJSON() ([]byte, error)

MarshalJSON returns as as the JSON encoding of as.

func (*AppSet) UnmarshalJSON

func (as *AppSet) UnmarshalJSON(bytes []byte) error

UnmarshalJSON sets *as to a copy of data.

type Client

type Client struct {
	APIURL     *url.URL
	HTTP       *http.Client
	Username   string
	Password   string
	UserAgent  string
	Debug      bool
	Output     func(...interface{})
	OutputDest io.Writer
	Timeout    time.Duration
}

Client represents a user client data in struct variables.

func NewClient

func NewClient() (*Client, error)

NewClient returns a new arukas client, requires an authorization key. You can generate a API key by visiting the Keys section of the Arukas control panel for your account.

func NewClientWithOsExitOnErr

func NewClientWithOsExitOnErr() *Client

NewClientWithOsExitOnErr return client.

func (*Client) APIReq

func (c *Client) APIReq(v interface{}, method, path string, body interface{}) error

APIReq Sends a Arukas API request and decodes the response into v. As described in NewRequest(), the type of body determines how to encode the request body. As described in DoReq(), the type of v determines how to handle the response body.

func (*Client) Delete

func (c *Client) Delete(path string) error

Delete return *c as the delete path of API request.

func (*Client) DoReq

func (c *Client) DoReq(req *http.Request, v interface{}) error

DoReq Submits an HTTP request, checks its response, and deserializes the response into v. The type of v determines how to handle the response body:

nil        body is discarded
io.Writer  body is copied directly into v
else       body is decoded into v as json

func (*Client) Get

func (c *Client) Get(v interface{}, path string) error

Get return *c as the get path of API request.

func (*Client) NewRequest

func (c *Client) NewRequest(method, path string, body interface{}) (*http.Request, error)

NewRequest Generates an HTTP request for the Arukas API, but does not perform the request. The request's Accept header field will be set to:

Accept: application/vnd.api+json;

The type of body determines how to encode the request:

nil         no body
io.Reader   body is sent verbatim
[]byte      body is encoded as application/vnd.api+json
else        body is encoded as application/json

func (*Client) Patch

func (c *Client) Patch(v interface{}, path string, body interface{}) error

Patch return *c as the patch path of API request.

func (*Client) Post

func (c *Client) Post(v interface{}, path string, body interface{}) error

Post return *c as the post path of API request.

func (*Client) PrintHeaderln

func (c *Client) PrintHeaderln(values ...interface{})

PrintHeaderln print as the values.

func (*Client) Println

func (c *Client) Println(values ...interface{})

Println print as the values.

func (*Client) Put

func (c *Client) Put(v interface{}, path string, body interface{}) error

Put return *c as the put path of API request.

type Container

type Container struct {
	Envs         Envs         `json:"envs"`
	Ports        Ports        `json:"ports"`
	PortMappings PortMappings `json:"port_mappings,omitempty"`
	StatusText   string       `json:"status_text,omitempty"`
	ID           string
	ImageName    string    `json:"image_name"`
	CreatedAt    JSONTime  `json:"created_at"`
	UpdatedAt    time.Time `json:"updated_at"`
	App          *App
	Mem          int    `json:"mem"`
	AppID        string `json:"app_id"`
	Instances    int    `json:"instances"`
	IsRunning    bool   `json:"is_running,omitempty"`
	Cmd          string `json:"cmd"`
	Name         string `json:"name"`
	Endpoint     string `json:"end_point,omitempty"`
}

Container represents a docker container data in struct variables.

func (Container) GetID

func (c Container) GetID() string

GetID returns a stringified of an ID.

func (Container) GetReferencedIDs

func (c Container) GetReferencedIDs() []jsonapi.ReferenceID

GetReferencedIDs satisfies the jsonapi.MarshalLinkedRelations interface.

func (Container) GetReferencedStructs

func (c Container) GetReferencedStructs() []jsonapi.MarshalIdentifier

GetReferencedStructs to satisfy the jsonapi.MarhsalIncludedRelations interface.

func (Container) GetReferences

func (c Container) GetReferences() []jsonapi.Reference

GetReferences returns all related structs to transactions.

func (*Container) SetID

func (c *Container) SetID(ID string) error

SetID to satisfy jsonapi.UnmarshalIdentifier interface.

func (*Container) SetToOneReferenceID

func (c *Container) SetToOneReferenceID(name, ID string) error

SetToOneReferenceID sets the reference ID and satisfies the jsonapi.UnmarshalToOneRelations interface.

type Env

type Env struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Env represents a docker container environment key-value in struct variables.

type Envs

type Envs []Env

Envs is multiple Env.

func ParseEnv

func ParseEnv(envs []string) (Envs, error)

ParseEnv parse docker container envs.

type JSONTime

type JSONTime time.Time

JSONTime is time.Time that serializes as unix timestamp (in microseconds).

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

MarshalJSON returns t as the JSON encoding of t.

func (JSONTime) String

func (t JSONTime) String() string

String return t as the string of t.

func (JSONTime) Time

func (t JSONTime) Time() time.Time

Time return t as the time of t.

func (*JSONTime) UnmarshalJSON

func (t *JSONTime) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON sets *t to a copy of data.

type Port

type Port struct {
	Protocol string `json:"protocol"`
	Number   int    `json:"number"`
}

Port represents a docker protocol and port-number in struct variables.

type PortMapping

type PortMapping struct {
	ContainerPort int    `json:"container_port"`
	ServicePort   int    `json:"service_port"`
	Host          string `json:"host"`
}

PortMapping represents a docker container port mapping in struct variables.

type PortMappings

type PortMappings []TaskPorts

PortMappings is multiple TaskPorts.

type Ports

type Ports []Port

Ports is multiple Port.

func ParsePort

func ParsePort(ports []string) (Ports, error)

ParsePort parse docker container ports.

type TaskPorts

type TaskPorts []PortMapping

TaskPorts is Multiple PortMapping.

type TmpJSON

type TmpJSON struct {
	Data []map[string]interface{} `json:"data"`
	Meta map[string]interface{}   `json:"-"`
}

TmpJSON Contain JSON data.

type User

type User struct {
	ID          string    `json:"-"`         // user id
	Name        string    `json:"name"`      // user name
	Email       string    `json:"email"`     // user e-mail
	Provider    string    `json:"provider"`  // user oAuth provider
	ImageURL    string    `json:"image_url"` // user profile image
	CreatedAt   time.Time `json:"created_at"`
	UpdatedAt   time.Time `json:"updated_at"`
	ConfirmedAt time.Time `json:"-"`
}

User represents a user data in struct variables.

func (User) GetID

func (u User) GetID() string

GetID returns a stringified of an ID.

func (*User) SetID

func (u *User) SetID(ID string) error

SetID to satisfy jsonapi.UnmarshalIdentifier interface.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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