You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2022/10/20 12:57:52 UTC

[camel-k] branch main updated: Fix get_catalog.sh when runtime is snapshot

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


The following commit(s) were added to refs/heads/main by this push:
     new 9cbbb81fe Fix get_catalog.sh when runtime is snapshot
9cbbb81fe is described below

commit 9cbbb81feede5d1ac15f6ce2d242add4ad28e684
Author: Claudio Miranda <cl...@claudius.com.br>
AuthorDate: Wed Oct 19 19:18:27 2022 -0300

    Fix get_catalog.sh when runtime is snapshot
    
    When the runtime is SNAPSHOT and uses a snapshot repository
    the downloaded artifact contains a timestamp which is not recognized
    when trying to move the file.
---
 script/get_catalog.sh | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/script/get_catalog.sh b/script/get_catalog.sh
index eaeec9025..9f1bdf79f 100755
--- a/script/get_catalog.sh
+++ b/script/get_catalog.sh
@@ -22,18 +22,26 @@ if [ "$#" -lt 1 ]; then
   echo "usage: $0 <Camel K runtime version> [<staging repository>]"
   exit 1
 fi
-
+runtime_version="$1"
 if [ -z $2 ]; then
-  mvn -q dependency:copy -Dartifact="org.apache.camel.k:camel-k-catalog:$1:yaml:catalog" -DoutputDirectory=${rootdir}/resources/
-  mv ${rootdir}/resources/camel-k-catalog-$1-catalog.yaml ${rootdir}/resources/camel-catalog-$1.yaml
+  mvn -q dependency:copy -Dartifact="org.apache.camel.k:camel-k-catalog:$runtime_version:yaml:catalog" -DoutputDirectory=${rootdir}/resources/
+  if [ -f "${rootdir}/resources/camel-k-catalog-${runtime_version}-catalog.yaml" ]; then
+      mv ${rootdir}/resources/camel-k-catalog-"${runtime_version}"-catalog.yaml ${rootdir}/resources/camel-catalog-"${runtime_version}".yaml
+  elif [[ $runtime_version == *"SNAPSHOT" ]]; then
+      # when using SNAPSHOT versions and a snapshot repository the downloaded artifact has a timestamp in place of the SNAPSHOT word
+      # we should replace this timestamp with the SNAPSHOT word
+      only_version=$(echo $runtime_version|sed 's/-SNAPSHOT//g')
+      cat_file=$(ls -lrt ${rootdir}/resources/camel-k-catalog-"${only_version}"*-catalog.yaml|tail -1|sed 's/.*resources\///g')
+      mv ${rootdir}/resources/$cat_file ${rootdir}/resources/camel-catalog-"${runtime_version}".yaml
+  fi
 else
   # TODO: fix this workaround to use the above mvn statement with the staging repository as well
   echo "INFO: extracting a catalog from staging repository $2"
-  wget -q $2/org/apache/camel/k/camel-k-catalog/$1/camel-k-catalog-$1-catalog.yaml -O ${rootdir}/resources/camel-catalog.yaml
+  wget -q $2/org/apache/camel/k/camel-k-catalog/$runtime_version/camel-k-catalog-$runtime_version-catalog.yaml -O ${rootdir}/resources/camel-catalog.yaml
 
   if [ -s ${rootdir}/resources/camel-catalog.yaml ]; then
     # the extracted catalog file is not empty
-    mv ${rootdir}/resources/camel-catalog.yaml ${rootdir}/resources/camel-catalog-$1.yaml
+    mv ${rootdir}/resources/camel-catalog.yaml ${rootdir}/resources/camel-catalog-$runtime_version.yaml
   else
     # the extracted catalog file is empty - some error in staging repository
     echo "WARNING: could not extract catalog from staging repository $2"