From ea3e6f072e8f5bec681f5c951cd4c5c900c115be Mon Sep 17 00:00:00 2001 From: Tomas Hozza Date: Thu, 3 Mar 2022 16:52:56 +0100 Subject: [PATCH] test/api.sh: filter repos by image type Filter the list of repositories passed in compose request based on the `image_type_tags` object member. This is the same approach used by the Weldr API. If the `image_type_tags` does not exist, the repo is added to the list. If the `image_type_tags` exists, the repo is added to the list only if the image type name is in the tags array. Signed-off-by: Tomas Hozza --- test/cases/api.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/cases/api.sh b/test/cases/api.sh index e1801b8bc..0974d9e1f 100755 --- a/test/cases/api.sh +++ b/test/cases/api.sh @@ -592,7 +592,7 @@ function createReqFileAWS() { "image_request": { "architecture": "$ARCH", "image_type": "${IMAGE_TYPE}", - "repositories": $(jq ".\"$ARCH\"" /usr/share/tests/osbuild-composer/repositories/"$DISTRO".json), + "repositories": $(jq ".\"$ARCH\" | .[] | select((has(\"image_type_tags\") | not) or (.\"image_type_tags\" | index(\"${IMAGE_TYPE}\")))" /usr/share/tests/osbuild-composer/repositories/"$DISTRO".json | jq -s .), "upload_options": { "region": "${AWS_REGION}", "snapshot_name": "${AWS_SNAPSHOT_NAME}", @@ -637,7 +637,7 @@ function createReqFileAWSS3() { "image_request": { "architecture": "$ARCH", "image_type": "${IMAGE_TYPE}", - "repositories": $(jq ".\"$ARCH\"" /usr/share/tests/osbuild-composer/repositories/"$DISTRO".json), + "repositories": $(jq ".\"$ARCH\" | .[] | select((has(\"image_type_tags\") | not) or (.\"image_type_tags\" | index(\"${IMAGE_TYPE}\")))" /usr/share/tests/osbuild-composer/repositories/"$DISTRO".json | jq -s .), "ostree": { "ref": "${OSTREE_REF}" }, @@ -711,7 +711,7 @@ function createReqFileGCP() { "image_request": { "architecture": "$ARCH", "image_type": "${IMAGE_TYPE}", - "repositories": $(jq ".\"$ARCH\"" /usr/share/tests/osbuild-composer/repositories/"$DISTRO".json), + "repositories": $(jq ".\"$ARCH\" | .[] | select((has(\"image_type_tags\") | not) or (.\"image_type_tags\" | index(\"${IMAGE_TYPE}\")))" /usr/share/tests/osbuild-composer/repositories/"$DISTRO".json | jq -s .), "upload_options": { "bucket": "${GCP_BUCKET}", "region": "${GCP_REGION}", @@ -749,7 +749,7 @@ function createReqFileAzure() { "image_request": { "architecture": "$ARCH", "image_type": "${IMAGE_TYPE}", - "repositories": $(jq ".\"$ARCH\"" /usr/share/tests/osbuild-composer/repositories/"$DISTRO".json), + "repositories": $(jq ".\"$ARCH\" | .[] | select((has(\"image_type_tags\") | not) or (.\"image_type_tags\" | index(\"${IMAGE_TYPE}\")))" /usr/share/tests/osbuild-composer/repositories/"$DISTRO".json | jq -s .), "upload_options": { "tenant_id": "${AZURE_TENANT_ID}", "subscription_id": "${AZURE_SUBSCRIPTION_ID}",