Sign inSign up

swaleio/curl-jq

By swaleio

•Updated about 2 months ago

curl and jq for HTTP requests in Swale workflows. Backs the http-request task.

Image
0

374

swaleio/curl-jq repository overview

⁠curl-jq

A small Alpine-based image bundling curl, jq, and CA certificates, with an entry point that performs a single HTTP request and reports its outcome the way the Swale container contract expects. It is the swale-built image behind Swale's http-request task and is not intended to be run standalone.

The entry point assembles the curl invocation from INPUT_* environment variables (injected by the platform from task inputs), writes the response body to the file named by INPUT_RESPONSE_PATH (defaulting to response.json in the working directory — /mnt/workspace unless overridden), and appends the HTTP status and body path to $WORKFLOW_TASK_OUTPUT. Arguments are built as a quoted argument vector -- never via string concatenation or eval -- so header values, request bodies, and URLs are always passed as opaque tokens.

jq is included so downstream tasks (or a wrapping script) can parse the JSON response the request leaves in the workspace.

⁠Inputs it reads

Environment variableRequiredDefaultPurpose
INPUT_URLyes—The request URL.
INPUT_METHODnoGETHTTP method (--request).
INPUT_HEADERSno—Newline-separated Key: Value lines; each non-empty line becomes a repeated --header.
INPUT_BODYno—Inline request body (sent with --data-raw).
INPUT_BODY_FILEno—Path to a body file (sent with --data-binary @<path>); takes precedence over INPUT_BODY.
INPUT_RETRYno3Retry count passed to curl --retry.
INPUT_RETRY_ON_CONNREFUSEDnotrueWhen true, adds --retry-connrefused.
INPUT_RESPONSE_PATHnoresponse.jsonWhere the response body is written (relative paths land in the working directory; pass an absolute path to place it elsewhere).
INPUT_EXPECTED_STATUSno—If set and the actual status differs, the task exits non-zero.

⁠Outputs it emits

Appended to $WORKFLOW_TASK_OUTPUT as key=value lines:

OutputDescription
statusThe HTTP status code returned by the request.
body_fileThe path of the written response body.

⁠Behavior notes

  • A transport-level failure (DNS, connection, TLS) exits non-zero and fails the task; retries are governed by INPUT_RETRY / INPUT_RETRY_ON_CONNREFUSED.
  • An HTTP error status (4xx/5xx) is captured and emitted normally -- curl is not run with --fail. Use INPUT_EXPECTED_STATUS to turn an unexpected status into a task failure.
  • Runs as a non-root user (uid 1000) with WORKDIR /mnt/workspace, per the Swale container contract.

Built from images/curl-jq⁠ in the swaleio/task-definitions⁠ repository. For how a task definition references an image, see the task definition reference⁠ in the Swale documentation⁠.

The Dockerfile and entrypoint are covered by the MIT License⁠. The software this image packages keeps its own licenses, which ship inside the image.

Tag summary

Content type

Image

Digest

sha256:4e69b0173…

Size

6.5 MB

Last updated

about 2 months ago

docker pull swaleio/curl-jq