From b57c89e61b60743b0f2b6bd6c6bf4e4b80fb505c Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 7 Jul 2019 18:29:20 +0300 Subject: Add: helper scripts to use CI component API --- curl.sh | 34 ++++++++++++++++++++++++++++++++++ mktoken | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100755 curl.sh create mode 100755 mktoken diff --git a/curl.sh b/curl.sh new file mode 100755 index 0000000..412192c --- /dev/null +++ b/curl.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +set -eu + +runcurl() { + ./mktoken > token + curl -s -H "Authorization: Bearer $(cat token)" "$@" +} + +cmd="$1" +shift 1 + +case "$cmd" in + update-repo) + runcurl -X POST --data-binary @hithere.json \ + -H "Content-Type: application/json" \ + https://wmf2-vcsworker.vm.liw.fi/updaterepo + ;; + + upload-blob) + runcurl -X PUT --data-binary @"$1" \ + -H "Content-Type: application/octet-stream" \ + https://wmf2-artifacts.vm.liw.fi/blobs/"$2" + ;; + + get-blob) + runcurl -X GET https://wmf2-artifacts.vm.liw.fi/blobs/"$1" + ;; + + *) + echo "eek" 1>&2 + exit 1 + ;; +esac diff --git a/mktoken b/mktoken new file mode 100755 index 0000000..c10e86e --- /dev/null +++ b/mktoken @@ -0,0 +1,49 @@ +#!/bin/sh + +set -eu + +scopes=" +status +hello +update-repo +uapi_version_get +uapi_work_post +uapi_status_get +uapi_projects_id_status_get +uapi_projects_id_status_put +uapi_blobs_id_get +uapi_blobs_id_put +uapi_notify_post +uapi_projects_get +uapi_projects_post +uapi_projects_id_get +uapi_projects_id_put +uapi_projects_id_delete +uapi_pipelines_get +uapi_pipelines_post +uapi_pipelines_id_get +uapi_pipelines_id_put +uapi_pipelines_id_delete +uapi_workers_get +uapi_workers_post +uapi_workers_id_get +uapi_workers_id_put +uapi_workers_id_delete +uapi_work_get +uapi_work_post +uapi_work_id_get +uapi_work_id_put +uapi_work_id_delete +uapi_builds_get +uapi_builds_post +uapi_builds_id_get +uapi_builds_id_put +uapi_builds_id_delete +uapi_logs_get +uapi_logs_post +uapi_logs_id_get +uapi_logs_id_put +uapi_logs_id_delete +" + +./create-token key iss aud "$scopes" -- cgit v1.2.1