From 05e2efd05662475931c1152ef796ba527d3d3c87 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Tue, 28 May 2024 13:53:04 +0200 Subject: [PATCH 1/5] feat: fetch variables required to submit the image Signed-off-by: Dominik Rosiek --- scripts/build-push-all.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/build-push-all.sh b/scripts/build-push-all.sh index 133d4fd..ec1dac1 100755 --- a/scripts/build-push-all.sh +++ b/scripts/build-push-all.sh @@ -6,6 +6,7 @@ HELM_CHART_VERSION=v4 SUMO_REGISTRY="public.ecr.aws/sumologic/" PUSH="" CHECK="${CHECK:-true}" +OPERATOR_PROJECT_ID=6075d88c2b962feb86bea730 IMAGES=$(./scripts/list-images.py \ --fetch-base \ @@ -42,4 +43,9 @@ for IMAGE in ${IMAGES}; do if [[ "${CHECK}" == "true" ]]; then make -C ${NAME} check IMAGE_NAME=${IMAGE_NAME} UPSTREAM_VERSION="${UPSTREAM_VERSION}" fi + + # prepare image to submit + CONTAINER_PROJECT_ID="$(curl -sH "X-API-KEY: ${RED_HAT_API_KEY}" "https://catalog.redhat.com/api/containers/v1/product-listings/id/${OPERATOR_PROJECT_ID}/projects/certification" | jq ".data[] | select(.name == \"${NAME}\")._id" --raw-output)" + CONTAINER_REGISTRY_KEY="$(curl -sH "X-API-KEY: ${RED_HAT_API_KEY}" "https://catalog.redhat.com/api/containers/v1/projects/certification/id/${CONTAINER_PROJECT_ID}/secrets" | jq ".registry_credentials.password" --raw-output)" + SUMOLOGIC_IMAGE=${IMAGE_NAME} done From 233b679cbc730b0093abe88912f51d12d27a2ab4 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Tue, 28 May 2024 14:12:40 +0200 Subject: [PATCH 2/5] chore: comment Signed-off-by: Dominik Rosiek --- scripts/build-push-all.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/build-push-all.sh b/scripts/build-push-all.sh index ec1dac1..b6b892b 100755 --- a/scripts/build-push-all.sh +++ b/scripts/build-push-all.sh @@ -6,7 +6,9 @@ HELM_CHART_VERSION=v4 SUMO_REGISTRY="public.ecr.aws/sumologic/" PUSH="" CHECK="${CHECK:-true}" -OPERATOR_PROJECT_ID=6075d88c2b962feb86bea730 +## Sumo Logic Helm Operator project id +## rel: https://connect.redhat.com/manage/products/6075d88c2b962feb86bea730/overview +readonly OPERATOR_PROJECT_ID=6075d88c2b962feb86bea730 IMAGES=$(./scripts/list-images.py \ --fetch-base \ From a93ba4d72c6d3721065bb54014a0ee9f4e23a97a Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Tue, 28 May 2024 14:14:05 +0200 Subject: [PATCH 3/5] chore: comments Signed-off-by: Dominik Rosiek --- scripts/build-push-all.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/build-push-all.sh b/scripts/build-push-all.sh index b6b892b..c605de2 100755 --- a/scripts/build-push-all.sh +++ b/scripts/build-push-all.sh @@ -46,8 +46,12 @@ for IMAGE in ${IMAGES}; do make -C ${NAME} check IMAGE_NAME=${IMAGE_NAME} UPSTREAM_VERSION="${UPSTREAM_VERSION}" fi - # prepare image to submit + ## prepare image to submit + + ## Fetch container project id based on directory(image) name CONTAINER_PROJECT_ID="$(curl -sH "X-API-KEY: ${RED_HAT_API_KEY}" "https://catalog.redhat.com/api/containers/v1/product-listings/id/${OPERATOR_PROJECT_ID}/projects/certification" | jq ".data[] | select(.name == \"${NAME}\")._id" --raw-output)" + ## Fetch key for image registry CONTAINER_REGISTRY_KEY="$(curl -sH "X-API-KEY: ${RED_HAT_API_KEY}" "https://catalog.redhat.com/api/containers/v1/projects/certification/id/${CONTAINER_PROJECT_ID}/secrets" | jq ".registry_credentials.password" --raw-output)" + ## Prepate image name SUMOLOGIC_IMAGE=${IMAGE_NAME} done From bdd7ff6051f282f9e22afcf96080a78ff426571f Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Wed, 29 May 2024 07:50:53 +0200 Subject: [PATCH 4/5] chore: refactor Signed-off-by: Dominik Rosiek --- .gitignore | 1 + scripts/build-push-all.sh | 31 ++++++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..00b2158 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +preflight.log diff --git a/scripts/build-push-all.sh b/scripts/build-push-all.sh index c605de2..624d5c0 100755 --- a/scripts/build-push-all.sh +++ b/scripts/build-push-all.sh @@ -10,6 +10,24 @@ CHECK="${CHECK:-true}" ## rel: https://connect.redhat.com/manage/products/6075d88c2b962feb86bea730/overview readonly OPERATOR_PROJECT_ID=6075d88c2b962feb86bea730 +if [[ -z "${RED_HAT_API_KEY}" && "${CHECK}" == "true" ]]; then + echo "RED_HAT_API_KEY is required to perform check" + exit -1 +fi + +function check(){ + echo ${NAME} ${IMAGE_NAME} ${UPSTREAM_VERSION} + make -C ${NAME} check IMAGE_NAME=${IMAGE_NAME} UPSTREAM_VERSION="${UPSTREAM_VERSION}" + + ## prepare image to submit + ## Fetch container project id based on directory(image) name + CONTAINER_PROJECT_ID="$(curl -sH "X-API-KEY: ${RED_HAT_API_KEY}" "https://catalog.redhat.com/api/containers/v1/product-listings/id/${OPERATOR_PROJECT_ID}/projects/certification" | jq ".data[] | select(.name == \"${NAME}\")._id" --raw-output)" + ## Fetch key for image registry + CONTAINER_REGISTRY_KEY="$(curl -sH "X-API-KEY: ${RED_HAT_API_KEY}" "https://catalog.redhat.com/api/containers/v1/projects/certification/id/${CONTAINER_PROJECT_ID}/secrets" | jq ".registry_credentials.password" --raw-output)" + ## Prepate image name + SUMOLOGIC_IMAGE=${IMAGE_NAME} +} + IMAGES=$(./scripts/list-images.py \ --fetch-base \ --values scripts/values.yaml \ @@ -30,7 +48,7 @@ for IMAGE in ${IMAGES}; do echo ${IMAGE_NAME} if docker pull ${IMAGE_NAME}; then if [[ "${CHECK}" == "true" ]]; then - make -C ${NAME} check IMAGE_NAME=${IMAGE_NAME} UPSTREAM_VERSION="${UPSTREAM_VERSION}" + check fi # as image exist, we can go to the next one continue @@ -43,15 +61,6 @@ for IMAGE in ${IMAGES}; do fi if [[ "${CHECK}" == "true" ]]; then - make -C ${NAME} check IMAGE_NAME=${IMAGE_NAME} UPSTREAM_VERSION="${UPSTREAM_VERSION}" + check fi - - ## prepare image to submit - - ## Fetch container project id based on directory(image) name - CONTAINER_PROJECT_ID="$(curl -sH "X-API-KEY: ${RED_HAT_API_KEY}" "https://catalog.redhat.com/api/containers/v1/product-listings/id/${OPERATOR_PROJECT_ID}/projects/certification" | jq ".data[] | select(.name == \"${NAME}\")._id" --raw-output)" - ## Fetch key for image registry - CONTAINER_REGISTRY_KEY="$(curl -sH "X-API-KEY: ${RED_HAT_API_KEY}" "https://catalog.redhat.com/api/containers/v1/projects/certification/id/${CONTAINER_PROJECT_ID}/secrets" | jq ".registry_credentials.password" --raw-output)" - ## Prepate image name - SUMOLOGIC_IMAGE=${IMAGE_NAME} done From 105a36c47455b262bc5da9f7ef411a9a0ea090b7 Mon Sep 17 00:00:00 2001 From: Dominik Rosiek Date: Wed, 29 May 2024 07:51:33 +0200 Subject: [PATCH 5/5] chore: set env Signed-off-by: Dominik Rosiek --- .github/workflows/pull_requests.yml | 2 ++ scripts/build-push-all.sh | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_requests.yml b/.github/workflows/pull_requests.yml index 7107d68..38a7d94 100644 --- a/.github/workflows/pull_requests.yml +++ b/.github/workflows/pull_requests.yml @@ -8,6 +8,8 @@ on: jobs: build-all: runs-on: ubuntu-22.04 + env: + CHECK: "false" steps: - uses: actions/checkout@v4 - name: Build all diff --git a/scripts/build-push-all.sh b/scripts/build-push-all.sh index 624d5c0..83a6c94 100755 --- a/scripts/build-push-all.sh +++ b/scripts/build-push-all.sh @@ -15,8 +15,8 @@ if [[ -z "${RED_HAT_API_KEY}" && "${CHECK}" == "true" ]]; then exit -1 fi +## Perform image check function check(){ - echo ${NAME} ${IMAGE_NAME} ${UPSTREAM_VERSION} make -C ${NAME} check IMAGE_NAME=${IMAGE_NAME} UPSTREAM_VERSION="${UPSTREAM_VERSION}" ## prepare image to submit @@ -24,7 +24,7 @@ function check(){ CONTAINER_PROJECT_ID="$(curl -sH "X-API-KEY: ${RED_HAT_API_KEY}" "https://catalog.redhat.com/api/containers/v1/product-listings/id/${OPERATOR_PROJECT_ID}/projects/certification" | jq ".data[] | select(.name == \"${NAME}\")._id" --raw-output)" ## Fetch key for image registry CONTAINER_REGISTRY_KEY="$(curl -sH "X-API-KEY: ${RED_HAT_API_KEY}" "https://catalog.redhat.com/api/containers/v1/projects/certification/id/${CONTAINER_PROJECT_ID}/secrets" | jq ".registry_credentials.password" --raw-output)" - ## Prepate image name + ## Prepare image name SUMOLOGIC_IMAGE=${IMAGE_NAME} }