summaryrefslogtreecommitdiff
path: root/curl.sh
blob: 493b0f87cac3e16e637ee88435a750f433fc3b72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/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 @"$1" \
                -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"
        ;;

    deploy)
        runcurl  -X POST --data-binary @"$1" \
                -H "Content-Type: application/json" \
                https://wmf2-deployer.vm.liw.fi/publish
        ;;

    status)
        runcurl https://wmf2-controller.vm.liw.fi/status
        ;;

    *)
        echo "eek" 1>&2
        exit 1
        ;;
esac