client

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectResponse

func CollectResponse(
	cluster framework.Cluster,
	container string,
	destination string,
	fn ...CollectResponsesOptsFn,
) (types.EchoResponse, error)

func CollectResponseDirectly

func CollectResponseDirectly(
	destination string,
	fn ...CollectResponsesOptsFn,
) (types.EchoResponse, error)

CollectResponseDirectly collects responses using http client that calls the server from outside the cluster

func CollectResponses

func CollectResponses(cluster framework.Cluster, source, destination string, fn ...CollectResponsesOptsFn) ([]types.EchoResponse, error)

func CollectResponsesByInstance

func CollectResponsesByInstance(cluster framework.Cluster, source, destination string, fn ...CollectResponsesOptsFn) (map[string]int, error)

func CollectTCPResponse

func CollectTCPResponse(
	cluster framework.Cluster,
	container string,
	destination string,
	stdin string,
	fn ...CollectResponsesOptsFn,
) (string, error)

func MakeDirectRequest

func MakeDirectRequest(
	destination string,
	fn ...CollectResponsesOptsFn,
) (*http.Response, error)

MakeDirectRequest collects responses using http client that calls the server from outside the cluster

Types

type CollectResponsesOpts

type CollectResponsesOpts struct {
	NumberOfRequests int
	URL              string
	Method           string
	Headers          map[string]string

	Flags        []string
	ShellEscaped func(string) string
	// contains filtered or unexported fields
}

func CollectOptions

func CollectOptions(requestURL string, options ...CollectResponsesOptsFn) CollectResponsesOpts

func DefaultCollectResponsesOpts

func DefaultCollectResponsesOpts() CollectResponsesOpts

type CollectResponsesOptsFn

type CollectResponsesOptsFn func(opts *CollectResponsesOpts)

func FromKubernetesPod

func FromKubernetesPod(namespace string, application string) CollectResponsesOptsFn

FromKubernetesPod executes the curl command from a pod belonging to the specified Kubernetes deployment. The cluster must be a Kubernetes cluster, and the deployment must have an "app" label that matches the application parameter.

Note that the caller of CollectResponse still needs to specify the source container name within the Pod.

func Insecure

func Insecure() CollectResponsesOptsFn

Insecure sets the curl --insecure flag. See https://curl.se/docs/manpage.html#-k.

func NoFail

func NoFail() CollectResponsesOptsFn

NoFail removes the default curl --fail flag. See https://curl.se/docs/manpage.html#-f.

func OutputFormat

func OutputFormat(format string) CollectResponsesOptsFn

OutputFormat sets the curl --write-out flag. See https://everything.curl.dev/usingcurl/verbose/writeout.

func Resolve

func Resolve(hostPort string, address string) CollectResponsesOptsFn

Resolve sets the curl --resolve flag. See https://curl.se/docs/manpage.html#--resolve.

func WithHeader

func WithHeader(key, value string) CollectResponsesOptsFn

func WithMethod

func WithMethod(method string) CollectResponsesOptsFn

func WithNumberOfRequests

func WithNumberOfRequests(numberOfRequests int) CollectResponsesOptsFn

func WithPathPrefix

func WithPathPrefix(prefix string) CollectResponsesOptsFn

WithPathPrefix injects prefix at the start of the target URL path.

type FailureResponse

type FailureResponse struct {
	Exitcode int `json:"exitcode"`

	ResponseCode int    `json:"response_code"`
	Method       string `json:"method"`
	Scheme       string `json:"scheme"`
	ContentType  string `json:"content_type"`
	URL          string `json:"url"`
	EffectiveURL string `json:"url_effective"`
}

FailureResponse is the JSON output for a Curl command. Note that the available fields depend on the Curl version, which must be at least 7.70.0 for this feature.

See https://curl.se/docs/manpage.html#-w.

func CollectFailure

func CollectFailure(cluster framework.Cluster, container, destination string, fn ...CollectResponsesOptsFn) (FailureResponse, error)

CollectFailure runs Curl to fetch a URL that is expected to fail. The Curl JSON output is returned so the caller can inspect the failure to see whether it was what was expected.

Jump to

Keyboard shortcuts

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