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

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

commit 63cbf6c8ea4f2424e2badf262cd8e47e16f67621
Author: Marat Gubaidullin <[email protected]>
AuthorDate: Fri May 10 15:25:16 2024 -0400

    Simplified clone script
---
 docs/WEB_KUBERNETES.md                             |  4 +++
 .../src/main/resources/snippets/docker-build.sh    | 33 +++++++++-------------
 .../main/resources/snippets/kubernetes-build.sh    | 30 ++++++++------------
 .../src/main/resources/snippets/openshift-build.sh | 28 ++++++------------
 4 files changed, 37 insertions(+), 58 deletions(-)

diff --git a/docs/WEB_KUBERNETES.md b/docs/WEB_KUBERNETES.md
index e46f8cec..630dc8fb 100644
--- a/docs/WEB_KUBERNETES.md
+++ b/docs/WEB_KUBERNETES.md
@@ -30,3 +30,7 @@
     kubectl create namespace karavan
     kubectl apply -k .
     ```
+7. Expose karavan service
+    ```
+    minikube service karavan --url --namespace karavan
+    ```
\ No newline at end of file
diff --git a/karavan-app/src/main/resources/snippets/docker-build.sh 
b/karavan-app/src/main/resources/snippets/docker-build.sh
index 319d5383..6f1b96f1 100644
--- a/karavan-app/src/main/resources/snippets/docker-build.sh
+++ b/karavan-app/src/main/resources/snippets/docker-build.sh
@@ -1,27 +1,20 @@
 #!/usr/bin/env bash
 
-if  [[ ${GIT_REPOSITORY} == https* ]] ;
-then
-    replacer=https://${GIT_USERNAME}:${GIT_PASSWORD}@
-    prefix=https://
-    url="${GIT_REPOSITORY/$prefix/$replacer}"
-    git clone --depth 1 --branch ${GIT_BRANCH} $url ${CODE_DIR}
-elif [[ ${GIT_REPOSITORY} == http* ]] ;
-then
-  replacer=http://${GIT_USERNAME}:${GIT_PASSWORD}@
-      prefix=http://
-      url="${GIT_REPOSITORY/$prefix/$replacer}"
-      git clone --depth 1 --branch ${GIT_BRANCH} $url ${CODE_DIR}
-else
-    git clone --depth 1 --branch ${GIT_BRANCH} ${GIT_REPOSITORY} ${CODE_DIR}
-fi
+git config --global credential.helper 'cache --timeout=3600'
+git_credential_fill() 
+    echo url=$GIT_REPOSITORY
+    echo username=$GIT_USERNAME
+    echo password=$GIT_PASSWORD
 
-cd ${CODE_DIR}/${PROJECT_ID}
+git_credential_fill | git credential approve
+git clone --depth 1 --branch $GIT_BRANCH $GIT_REPOSITORY $CODE_DIR
 
-jbang -Dcamel.jbang.version=${CAMEL_VERSION} camel@apache/camel export 
--local-kamelet-dir=${KAMELETS_DIR}
+cd $CODE_DIR/$PROJECT_ID
+
+jbang -Dcamel.jbang.version=$CAMEL_VERSION camel@apache/camel export 
--local-kamelet-dir=$KAMELETS_DIR
 
 mvn package jib:build \
   -Djib.allowInsecureRegistries=true \
-  -Djib.to.image=${IMAGE_REGISTRY}/${IMAGE_GROUP}/${PROJECT_ID}:${TAG} \
-  -Djib.to.auth.username=${IMAGE_REGISTRY_USERNAME} \
-  -Djib.to.auth.password=${IMAGE_REGISTRY_PASSWORD}
+  -Djib.to.image=$IMAGE_REGISTRY/$IMAGE_GROUP/$PROJECT_ID:$TAG \
+  -Djib.to.auth.username=$IMAGE_REGISTRY_USERNAME \
+  -Djib.to.auth.password=$IMAGE_REGISTRY_PASSWORD
diff --git a/karavan-app/src/main/resources/snippets/kubernetes-build.sh 
b/karavan-app/src/main/resources/snippets/kubernetes-build.sh
index 496e9061..70162609 100644
--- a/karavan-app/src/main/resources/snippets/kubernetes-build.sh
+++ b/karavan-app/src/main/resources/snippets/kubernetes-build.sh
@@ -1,27 +1,19 @@
 #!/usr/bin/env bash
 
-if  [[ ${GIT_REPOSITORY} == https* ]] ;
-then
-    replacer=https://${GIT_USERNAME}:${GIT_PASSWORD}@
-    prefix=https://
-    url="${GIT_REPOSITORY/$prefix/$replacer}"
-    git clone --depth 1 --branch ${GIT_BRANCH} $url ${CODE_DIR}
-elif [[ ${GIT_REPOSITORY} == http* ]] ;
-then
-  replacer=http://${GIT_USERNAME}:${GIT_PASSWORD}@
-      prefix=http://
-      url="${GIT_REPOSITORY/$prefix/$replacer}"
-      git clone --depth 1 --branch ${GIT_BRANCH} $url ${CODE_DIR}
-else
-    git clone --depth 1 --branch ${GIT_BRANCH} ${GIT_REPOSITORY} ${CODE_DIR}
-fi
+export NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
 
-cd ${CODE_DIR}/${PROJECT_ID}
+git config --global credential.helper 'cache --timeout=3600'
+git_credential_fill() {
+    echo url=$GIT_REPOSITORY
+    echo username=$GIT_USERNAME
+    echo password=$GIT_PASSWORD
+}
+git_credential_fill | git credential approve
+git clone --depth 1 --branch $GIT_BRANCH $GIT_REPOSITORY $CODE_DIR
 
-jbang -Dcamel.jbang.version=${CAMEL_VERSION} camel@apache/camel export 
--local-kamelet-dir=${KAMELETS_DIR}
+cd $CODE_DIR/$PROJECT_ID
 
-export TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
-export NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
+jbang -Dcamel.jbang.version=$CAMEL_VERSION camel@apache/camel export 
--local-kamelet-dir=$KAMELETS_DIR
 
 mvn package jib:build k8s:resource k8s:apply \
   -Djkube.namespace=${NAMESPACE} \
diff --git a/karavan-app/src/main/resources/snippets/openshift-build.sh 
b/karavan-app/src/main/resources/snippets/openshift-build.sh
index f503fd17..d900457b 100644
--- a/karavan-app/src/main/resources/snippets/openshift-build.sh
+++ b/karavan-app/src/main/resources/snippets/openshift-build.sh
@@ -1,30 +1,20 @@
 #!/usr/bin/env bash
 ENV _JAVA_OPTIONS="-Duser.home=$KARAVAN"
+export NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
 
-if  [[ ${GIT_REPOSITORY} == https* ]] ;
-then
-    replacer=https://${GIT_USERNAME}:${GIT_PASSWORD}@
-    prefix=https://
-    url="${GIT_REPOSITORY/$prefix/$replacer}"
-    git clone --depth 1 --branch ${GIT_BRANCH} $url ${CODE_DIR}
-elif [[ ${GIT_REPOSITORY} == http* ]] ;
-then
-  replacer=http://${GIT_USERNAME}:${GIT_PASSWORD}@
-      prefix=http://
-      url="${GIT_REPOSITORY/$prefix/$replacer}"
-      git clone --depth 1 --branch ${GIT_BRANCH} $url ${CODE_DIR}
-else
-    git clone --depth 1 --branch ${GIT_BRANCH} ${GIT_REPOSITORY} ${CODE_DIR}
-fi
+git config --global credential.helper 'cache --timeout=3600'
+git_credential_fill() {
+    echo url=$GIT_REPOSITORY
+    echo username=$GIT_USERNAME
+    echo password=$GIT_PASSWORD
+}
+git_credential_fill | git credential approve
+git clone --depth 1 --branch $GIT_BRANCH $GIT_REPOSITORY $CODE_DIR
 
 cd ${CODE_DIR}/${PROJECT_ID}
 
 jbang -Dcamel.jbang.version=${CAMEL_VERSION} camel@apache/camel export 
--local-kamelet-dir=${KAMELETS_DIR}
 
-export CERT=$(cat /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt)
-export TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
-export NAMESPACE=$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
-
 sed -i 's/kubernetes-maven-plugin/openshift-maven-plugin/g' pom.xml
 
 mvn package jib:build oc:resource oc:apply \

Reply via email to