internal

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2015 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const VERSION = "$version"

VERSION of sail

Variables

View Source
var (
	// Host points to the sailabove infrastructure wanted
	Host string
	// User of sailabove to use
	User string
	// Password of sailabove account to use
	Password string
	// 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 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 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 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 GetListApplications

func GetListApplications(args []string) []string

GetListApplications returns list of applications, GET on /applications

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