This is an automated email from the ASF dual-hosted git repository.

pcongiusti pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git

commit bf7449943674c1b7a5f7bec600a419b26309adec
Author: phantomjinx <[email protected]>
AuthorDate: Fri Feb 25 13:39:04 2022 +0000

    Build latest opm with fix to http-only
---
 .../kamel-build-bundle/build-index-image.sh        |  6 +++-
 .github/actions/kamel-config-cluster/action.yaml   | 13 --------
 .../actions/kamel-preflight-test/preflight-test.sh |  2 +-
 script/Makefile                                    | 20 +++---------
 script/build_install_opm.sh                        | 37 ++++++++++++++++++++++
 5 files changed, 47 insertions(+), 31 deletions(-)

diff --git a/.github/actions/kamel-build-bundle/build-index-image.sh 
b/.github/actions/kamel-build-bundle/build-index-image.sh
index cbd44b09c..9cd3faf64 100755
--- a/.github/actions/kamel-build-bundle/build-index-image.sh
+++ b/.github/actions/kamel-build-bundle/build-index-image.sh
@@ -172,9 +172,13 @@ if [ -d ${CATALOG_DIR} ]; then
   rm -rf ${CATALOG_DIR}
 fi
 
+if [ -f ${CATALOG_DIR}.Dockerfile ]; then
+  rm -f ${CATALOG_DIR}.Dockerfile
+fi
+
 mkdir ${CATALOG_DIR}
 opm render quay.io/operatorhubio/catalog:latest -o yaml > 
${CATALOG_DIR}/bundles.yaml
-sudo opm render --use-http -o yaml ${BUNDLE_IMAGE} > 
${CATALOG_DIR}/camel-k.yaml
+opm render --use-http -o yaml ${BUNDLE_IMAGE} > ${CATALOG_DIR}/camel-k.yaml
 cat << EOF >> ${CATALOG_DIR}/camel-k.yaml
 ---
 schema: olm.channel
diff --git a/.github/actions/kamel-config-cluster/action.yaml 
b/.github/actions/kamel-config-cluster/action.yaml
index 90a5ae7d6..556433c54 100644
--- a/.github/actions/kamel-config-cluster/action.yaml
+++ b/.github/actions/kamel-config-cluster/action.yaml
@@ -115,19 +115,6 @@ runs:
             ;;
         esac
 
-      #
-      # Install opm if required
-      #
-    - id: install-opm
-      name: Install opm if required
-      shell: bash
-      run: |
-        if [ "${{ inputs.opm }}" == "true" ]; then
-          curl -L 
https://github.com/operator-framework/operator-registry/releases/download/v1.19.5/linux-amd64-opm
 -o opm
-          chmod +x opm
-          sudo mv opm /usr/local/bin/
-        fi
-
       #
       # Install OLM if required
       #
diff --git a/.github/actions/kamel-preflight-test/preflight-test.sh 
b/.github/actions/kamel-preflight-test/preflight-test.sh
index a584193ba..d210e46da 100755
--- a/.github/actions/kamel-preflight-test/preflight-test.sh
+++ b/.github/actions/kamel-preflight-test/preflight-test.sh
@@ -19,7 +19,7 @@
 
 ####
 #
-# Execute the kubernetes tests
+# Execute a preflight test for checking the operator is at the correct version
 #
 ####
 
diff --git a/script/Makefile b/script/Makefile
index 37ea17b1a..58681eaa0 100644
--- a/script/Makefile
+++ b/script/Makefile
@@ -25,13 +25,11 @@ INSTALL_DEFAULT_KAMELETS := true
 CONTROLLER_GEN_VERSION := v0.4.1
 OPERATOR_SDK_VERSION := v1.14.0
 KUSTOMIZE_VERSION := v4.1.2
+OPM_VERSION := v1.21.0
 BASE_IMAGE := adoptopenjdk/openjdk11:slim
 LOCAL_REPOSITORY := /tmp/artifacts/m2
 IMAGE_NAME := docker.io/apache/camel-k
 
-OPM_VERSION := v1.21.0 # <- Not yet released
-OPM_PKG := github.com/operator-framework/operator-registry
-
 #
 # Situations when user wants to override
 # the image name and version
@@ -444,21 +442,11 @@ OPERATOR_SDK=$(shell command -v operator-sdk 2> /dev/null)
 endif
 
 opm:
-ifeq (, $(shell which opm))
-       @{ \
-       set -e ;\
-       OPM_GEN_TMP_DIR=$$(mktemp -d) ;\
-       cd $$OPM_GEN_TMP_DIR ;\
-       go mod init tmp ;\
-       go get \
-               -ldflags '-w -extldflags "-static"' -tags "json1" \
-               -ldflags "-X 
'$(OPM_PKG)/cmd/opm/version.opmVersion=$(OPM_VERSION)'" \
-               $(OPM_PKG)/cmd/opm@$(OPM_VERSION) ;\
-               rm -rf $$OPM_GEN_TMP_DIR ;\
-       }
+ifeq (, $(shell command -v opm 2> /dev/null))
+       @OPM_VERSION=$(OPM_VERSION) ./script/build_install_opm.sh
 OPM=$(GOBIN)/opm
 else
-OPM=$(shell which opm)
+OPM=$(shell command -v opm 2> /dev/null)
 endif
 
 .PHONY: generate-crd $(BUNDLE_CAMEL_APIS) bundle bundle-build
diff --git a/script/build_install_opm.sh b/script/build_install_opm.sh
new file mode 100755
index 000000000..795a5bb7b
--- /dev/null
+++ b/script/build_install_opm.sh
@@ -0,0 +1,37 @@
+#!/bin/bash
+set +e
+
+check_env_var() {
+  if [ -z "${2}" ]; then
+    echo "Error: ${1} env var not defined"
+    exit 1
+  fi
+}
+
+check_env_var "OPM_VERSION" ${OPM_VERSION}
+
+OPM_PKG=github.com/operator-framework/operator-registry
+#
+# Timestamp for the building of the operator
+#
+BUILD_TIME=$(date +%Y-%m-%dT%H:%M:%S%z)
+
+OPM_GEN_TMP_DIR=$(mktemp -d)
+echo "Using temporary directory ${OPM_GEN_TMP_DIR}"
+cd ${OPM_GEN_TMP_DIR}
+
+go mod init tmp ;\
+go get \
+  -ldflags '-w -extldflags "-static"' -tags "json1" \
+  -ldflags "-X '${OPM_PKG}/cmd/opm/version.opmVersion=${OPM_VERSION}'" \
+  ${OPM_PKG}/cmd/opm@${OPM_VERSION} ;\
+
+if [ $? != 0 ]; then
+  echo "Error: Failed to install opm version ${OPM_VERSION}"
+  exit 1
+fi
+
+echo "OPM Version ..."
+opm version
+
+rm -rf ${OPM_GEN_TMP_DIR}

Reply via email to