client

package
v0.56.3 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: Apache-2.0 Imports: 16 Imported by: 4

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

Constants

This section is empty.

Variables

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

func CheckHTTPResponse(response *http.Response, err error) ([]byte, error)

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

func CreateServiceHTTPJSONRequest(method, urlPath string, jsonPayload []byte) *http.Request

CreateServiceHTTPJSONRequest creates a service HTTP JSON request

func CreateServiceHTTPQueryRequest

func CreateServiceHTTPQueryRequest(method, urlPath, urlQuery string) *http.Request

CreateServiceHTTPQueryRequest creates a service HTTP query request

func CreateServiceHTTPRequest

func CreateServiceHTTPRequest(method, urlPath string) *http.Request

CreateServiceHTTPRequest creates a service HTTP request

func CreateServiceURL

func CreateServiceURL(urlPath, urlQuery string) *url.URL

CreateServiceURL creates a service URL of the form http://clusterurl.com/service/<servicename>/<urlPath>[?urlQuery]

func CreateURL

func CreateURL(baseURL, urlPath, urlQuery string) *url.URL

CreateURL creates a URL of the form <baseURL>/<urlPath>[?urlQuery]

func FormatList

func FormatList(entries []string) string

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

func HTTPCosmosPostJSON(urlPath string, jsonPayload []byte) ([]byte, error)

HTTPCosmosPostJSON triggers a HTTP POST request containing jsonPayload to https://dcos.cluster/cosmos/service/<urlPath>

func HTTPQuery

func HTTPQuery(request *http.Request) (*http.Response, error)

HTTPQuery does a HTTP query, returning the response if it's successful, or an error otherwise

func HTTPServiceDelete

func HTTPServiceDelete(urlPath string) ([]byte, error)

HTTPServiceDelete triggers a HTTP DELETE request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServiceDeleteData

func HTTPServiceDeleteData(urlPath string, payload []byte, contentType string) ([]byte, error)

HTTPServiceDeleteData triggers a HTTP DELETE request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServiceDeleteJSON

func HTTPServiceDeleteJSON(urlPath string, jsonPayload []byte) ([]byte, error)

HTTPServiceDeleteJSON triggers a HTTP DELETE request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServiceDeleteQuery

func HTTPServiceDeleteQuery(urlPath, urlQuery string) ([]byte, error)

HTTPServiceDeleteQuery triggers a HTTP DELETE request with query parameters to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>?<urlQuery>

func HTTPServiceGet

func HTTPServiceGet(urlPath string) ([]byte, error)

HTTPServiceGet triggers a HTTP GET request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServiceGetData

func HTTPServiceGetData(urlPath string, payload []byte, contentType string) ([]byte, error)

HTTPServiceGetData triggers a HTTP GET request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServiceGetJSON

func HTTPServiceGetJSON(urlPath string, jsonPayload []byte) ([]byte, error)

HTTPServiceGetJSON triggers a HTTP GET request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServiceGetQuery

func HTTPServiceGetQuery(urlPath, urlQuery string) ([]byte, error)

HTTPServiceGetQuery triggers a HTTP GET request with query parameters to: <config.DcosURL>/service/<config.ServiceName><urlPath>?<urlQuery>

func HTTPServicePost

func HTTPServicePost(urlPath string) ([]byte, error)

HTTPServicePost triggers a HTTP POST request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServicePostData

func HTTPServicePostData(urlPath string, payload []byte, contentType string) ([]byte, error)

HTTPServicePostData triggers a HTTP POST request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServicePostJSON

func HTTPServicePostJSON(urlPath string, jsonPayload []byte) ([]byte, error)

HTTPServicePostJSON triggers a HTTP POST request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServicePostQuery

func HTTPServicePostQuery(urlPath, urlQuery string) ([]byte, error)

HTTPServicePostQuery triggers a HTTP POST request with query parameters to: <config.DcosURL>/service/<config.ServiceName><urlPath>?<urlQuery>

func HTTPServicePut

func HTTPServicePut(urlPath string) ([]byte, error)

HTTPServicePut triggers a HTTP PUT request to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServicePutData

func HTTPServicePutData(urlPath string, payload []byte, contentType string) ([]byte, error)

HTTPServicePutData triggers a HTTP PUT request with a payload of contentType to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServicePutJSON

func HTTPServicePutJSON(urlPath string, jsonPayload []byte) ([]byte, error)

HTTPServicePutJSON triggers a HTTP PUT request containing jsonPayload to: <config.DcosURL>/service/<config.ServiceName>/<urlPath>

func HTTPServicePutQuery

func HTTPServicePutQuery(urlPath, urlQuery string) ([]byte, error)

HTTPServicePutQuery triggers a HTTP PUT request with query parameters to: <config.DcosURL>/service/<config.ServiceName><urlPath>?<urlQuery>

func OptionalCLIConfigValue

func OptionalCLIConfigValue(name string) string

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

func PrintVerbose(format string, a ...interface{}) (int, error)

PrintVerbose prints a message using PrintMessage iff config.Verbose is enabled

func RequiredCLIConfigValue

func RequiredCLIConfigValue(name string, description string, errorInstruction string) string

RequiredCLIConfigValue gets config values from the DC/OS CLI

func RunCLICommand

func RunCLICommand(arg ...string) (string, error)

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.

Jump to

Keyboard shortcuts

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