You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.5 KiB
Bash
76 lines
1.5 KiB
Bash
4 years ago
|
#!/usr/bin/env bash
|
||
|
# vim:ts=4:sts=4:sw=4:et
|
||
|
# args: /users/harisekhon | jq .
|
||
|
#
|
||
|
# Author: Hari Sekhon
|
||
|
# Date: 2020-02-12 23:43:00 +0000 (Wed, 12 Feb 2020)
|
||
|
#
|
||
|
# https://github.com/harisekhon/bash-tools
|
||
|
#
|
||
|
# License: see accompanying Hari Sekhon LICENSE file
|
||
|
#
|
||
|
# If you're using my code you're welcome to connect with me on LinkedIn and optionally send me feedback to help steer this or other code I publish
|
||
|
#
|
||
|
# https://www.linkedin.com/in/harisekhon
|
||
|
#
|
||
|
|
||
|
set -euo pipefail
|
||
|
[ -n "${DEBUG:-}" ] && set -x
|
||
|
srcdir="$(dirname "${BASH_SOURCE[0]}")"
|
||
|
|
||
|
# shellcheck disable=SC1090
|
||
|
. "$srcdir/lib/utils.sh"
|
||
|
|
||
|
# shellcheck disable=SC1090
|
||
|
. "$srcdir/lib/git.sh"
|
||
|
|
||
|
# shellcheck disable=SC2034,SC2154
|
||
|
usage_description="
|
||
|
Queries the Quay.com API
|
||
|
|
||
|
Requires \$QUAY_TOKEN to be set in the environment
|
||
|
|
||
|
Can specify \$CURL_OPTS for options to pass to curl or provide them as arguments
|
||
|
|
||
|
|
||
|
Set up your OAuth2 access token here:
|
||
|
|
||
|
https://quay.io/user/<username>?tab=robots
|
||
|
|
||
|
|
||
|
API Reference:
|
||
|
|
||
|
https://docs.quay.io/api/
|
||
|
|
||
|
|
||
|
API Explorer:
|
||
|
|
||
|
https://docs.quay.io/api/swagger/
|
||
|
"
|
||
|
|
||
|
# used by usage() in lib/utils.sh
|
||
|
# shellcheck disable=SC2034
|
||
|
usage_args="/path [<curl_options>]"
|
||
|
|
||
|
url_base="https://quay.io/api/v1"
|
||
|
|
||
|
CURL_OPTS="-sS --fail --connect-timeout 3 ${CURL_OPTS:-}"
|
||
|
|
||
|
check_env_defined "QUAY_TOKEN"
|
||
|
|
||
|
help_usage "$@"
|
||
|
|
||
|
min_args 1 "$@"
|
||
|
|
||
|
export TOKEN="$QUAY_TOKEN"
|
||
|
|
||
|
url_path="${1:-}"
|
||
|
shift
|
||
|
|
||
|
url_path="${url_path//https:\/\/quay.io\/api\/v1/}"
|
||
|
url_path="${url_path##/}"
|
||
|
|
||
|
# need CURL_OPTS splitting, safer than eval
|
||
|
# shellcheck disable=SC2086
|
||
|
"$srcdir/curl_auth.sh" -L "$url_base/$url_path" "$@" $CURL_OPTS
|