cloudapi: V2

V2 is compliant with api.openshift.com design guidelines.

Errors are predefined, have codes, and are queryable.

All requests have an operationId set: a unique identifier which is
sortable by time. This is added to the response in case of an error.

All returned objects have the href, id, and kind field set.
This commit is contained in:
sanne 2021-08-25 16:49:17 +02:00 committed by Sanne Raymaekers
parent 19eb65e9fd
commit 5a9d8c792b
28 changed files with 4877 additions and 585 deletions

View file

@ -656,6 +656,7 @@ function sendCompose() {
function waitForState() {
local DESIRED_STATE="${1:-success}"
local VERSION="${2:-v1}"
while true
do
OUTPUT=$(curl \
@ -664,7 +665,7 @@ function waitForState() {
--cacert /etc/osbuild-composer/ca-crt.pem \
--key /etc/osbuild-composer/client-key.pem \
--cert /etc/osbuild-composer/client-crt.pem \
https://localhost/api/composer/v1/compose/"$COMPOSE_ID")
https://localhost/api/composer/"$VERSION"/compose/"$COMPOSE_ID")
COMPOSE_STATUS=$(echo "$OUTPUT" | jq -r '.image_status.status')
UPLOAD_STATUS=$(echo "$OUTPUT" | jq -r '.image_status.upload_status.status')
@ -713,6 +714,8 @@ sudo systemctl start "osbuild-worker@1"
INIT_COMPOSES="$(collectMetrics)"
sendCompose
waitForState
# Same state with v2
waitForState "success" "v2"
SUBS_COMPOSES="$(collectMetrics)"
test "$UPLOAD_STATUS" = "success"
@ -947,6 +950,20 @@ function verifyInAWSS3() {
echo "Commit ID returned from API does not match Commit ID in archive 😠"
exit 1
fi
# v2 has the same result
API_COMMIT_ID_V2=$(curl \
--silent \
--show-error \
--cacert /etc/osbuild-composer/ca-crt.pem \
--key /etc/osbuild-composer/client-key.pem \
--cert /etc/osbuild-composer/client-crt.pem \
https://localhost/api/composer/v2/compose/"$COMPOSE_ID"/metadata | jq -r '.ostree_commit')
if [[ "${API_COMMIT_ID_V2}" != "${TAR_COMMIT_ID}" ]]; then
echo "Commit ID returned from API v2 does not match Commit ID in archive 😠"
exit 1
fi
}
# Verify image in Compute Engine on GCP