Documentation ¶
Index ¶
- Constants
- Variables
- func Check(err error)
- func CheckHostConsistent(host string) bool
- func CheckName(name string) error
- func DeleteBodyWantJSON(path string, body []byte) []byte
- func DeleteWantJSON(path string) []byte
- func DisplayEventStream(buffer io.ReadCloser, exitAtContainerExit bool) ([]byte, error)
- func DisplayStream(buffer io.ReadCloser) ([]byte, error)
- func EventStreamPrint(method string, path string, args []byte, exitAtContainerExit bool, ...)
- func Exit(format string, args ...interface{})
- func ExitAfterCtrlC()
- func FormatOutput(data []byte, prettyFormatter func([]byte))
- func FormatOutputDef(data []byte)
- func FormatOutputError(data []byte)
- func GetListApplications(apps []string) []string
- func GetUserName() string
- func GetWantJSON(path string) []byte
- func ParseResourceName(repositoryName string) (host, application, repository, tag string, err error)
- func PostBodyWantJSON(path string, body []byte) []byte
- func PostWantJSON(path string) []byte
- func ReadConfig() error
- func ReqWant(method string, wantCode int, path string, jsonStr []byte) []byte
- func ReqWantJSON(method string, wantCode int, path string, body []byte) []byte
- func Request(method string, path string, args []byte, mods ...RequestModifier) ([]byte, int, error)
- func Stream(method string, path string, args []byte, mods ...RequestModifier) (io.ReadCloser, int, error)
- func StreamPrint(method string, path string, args []byte, mods ...RequestModifier)
- func StreamWant(method string, wantCode int, path string, jsonStr []byte)
- type Error
- type Event
- type EventData
- type LastExitStatus
- type Message
- type RequestModifier
Constants ¶
const VERSION = "0.7.5"
VERSION of sail
Variables ¶
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) )
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 CheckHostConsistent ¶ added in v0.5.1
CheckHostConsistent with config. Assume config has already been parsed. Consider ” as OK
func CheckName ¶ added in v0.5.2
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 ¶
DeleteBodyWantJSON on path and return []byte of JSON
func DeleteWantJSON ¶
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 ¶
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 ¶
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 ¶
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 ¶
PostBodyWantJSON POST a body on path and return []byte of JSON
func PostWantJSON ¶
PostWantJSON POST on path and return []byte of JSON
func ReqWantJSON ¶
ReqWantJSON requests with a method on a path, check wantCode and returns []byte of JSON
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
Types ¶
type Error ¶
type Error struct { Status string `json:"error_status"` Message string `json:"error_details"` Code int `json:"error"` }
Error type
func DecodeError ¶
DecodeError return an Error struct from json
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
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 RequestModifier ¶
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