check

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: Apache-2.0 Imports: 10 Imported by: 6

Documentation

Index

Constants

View Source
const (
	DefaultConditionTimeout  = "120s"
	DefaultConditionInterval = "5s"
)
View Source
const (
	DefaultCurlDelay       = "1s"
	DefaultCurlAttempts    = 10
	DefaultMethod          = "GET"
	DefaultPortForwardPort = 8080
)

Variables

View Source
var (
	UnexpectedStatusCodeError = func(statusCode int) error {
		return errors.Errorf("Curl got unexpected status code %d", statusCode)
	}
	UnexpectedResponseBodyError = func(responseBody string) error {
		return errors.Errorf("Curl got unexpected response body:\n%s", responseBody)
	}
)
View Source
var (
	ConditionNotMetError = errors.Errorf("Condition wasn't met")
)

Functions

This section is empty.

Types

type Condition

type Condition struct {
	Type      string `json:"type"`
	Name      string `json:"name" valet:"template"`
	Namespace string `json:"namespace"`
	Jsonpath  string `json:"jsonpath"`
	Value     string `json:"value"`
	Timeout   string `json:"timeout" valet:"template,default=120s"`
	Interval  string `json:"interval" valet:"template,default=5s"`
}

func (*Condition) GetCmd

func (c *Condition) GetCmd() *cmd.Command

func (*Condition) GetDescription

func (c *Condition) GetDescription(ctx *api.WorkflowContext, values render.Values) (string, error)

func (*Condition) GetDocs

func (c *Condition) GetDocs(ctx *api.WorkflowContext, values render.Values, flags render.Flags) (string, error)

func (*Condition) Run

func (c *Condition) Run(ctx *api.WorkflowContext, values render.Values) error

type Curl

type Curl struct {
	Path                  string            `json:"path,omitempty"`
	Host                  string            `json:"host,omitempty"`
	Headers               map[string]string `json:"headers,omitempty"`
	StatusCode            int               `json:"statusCode,omitempty" valet:"default=200"`
	Method                string            `json:"method,omitempty" valet:"default=GET"`
	RequestBody           string            `json:"body,omitempty"`
	ResponseBody          string            `json:"responseBody,omitempty"`
	ResponseBodySubstring string            `json:"responseBodySubstring,omitempty"`
	Service               *ServiceRef       `json:"service,omitempty"`
	PortForward           *PortForward      `json:"portForward,omitempty"`
	Attempts              int               `json:"attempts,omitempty" valet:"default=10"`
	Delay                 string            `json:"delay,omitempty" valet:"default=1s"`
}

Use Curl to simulate testing an endpoint with an HTTP request using curl.

If service is provided, then the URL to send the request to will be determined by getting the address to a service exposed in the current Kube context.

If portForward is provided, then the curl will be wrapped in a port-forward, exposing some deployment and port to localhost. The request will be send to a localhost address.

Only one of service or portForward should be provided.

The request can be customized with the path, host, headers, and requestBody fields.

The response can be validated with the statusCode, responseBody, and responseBodySubstring fields.

Curl will by default try 10 times if the validation criteria isn't met for any reason, with a delay of 1 second between attempt. Customize these with the attempts and delay fields.

func (*Curl) GetDescription

func (c *Curl) GetDescription(ctx *api.WorkflowContext, values render.Values) (string, error)

func (*Curl) GetDocs

func (c *Curl) GetDocs(ctx *api.WorkflowContext, values render.Values, flags render.Flags) (string, error)

func (*Curl) GetHttpRequest

func (c *Curl) GetHttpRequest(url string) (*http.Request, error)

func (*Curl) GetUrl

func (c *Curl) GetUrl(ctx *api.WorkflowContext, values render.Values) (string, error)

func (*Curl) Run

func (c *Curl) Run(ctx *api.WorkflowContext, values render.Values) error

type PortForward

type PortForward struct {
	Namespace      string `json:"namespace,omitempty" valet:"key=Namespace"`
	DeploymentName string `json:"deploymentName,omitempty"`
	Port           int    `json:"port,omitempty" valet:"default=8080"`
}

func (*PortForward) Initiate

func (p *PortForward) Initiate(ctx *api.WorkflowContext, values render.Values) (*cmd.CommandStreamHandler, error)

type ServiceRef

type ServiceRef struct {
	Name      string `json:"name,omitempty"`
	Namespace string `json:"namespace,omitempty" valet:"key=Namespace"`
	Port      string `json:"port,omitempty" valet:"default=http"`
}

func (*ServiceRef) GetAddress

func (s *ServiceRef) GetAddress(ctx *api.WorkflowContext, values render.Values) (string, error)

func (*ServiceRef) GetIp

func (s *ServiceRef) GetIp(ctx *api.WorkflowContext, values render.Values) (string, error)

type WaitForPods

type WaitForPods struct {
	// Namespace to check for pods
	Namespace string `json:"namespace,omitempty"`
}

check.WaitForPods is a workflow step that is used to pause a workflow until the pods in a namespace are ready or completed successfully.

func (*WaitForPods) GetDescription

func (w *WaitForPods) GetDescription(_ *api.WorkflowContext, _ render.Values) (string, error)

func (*WaitForPods) GetDocs

func (*WaitForPods) Run

Jump to

Keyboard shortcuts

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