http
http
is a generic step that makes an HTTP/S request to enable basic integration
with a wide variety of external services.
Configuration
Name | Type | Required | Description |
---|---|---|---|
method | string | Y | The HTTP method to use. |
url | string | Y | The URL to which the request should be made. |
headers | []object | N | A list of headers to include in the request. |
headers[].name | string | Y | The name of the header. |
headers[].value | string | Y | The value of the header. |
queryParams | []object | N | A list of query parameters to include in the request. |
queryParams[].name | string | Y | The name of the query parameter. |
queryParams[].value | string | Y | The value of the query parameter. The provided value will automatically be URL-encoded if necessary. |
body | string | N | The body of the request. Note: As this field is a string , take care to utilize quote() if the body is a valid JSON object . Refer to the example below of posting a message to a Slack channel. |
insecureSkipTLSVerify | boolean | N | Indicates whether to bypass TLS certificate verification when making the request. Setting this to true is highly discouraged. |
timeout | string | N | A string representation of the maximum time interval to wait for a request to complete. This is the timeout for an individual HTTP request. If a request is retried, each attempt is independently subject to this timeout. See Go's time package docs for a description of the accepted format. |
successExpression | string | N | An expr-lang expression that can evaluate the response to determine success. If this is left undefined and failureExpression is defined, the default success criteria will be the inverse of the specified failure criteria. If both are left undefined, success is true when the HTTP status code is 2xx . If successExpression and failureExpression are both defined and both evaluate to true , the failure takes precedence. Note that this expression should not be offset by ${{ and }} . See examples for more details. |
failureExpression | string | N | An expr-lang expression that can evaluate the response to determine failure. If this is left undefined and successExpression is defined, the default failure criteria will be the inverse of the specified success criteria. If both are left undefined, failure is true when the HTTP status code is not 2xx . If successExpression and failureExpression are both defined and both evaluate to true , the failure takes precedence. Note that this expression should not be offset by ${{ and }} . See examples for more details. |
outputs | []object | N | A list of rules for extracting outputs from the HTTP response. These are only applied to responses deemed successful. |
outputs[].name | string | Y | The name of the output. |
outputs[].fromExpression | string | Y | An expr-lang expression that can extract a value from the HTTP response. Note that this expression should not be offset by ${{ and }} . See examples for more details. |
An HTTP response that is not conclusively determined to have succeeded or failed
will result in the step reporting a result of Running
. Kargo will
retry such a step on its next
attempt at reconciling thePromotion
resource. This will continue until the step
succeeds, fails, exhausts the configured maximum number of retries, or a configured
timeout has elapsed.
Expressions
The successExpression
, failureExpression
, and outputs[].fromExpression
fields all support expr-lang expressions.
The expressions included in the successExpression
, failureExpression
, and
outputs[].fromExpression
fields should not be offset by ${{
and }}
. This
is to prevent the expressions from being evaluated by Kargo during
pre-processing of step configurations. The http
step itself will evaluate
these expressions.
A response
object (a map[string]any
) is available to these expressions. It
is structured as follows:
Field | Type | Description |
---|---|---|
status | int | The HTTP status code of the response. |
headers | http.Header | The headers of the response. See applicable Go documentation. |
header | func(string) string | headers can be inconvenient to work with directly. This function allows you to access a header by name. |
body | map[string]any | The body of the response, if any, unmarshaled into a map. If the response body is empty, this map will also be empty. |
Outputs
The http
step only produces the outputs described by the outputs
field of
its configuration.