internal

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2016 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const VERSION = "0.7.5"

VERSION of sail

Variables

View Source
var (
	// Host points to the sailabove infrastructure wanted
	Host = os.Getenv("SAIL_HOST")
	// User of sailabove to use
	User = os.Getenv("SAIL_USER")
	// Password of sailabove account to use
	Password = os.Getenv("SAIL_PASSWORD")
	// ConfigDir points to the Docker configuration directory
	ConfigDir string
	// Verbose conditions the quantity of output of api requests
	Verbose bool
	// Format to use for output. One of 'json', 'yaml', 'pretty'
	Format string
	// Home fetches the user home directory
	Home = os.Getenv("HOME")
	// Headers to append to each requests. For debugging/internal purpose.
	Headers = make(headers)
)
View Source
var Cmd = &cobra.Command{
	Use:     "config",
	Short:   "Config commands: sail config --help",
	Long:    `Config commands: sail config <command>`,
	Aliases: []string{"c"},
}

Cmd config

Functions

func Check

func Check(err error)

Check checks e and panic if not nil

func CheckHostConsistent added in v0.5.1

func CheckHostConsistent(host string) bool

CheckHostConsistent with config. Assume config has already been parsed. Consider ” as OK

func CheckName added in v0.5.2

func CheckName(name string) error

CheckName validates that a service or application looks consistent. It will only block request that will *always* fail. It does not duplicate API validation

func DeleteBodyWantJSON

func DeleteBodyWantJSON(path string, body []byte) []byte

DeleteBodyWantJSON on path and return []byte of JSON

func DeleteWantJSON

func DeleteWantJSON(path string) []byte

DeleteWantJSON on path and return []byte of JSON

func DisplayEventStream added in v0.7.5

func DisplayEventStream(buffer io.ReadCloser, exitAtContainerExit bool) ([]byte, error)

DisplayEventStream displays each event related to a service, and terminates the current process with the exit code contained in an event, if any.

func DisplayStream

func DisplayStream(buffer io.ReadCloser) ([]byte, error)

DisplayStream decode each line from http buffer and print either message or error. Return last read line

func EventStreamPrint added in v0.7.5

func EventStreamPrint(method string, path string, args []byte, exitAtContainerExit bool, mods ...RequestModifier)

EventStreamPrint opens an event stream and print it in a goroutine, and exit when an event indicates an exit status

func Exit

func Exit(format string, args ...interface{})

Exit func display an error message on stderr and exit 1

func ExitAfterCtrlC

func ExitAfterCtrlC()

ExitAfterCtrlC will exit(0) as soon as Ctrl-C is pressed. Typically used when streaming console

func FormatOutput

func FormatOutput(data []byte, prettyFormatter func([]byte))

FormatOutput autmatically formats json based output based on user choice. when selected formatter is "pretty", call prettyFormatter callback.

func FormatOutputDef

func FormatOutputDef(data []byte)

FormatOutputDef autmatically formats json based output based on user choice. uses yamlFormatter as pretty formatter.

func FormatOutputError added in v0.5.2

func FormatOutputError(data []byte)

FormatOutputError prints the "message" field of an API return or falls back on FormatOutputDef if the field does not exist

func GetListApplications

func GetListApplications(apps []string) []string

GetListApplications returns list of applications, GET on /applications

func GetUserName added in v0.6.5

func GetUserName() string

GetUserName returns the name of the current user, GET on /users

func GetWantJSON

func GetWantJSON(path string) []byte

GetWantJSON GET on path and return []byte of JSON

func ParseResourceName added in v0.5.1

func ParseResourceName(repositoryName string) (host, application, repository, tag string, err error)

ParseResourceName normalizes repo or service name of the form [[cluster/]application/]name[:tag]

func PostBodyWantJSON

func PostBodyWantJSON(path string, body []byte) []byte

PostBodyWantJSON POST a body on path and return []byte of JSON

func PostWantJSON

func PostWantJSON(path string) []byte

PostWantJSON POST on path and return []byte of JSON

func ReadConfig

func ReadConfig() error

ReadConfig fetches docker config from ConfigDir

func ReqWant

func ReqWant(method string, wantCode int, path string, jsonStr []byte) []byte

ReqWant requests with a method on a path, check wantCode and returns []byte

func ReqWantJSON

func ReqWantJSON(method string, wantCode int, path string, body []byte) []byte

ReqWantJSON requests with a method on a path, check wantCode and returns []byte of JSON

func Request

func Request(method string, path string, args []byte, mods ...RequestModifier) ([]byte, int, error)

Request executes an authentificated HTTP request on $path given $method and $args

func Stream

func Stream(method string, path string, args []byte, mods ...RequestModifier) (io.ReadCloser, int, error)

Stream makes an authenticated http request and return io.ReadCloser

func StreamPrint

func StreamPrint(method string, path string, args []byte, mods ...RequestModifier)

StreamPrint opens a stream and print it in a goroutine

func StreamWant

func StreamWant(method string, wantCode int, path string, jsonStr []byte)

StreamWant request a path with method and stream result

Types

type Error

type Error struct {
	Status  string `json:"error_status"`
	Message string `json:"error_details"`
	Code    int    `json:"error"`
}

Error type

func DecodeError

func DecodeError(data []byte) *Error

DecodeError return an Error struct from json

func (*Error) Error

func (e *Error) Error() string

func (*Error) String

func (e *Error) String() string

type Event added in v0.7.5

type Event struct {
	Event       string     `json:"event"`
	Service     string     `json:"service"`
	Timestamp   float64    `json:"timestamp"`
	Data        *EventData `json:"data"`
	Application string     `json:"application"`
	State       string     `json:"state"`
	PrevState   string     `json:"prev_state"`
	Message     string     `json:"message"`
	Type        string     `json:"type"`
	ID          string     `json:"id"`
}

Event type

func DecodeEvent added in v0.7.5

func DecodeEvent(data []byte) *Event

DecodeEvent return a Event struct from json

type EventData added in v0.7.5

type EventData struct {
	LastExitStatus *LastExitStatus `json:"last_exit_status"`
}

EventData type

type LastExitStatus added in v0.7.5

type LastExitStatus struct {
	Reason        string `json:"reason"`
	RawExitStatus int    `json:"raw_exit_status"`
	ExitStatus    *int   `json:"exit_status"`
	Signal        *int   `json:"signal"`
}

LastExitStatus type

type Message

type Message struct {
	Message string `json:"message"`
	Type    string `json:"type"`
}

Message type

func DecodeMessage

func DecodeMessage(data []byte) *Message

DecodeMessage return a Message struct from json

type RequestModifier

type RequestModifier func(req *http.Request)

RequestModifier is used to modify behavior of Request and Steam functions

func SetHeader

func SetHeader(key, value string) RequestModifier

SetHeader modify headers of http.Request

Jump to

Keyboard shortcuts

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