Skip to content

Commit

Permalink
feat: fetch variables required to submit the image (#74)
Browse files Browse the repository at this point in the history
* feat: fetch variables required to submit the image

Signed-off-by: Dominik Rosiek <[email protected]>

* chore: comment

Signed-off-by: Dominik Rosiek <[email protected]>

* chore: comments

Signed-off-by: Dominik Rosiek <[email protected]>

* chore: refactor

Signed-off-by: Dominik Rosiek <[email protected]>

* chore: set env

Signed-off-by: Dominik Rosiek <[email protected]>

---------

Signed-off-by: Dominik Rosiek <[email protected]>
  • Loading branch information
sumo-drosiek authored May 29, 2024
1 parent 36435bf commit 7b244f5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:
jobs:
build-all:
runs-on: ubuntu-22.04
env:
CHECK: "false"
steps:
- uses: actions/checkout@v4
- name: Build all
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
preflight.log
25 changes: 23 additions & 2 deletions scripts/build-push-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@ HELM_CHART_VERSION=v4
SUMO_REGISTRY="public.ecr.aws/sumologic/"
PUSH=""
CHECK="${CHECK:-true}"
## Sumo Logic Helm Operator project id
## 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

## Perform image check
function check(){
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)"
## Prepare image name
SUMOLOGIC_IMAGE=${IMAGE_NAME}
}

IMAGES=$(./scripts/list-images.py \
--fetch-base \
Expand All @@ -27,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
Expand All @@ -40,6 +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
done

0 comments on commit 7b244f5

Please sign in to comment.