Documentation ¶
Overview ¶
Package client implements a set of common functionality that are used by DC/OS SDK commands to talk to schedulers built using the SDK or other DC/OS components (e.g. Cosmos). Cluster URL and other global values are pulled from the dcos-commons/cli/config package and populated by the values configured using the DC/OS CLI itself.
Index ¶
- Variables
- func CheckHTTPResponse(response *http.Response, err error) ([]byte, error)
- func CreateHTTPRawRequest(method string, url *url.URL, payload []byte, accept, contentType string) *http.Request
- func CreateHTTPURLRequest(method string, url *url.URL, payload []byte, accept, contentType string) *http.Request
- func CreateServiceHTTPDataRequest(method, urlPath string, jsonPayload []byte, contentType string) *http.Request
- func CreateServiceHTTPJSONRequest(method, urlPath string, jsonPayload []byte) *http.Request
- func CreateServiceHTTPQueryRequest(method, urlPath, urlQuery string) *http.Request
- func CreateServiceHTTPRequest(method, urlPath string) *http.Request
- func CreateServiceURL(urlPath, urlQuery string) *url.URL
- func CreateURL(baseURL, urlPath, urlQuery string) *url.URL
- func FormatList(entries []string) string
- func GetDCOSURL() string
- func HTTPCosmosPostJSON(urlPath string, jsonPayload []byte) ([]byte, error)
- func HTTPQuery(request *http.Request) (*http.Response, error)
- func HTTPServiceDelete(urlPath string) ([]byte, error)
- func HTTPServiceDeleteData(urlPath string, payload []byte, contentType string) ([]byte, error)
- func HTTPServiceDeleteJSON(urlPath string, jsonPayload []byte) ([]byte, error)
- func HTTPServiceDeleteQuery(urlPath, urlQuery string) ([]byte, error)
- func HTTPServiceGet(urlPath string) ([]byte, error)
- func HTTPServiceGetData(urlPath string, payload []byte, contentType string) ([]byte, error)
- func HTTPServiceGetJSON(urlPath string, jsonPayload []byte) ([]byte, error)
- func HTTPServiceGetQuery(urlPath, urlQuery string) ([]byte, error)
- func HTTPServicePost(urlPath string) ([]byte, error)
- func HTTPServicePostData(urlPath string, payload []byte, contentType string) ([]byte, error)
- func HTTPServicePostJSON(urlPath string, jsonPayload []byte) ([]byte, error)
- func HTTPServicePostQuery(urlPath, urlQuery string) ([]byte, error)
- func HTTPServicePut(urlPath string) ([]byte, error)
- func HTTPServicePutData(urlPath string, payload []byte, contentType string) ([]byte, error)
- func HTTPServicePutJSON(urlPath string, jsonPayload []byte) ([]byte, error)
- func HTTPServicePutQuery(urlPath, urlQuery string) ([]byte, error)
- func OptionalCLIConfigValue(name string) string
- func PrintJSONBytes(responseBytes []byte)
- func PrintResponseText(body []byte)
- func PrintVerbose(format string, a ...interface{}) (int, error)
- func RequiredCLIConfigValue(name string, description string, errorInstruction string) string
- func RunCLICommand(arg ...string) (string, error)
- func SetCustomResponseCheck(check responseCheck)
Constants ¶
This section is empty.
Variables ¶
var PrintMessage = printMessage
PrintMessage is a placeholder function that wraps a call to fmt.Println(fmt.Sprintf()) to allow assertions against captured output.
Functions ¶
func CheckHTTPResponse ¶
CheckHTTPResponse checks the HTTP response and the returned error, then returns the response payload and/or a better user-facing error.
func CreateHTTPRawRequest ¶
func CreateHTTPRawRequest(method string, url *url.URL, payload []byte, accept, contentType string) *http.Request
CreateHTTPRawRequest creates an HTTP request
func CreateHTTPURLRequest ¶
func CreateHTTPURLRequest(method string, url *url.URL, payload []byte, accept, contentType string) *http.Request
CreateHTTPURLRequest creates a HTTP url request which includes cluster auth headers as needed.
func CreateServiceHTTPDataRequest ¶
func CreateServiceHTTPDataRequest(method, urlPath string, jsonPayload []byte, contentType string) *http.Request
CreateServiceHTTPDataRequest creates a service HTTP data request
func CreateServiceHTTPJSONRequest ¶
CreateServiceHTTPJSONRequest creates a service HTTP JSON request
func CreateServiceHTTPQueryRequest ¶
CreateServiceHTTPQueryRequest creates a service HTTP query request
func CreateServiceHTTPRequest ¶
CreateServiceHTTPRequest creates a service HTTP request
func CreateServiceURL ¶
CreateServiceURL creates a service URL of the form http://clusterurl.com/service/<servicename>/<urlPath>[?urlQuery]
func FormatList ¶
FormatList outputs the provided entries as a list: - foo - bar ...
func GetDCOSURL ¶
func GetDCOSURL() string
GetDCOSURL gets the DC/OS cluster URL in the form of "http://cluster-host.com"
func HTTPCosmosPostJSON ¶
HTTPCosmosPostJSON triggers a HTTP POST request containing jsonPayload to https://dcos.cluster/cosmos/service/<urlPath>
func HTTPQuery ¶
HTTPQuery does a HTTP query, returning the response if it's successful, or an error otherwise
func HTTPServiceDelete ¶
HTTPServiceDelete triggers a HTTP DELETE request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceDeleteData ¶
HTTPServiceDeleteData triggers a HTTP DELETE request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceDeleteJSON ¶
HTTPServiceDeleteJSON triggers a HTTP DELETE request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceDeleteQuery ¶
HTTPServiceDeleteQuery triggers a HTTP DELETE request with query parameters to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>?<urlQuery>
func HTTPServiceGet ¶
HTTPServiceGet triggers a HTTP GET request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceGetData ¶
HTTPServiceGetData triggers a HTTP GET request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceGetJSON ¶
HTTPServiceGetJSON triggers a HTTP GET request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServiceGetQuery ¶
HTTPServiceGetQuery triggers a HTTP GET request with query parameters to: <config.DcosURL>/service/<config.ServiceName><urlPath>?<urlQuery>
func HTTPServicePost ¶
HTTPServicePost triggers a HTTP POST request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePostData ¶
HTTPServicePostData triggers a HTTP POST request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePostJSON ¶
HTTPServicePostJSON triggers a HTTP POST request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePostQuery ¶
HTTPServicePostQuery triggers a HTTP POST request with query parameters to: <config.DcosURL>/service/<config.ServiceName><urlPath>?<urlQuery>
func HTTPServicePut ¶
HTTPServicePut triggers a HTTP PUT request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePutData ¶
HTTPServicePutData triggers a HTTP PUT request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePutJSON ¶
HTTPServicePutJSON triggers a HTTP PUT request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>
func HTTPServicePutQuery ¶
HTTPServicePutQuery triggers a HTTP PUT request with query parameters to: <config.DcosURL>/service/<config.ServiceName><urlPath>?<urlQuery>
func OptionalCLIConfigValue ¶
OptionalCLIConfigValue retrieves the CLI configuration for name. If no value can be retrieved, this returns an empty string.
func PrintJSONBytes ¶
func PrintJSONBytes(responseBytes []byte)
PrintJSONBytes pretty prints responseBytes assuming it is valid JSON. If not valid, an error message will be printed and the original data will be printed.
func PrintResponseText ¶
func PrintResponseText(body []byte)
PrintResponseText prints out a byte array as text.
func PrintVerbose ¶
PrintVerbose prints a message using PrintMessage iff config.Verbose is enabled
func RequiredCLIConfigValue ¶
RequiredCLIConfigValue gets config values from the DC/OS CLI
func RunCLICommand ¶
RunCLICommand runs a DC/OS CLI command
func SetCustomResponseCheck ¶
func SetCustomResponseCheck(check responseCheck)
SetCustomResponseCheck sets a custom responseCheck that can be used for more advanced handling of HTTP responses.
Types ¶
This section is empty.