You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ts...@apache.org on 2022/12/20 03:21:33 UTC
[camel-k] branch main updated (45c22057a -> 0df10f38d)
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
from 45c22057a fix(ci): pass token via inputs
new fd0250649 (e2e): Extend timeout for uninstall test
new e3958ef5f (e2e): Prepares environment for windows OS support
new b8a2d90bb (e2e): Fixes error in kustomize removal check
new 0b8a1fe6a (e2e): make the use of paths os independent
new 0df10f38d (e2e): replaces deprecated set-output command
The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/actions/e2e-builder/action.yml | 1 -
.github/actions/e2e-common/action.yml | 1 -
.github/actions/e2e-install-native/action.yml | 1 -
.github/actions/e2e-install/action.yml | 1 -
.github/actions/e2e-knative-yaks/action.yml | 1 -
.github/actions/e2e-knative/action.yml | 1 -
.github/actions/e2e-upgrade/action.yml | 3 +-
.github/actions/kamel-build-binary/build-binary.sh | 9 +--
.../kamel-build-bundle/build-bundle-image.sh | 2 +-
.../kamel-build-bundle/build-index-image.sh | 4 +-
.../kamel-config-cluster-custom/connect-cluster.sh | 20 +++---
.../kamel-config-cluster-kind/extract-config.sh | 14 ++--
.../actions/kamel-config-cluster-ocp3/action.yml | 42 ++++++------
.github/actions/kamel-config-cluster/action.yaml | 26 +++++---
.../actions/kamel-config-cluster/output-config.sh | 20 +++---
.../kamel-install-knative/install-knative.sh | 2 +-
.github/actions/kamel-install-yaks/action.yml | 2 +-
.github/actions/kamel-prepare-env/action.yml | 49 +++++++++-----
.github/workflows/builder.yml | 3 -
.github/workflows/common.yml | 3 -
.github/workflows/install.yml | 3 -
.github/workflows/knative.yml | 3 -
.github/workflows/release.yml | 3 -
.github/workflows/upgrade.yml | 3 -
.gitmodules | 1 -
cmd/util/vfs-gen/main.go | 2 +-
e2e/namespace/install/cli/uninstall_test.go | 2 +-
pkg/builder/image.go | 13 ++--
pkg/builder/quarkus.go | 15 ++---
pkg/builder/s2i.go | 5 +-
pkg/builder/spectrum.go | 5 +-
pkg/cmd/config_test.go | 9 +--
pkg/cmd/local/local.go | 30 ++++-----
pkg/cmd/local/workdir.go | 25 +++----
pkg/cmd/modeline.go | 5 +-
pkg/cmd/modeline_test.go | 78 +++++++++++-----------
pkg/cmd/run_support.go | 7 +-
pkg/cmd/source/source.go | 4 +-
pkg/cmd/source/util.go | 8 +++
pkg/cmd/source/util_test.go | 26 +++++++-
pkg/controller/build/build_pod.go | 14 ++--
pkg/controller/build/monitor_routine.go | 6 +-
pkg/install/kamelets.go | 3 +-
pkg/resources/resources_support.go | 5 +-
pkg/trait/container.go | 4 +-
pkg/trait/jvm.go | 8 +--
pkg/trait/jvm_test.go | 16 +++--
pkg/trait/knative_service_test.go | 5 +-
pkg/trait/openapi.go | 7 +-
pkg/trait/trait_test.go | 6 +-
pkg/trait/trait_types.go | 17 ++---
pkg/util/camel/camel_dependencies.go | 3 +-
pkg/util/camel/camel_util.go | 16 ++---
pkg/util/camel/catalog.go | 4 +-
pkg/util/digest/digest.go | 4 +-
pkg/util/docker/docker.go | 10 +--
pkg/util/docker/docker_base.go | 4 +-
pkg/util/jvm/keystore.go | 4 +-
pkg/util/maven/maven_command.go | 14 ++--
pkg/util/util.go | 2 +-
60 files changed, 320 insertions(+), 284 deletions(-)
[camel-k] 01/05: (e2e): Extend timeout for uninstall test
Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit fd0250649f0e59e86aa34014bdcd6ab4eeaa17cc
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Tue Nov 1 14:36:51 2022 +0000
(e2e): Extend timeout for uninstall test
* Wait a little longer to see if kamelets are successfully removed
---
e2e/namespace/install/cli/uninstall_test.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/e2e/namespace/install/cli/uninstall_test.go b/e2e/namespace/install/cli/uninstall_test.go
index 14d0686cc..514b46484 100644
--- a/e2e/namespace/install/cli/uninstall_test.go
+++ b/e2e/namespace/install/cli/uninstall_test.go
@@ -61,7 +61,7 @@ func TestBasicUninstall(t *testing.T) {
Eventually(Configmap(ns, "camel-k-maven-settings")).Should(BeNil())
Eventually(OperatorPod(ns), TestTimeoutMedium).Should(BeNil())
- Eventually(KameletList(ns)).Should(BeEmpty())
+ Eventually(KameletList(ns), TestTimeoutMedium).Should(BeEmpty())
})
}
[camel-k] 05/05: (e2e): replaces deprecated set-output command
Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 0df10f38d01889c0909dfd4c68abe630419f59e4
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Tue Nov 8 17:38:31 2022 +0000
(e2e): replaces deprecated set-output command
* github has deprecated set-output function. Replaces with new syntax
---
.github/actions/e2e-upgrade/action.yml | 2 +-
.github/actions/kamel-build-binary/build-binary.sh | 4 ++--
.../actions/kamel-build-bundle/build-bundle-image.sh | 2 +-
.../actions/kamel-build-bundle/build-index-image.sh | 2 +-
.../kamel-config-cluster-custom/connect-cluster.sh | 20 ++++++++++----------
.../kamel-config-cluster-kind/extract-config.sh | 14 +++++++-------
.github/actions/kamel-config-cluster-ocp3/action.yml | 16 ++++++++--------
.github/actions/kamel-config-cluster/action.yaml | 15 ++++++++-------
.../actions/kamel-config-cluster/output-config.sh | 20 ++++++++++----------
.github/actions/kamel-prepare-env/action.yml | 2 +-
10 files changed, 49 insertions(+), 48 deletions(-)
diff --git a/.github/actions/e2e-upgrade/action.yml b/.github/actions/e2e-upgrade/action.yml
index bacf81189..6e11d6bea 100644
--- a/.github/actions/e2e-upgrade/action.yml
+++ b/.github/actions/e2e-upgrade/action.yml
@@ -75,7 +75,7 @@ runs:
mv /tmp/kamel ${RELEASED_KAMEL_BINARY}
if [ $? == 0 ]; then
echo "Info: Kamel version installed: $(${RELEASED_KAMEL_BINARY} version)"
- echo "::set-output name=released-kamel-binary::${RELEASED_KAMEL_BINARY}"
+ echo "released-kamel-binary=${RELEASED_KAMEL_BINARY}" >> $GITHUB_OUTPUT
else
echo "Error: Failed to install kamel binary ${KAMEL_VERSION}"
exit 1
diff --git a/.github/actions/kamel-build-binary/build-binary.sh b/.github/actions/kamel-build-binary/build-binary.sh
index 0ba377283..cbf64e352 100755
--- a/.github/actions/kamel-build-binary/build-binary.sh
+++ b/.github/actions/kamel-build-binary/build-binary.sh
@@ -107,6 +107,6 @@ echo "Kamel version installed: $(kamel version)"
BUILD_BINARY_LOCAL_IMAGE_NAME="${REGISTRY_PULL_HOST}/${IMAGE_NAMESPACE}/camel-k"
BUILD_BINARY_LOCAL_IMAGE_VERSION="$(make get-version)"
echo "Setting build-binary-local-image-name to ${BUILD_BINARY_LOCAL_IMAGE_NAME}"
-echo "::set-output name=build-binary-local-image-name::${BUILD_BINARY_LOCAL_IMAGE_NAME}"
+echo "build-binary-local-image-name=${BUILD_BINARY_LOCAL_IMAGE_NAME}" >> $GITHUB_OUTPUT
echo "Setting build-binary-local-image-name-version to ${BUILD_BINARY_LOCAL_IMAGE_VERSION}"
-echo "::set-output name=build-binary-local-image-version::${BUILD_BINARY_LOCAL_IMAGE_VERSION}"
+echo "build-binary-local-image-version=${BUILD_BINARY_LOCAL_IMAGE_VERSION}" >> $GITHUB_OUTPUT
diff --git a/.github/actions/kamel-build-bundle/build-bundle-image.sh b/.github/actions/kamel-build-bundle/build-bundle-image.sh
index f6c509cbf..625ac0f2b 100755
--- a/.github/actions/kamel-build-bundle/build-bundle-image.sh
+++ b/.github/actions/kamel-build-bundle/build-bundle-image.sh
@@ -134,4 +134,4 @@ fi
#
PULL_BUNDLE_LOCAL_IMAGE="${REGISTRY_PULL_HOST}/${IMAGE_NAMESPACE}/${BUNDLE_IMAGE_BASE_NAME}:${IMAGE_VERSION}"
echo "Setting build-bundle-local-image to ${PULL_BUNDLE_LOCAL_IMAGE}"
-echo "::set-output name=build-bundle-local-image::${PULL_BUNDLE_LOCAL_IMAGE}"
+echo "build-bundle-local-image=${PULL_BUNDLE_LOCAL_IMAGE}" >> $GITHUB_OUTPUT
diff --git a/.github/actions/kamel-build-bundle/build-index-image.sh b/.github/actions/kamel-build-bundle/build-index-image.sh
index 48d5c2a79..670f46997 100755
--- a/.github/actions/kamel-build-bundle/build-index-image.sh
+++ b/.github/actions/kamel-build-bundle/build-index-image.sh
@@ -259,4 +259,4 @@ docker build . -f catalog.Dockerfile -t ${LOCAL_IIB}
docker push ${LOCAL_IIB}
BUILD_BUNDLE_LOCAL_IMAGE_BUNDLE_INDEX="${REGISTRY_PULL_HOST}/${IMAGE_NAMESPACE}/camel-k-iib:${IMAGE_VERSION}"
echo "Setting build-bundle-image-bundle-index to ${BUILD_BUNDLE_LOCAL_IMAGE_BUNDLE_INDEX}"
-echo "::set-output name=build-bundle-image-bundle-index::${BUILD_BUNDLE_LOCAL_IMAGE_BUNDLE_INDEX}"
+echo "build-bundle-image-bundle-index=${BUILD_BUNDLE_LOCAL_IMAGE_BUNDLE_INDEX}" >> $GITHUB_OUTPUT
diff --git a/.github/actions/kamel-config-cluster-custom/connect-cluster.sh b/.github/actions/kamel-config-cluster-custom/connect-cluster.sh
index 006f32c4e..019dc7173 100755
--- a/.github/actions/kamel-config-cluster-custom/connect-cluster.sh
+++ b/.github/actions/kamel-config-cluster-custom/connect-cluster.sh
@@ -83,25 +83,25 @@ if [ ! $(has_property image-registry-push-host) ]; then
exit 1
fi
-echo "::set-output name=cluster-image-registry-push-host::$(get_property image-registry-push-host)"
-echo "::set-output name=cluster-image-registry-pull-host::$(get_property image-registry-pull-host)"
-echo "::set-output name=cluster-image-registry-insecure::$(get_property image-registry-insecure)"
-echo "::set-output name=cluster-catalog-source-name::$(get_property catalog-source-name)"
-echo "::set-output name=cluster-catalog-source-namespace::$(get_property catalog-source-namespace)"
-echo "::set-output name=cluster-global-operator-namespace::$(get_property global-operator-namespace)"
+echo "cluster-image-registry-push-host=$(get_property image-registry-push-host)" >> $GITHUB_OUTPUT
+echo "cluster-image-registry-pull-host=$(get_property image-registry-pull-host)" >> $GITHUB_OUTPUT
+echo "cluster-image-registry-insecure=$(get_property image-registry-insecure)" >> $GITHUB_OUTPUT
+echo "cluster-catalog-source-name=$(get_property catalog-source-name)" >> $GITHUB_OUTPUT
+echo "cluster-catalog-source-namespace=$(get_property catalog-source-namespace)" >> $GITHUB_OUTPUT
+echo "cluster-global-operator-namespace=$(get_property global-operator-namespace)" >> $GITHUB_OUTPUT
#
# Export the image namespace if defined in the cluster config
#
if [ $(has_property image-namespace) ]; then
- echo "::set-output name=cluster-image-namespace::$(get_property image-namespace)"
+ echo "cluster-image-namespace=$(get_property image-namespace)" >> $GITHUB_OUTPUT
fi
#
# Export the context used for admin and user
#
-echo "::set-output name=cluster-kube-admin-user-ctx::$(get_property kube-admin-user-ctx)"
-echo "::set-output name=cluster-kube-user-ctx::$(get_property kube-user-ctx)"
+echo "cluster-kube-admin-user-ctx=$(get_property kube-admin-user-ctx)" >> $GITHUB_OUTPUT
+echo "cluster-kube-user-ctx=$(get_property kube-user-ctx)" >> $GITHUB_OUTPUT
#
# Keep values private in the log
@@ -114,7 +114,7 @@ echo "::add-mask::$(get_property kube-user-ctx)"
#
# Export the flag for olm capability
#
-echo "::set-output name=cluster-has-olm::$(get_property has-olm)"
+echo "cluster-has-olm=$(get_property has-olm)" >> $GITHUB_OUTPUT
#
# Login to docker if registry is externally secured
diff --git a/.github/actions/kamel-config-cluster-kind/extract-config.sh b/.github/actions/kamel-config-cluster-kind/extract-config.sh
index 69b492465..b23e0dae2 100755
--- a/.github/actions/kamel-config-cluster-kind/extract-config.sh
+++ b/.github/actions/kamel-config-cluster-kind/extract-config.sh
@@ -26,19 +26,19 @@
set -e
# Kind has the same interface for both pushing and pulling images in its registry
-echo "::set-output name=cluster-image-registry-push-host::${KIND_REGISTRY}"
-echo "::set-output name=cluster-image-registry-pull-host::${KIND_REGISTRY}"
-echo "::set-output name=cluster-image-registry-insecure::$(echo true)"
+echo "cluster-image-registry-push-host=${KIND_REGISTRY}" >> $GITHUB_OUTPUT
+echo "cluster-image-registry-pull-host=${KIND_REGISTRY}" >> $GITHUB_OUTPUT
+echo "cluster-image-registry-insecure=$(echo true)" >> $GITHUB_OUTPUT
#
# Export the context used for admin and user
# Since kind has no rbac switched on then these can be the same
#
-echo "::set-output name=cluster-kube-admin-user-ctx::$(kubectl config current-context)"
-echo "::set-output name=cluster-kube-user-ctx::$(kubectl config current-context)"
+echo "cluster-kube-admin-user-ctx=$(kubectl config current-context)" >> $GITHUB_OUTPUT
+echo "cluster-kube-user-ctx=$(kubectl config current-context)" >> $GITHUB_OUTPUT
# Set the image namespace
-echo "::set-output name=cluster-image-namespace::$(echo apache)"
+echo "cluster-image-namespace=$(echo apache)" >> $GITHUB_OUTPUT
#
# cluster-catalog-source-namespace intentionally blank as OLM not routinely installed
@@ -48,4 +48,4 @@ echo "::set-output name=cluster-image-namespace::$(echo apache)"
#
# Export the flag for olm capability
#
-echo "::set-output name=cluster-has-olm::$(echo false)"
+echo "cluster-has-olm=$(echo false)" >> $GITHUB_OUTPUT
diff --git a/.github/actions/kamel-config-cluster-ocp3/action.yml b/.github/actions/kamel-config-cluster-ocp3/action.yml
index aa772b547..f87c87107 100644
--- a/.github/actions/kamel-config-cluster-ocp3/action.yml
+++ b/.github/actions/kamel-config-cluster-ocp3/action.yml
@@ -105,7 +105,7 @@ runs:
oc login -u system:admin
# Export the context used for admin login
- echo "::set-output name=cluster-kube-admin-user-ctx::$(oc config current-context)"
+ echo "cluster-kube-admin-user-ctx=$(oc config current-context)" >> $GITHUB_OUTPUT
# Aggregate pod eviction permission to the default admin role
cat <<EOF | oc apply -f -
@@ -192,18 +192,18 @@ runs:
oc login -u developer
# Export the context used for developer login
- echo "::set-output name=cluster-kube-user-ctx::$(oc config current-context)"
+ echo "cluster-kube-user-ctx=$(oc config current-context)" >> $GITHUB_OUTPUT
- id: extract-config
shell: bash
if: ${{ env.CLUSTER_OCP3_CONFIGURED != 'true' }}
run: |
- echo "::set-output name=cluster-image-registry-pull-host::"
- echo "::set-output name=cluster-image-registry-push-host::"
- echo "::set-output name=cluster-image-registry-insecure::$(echo true)"
- echo "::set-output name=cluster-has-olm::$(echo false)"
- echo "::set-output name=cluster-image-namespace::$(echo apache)"
- echo "::set-output name=cluster-global-operator-namespace::$(echo openshift-operators)"
+ echo "cluster-image-registry-pull-host=" >> $GITHUB_OUTPUT
+ echo "cluster-image-registry-push-host=" >> $GITHUB_OUTPUT
+ echo "cluster-image-registry-insecure=$(echo true)" >> $GITHUB_OUTPUT
+ echo "cluster-has-olm=$(echo false)" >> $GITHUB_OUTPUT
+ echo "cluster-image-namespace=$(echo apache)" >> $GITHUB_OUTPUT
+ echo "cluster-global-operator-namespace=$(echo openshift-operators)" >> $GITHUB_OUTPUT
/* cluster-catalog-source-namespace intentionally blank due to using straight docker */
outputs:
diff --git a/.github/actions/kamel-config-cluster/action.yaml b/.github/actions/kamel-config-cluster/action.yaml
index 3f2b88e52..d73b44e90 100644
--- a/.github/actions/kamel-config-cluster/action.yaml
+++ b/.github/actions/kamel-config-cluster/action.yaml
@@ -43,16 +43,17 @@ runs:
# Have custom cluster-config-data so override cluster-type
#
echo "Have cluster-config-data so setting cluster-type to custom"
- echo "CLUSTER_TYPE=custom" >> $GITHUB_ENV
+ calculated_cluster_type=custom
elif [ -n "${{ inputs.cluster-type }}" ]; then
echo "Cluster-type specified so setting accordingly"
- echo "CLUSTER_TYPE=${{ inputs.cluster-type }}" >> $GITHUB_ENV
+ calculated_cluster_type=${{ inputs.cluster-type }}
else
echo "Info: No cluster configuration supplied. Default to kind."
- echo "CLUSTER_TYPE=kind" >> $GITHUB_ENV
+ calculated_cluster_type=kind
fi
- echo "CLUSTER_TYPE -> ${{ env.CLUSTER_TYPE }}"
+ echo "CLUSTER_TYPE -> ${calculated_cluster_type}"
+ echo "CLUSTER_TYPE=${calculated_cluster_type}" >> $GITHUB_ENV
- id: execute-kind
name: Maybe Execute Kind Cluster
@@ -134,14 +135,14 @@ runs:
if [ "${{ steps.cluster-config.outputs.cluster-has-olm }}" == "true" ]; then
# OLM already installed by default
echo "OLM already available in cluster"
- echo "::set-output name=cluster-has-olm::${{ steps.cluster-config.outputs.cluster-has-olm }}"
+ echo "cluster-has-olm=${{ steps.cluster-config.outputs.cluster-has-olm }}" >> $GITHUB_OUTPUT
exit 0
fi
if [ "${{ inputs.require-olm }}" != "true" ]; then
# OLM not explicitly requested
echo "OLM not explicity required for testing"
- echo "::set-output name=cluster-has-olm::$(echo false)"
+ echo "cluster-has-olm=$(echo false)" >> $GITHUB_OUTPUT
exit 0
fi
@@ -176,7 +177,7 @@ runs:
echo "Return to original kube context"
kubectl config use-context "${ctx}"
- echo "::set-output name=cluster-has-olm::$(echo true)"
+ echo "cluster-has-olm=$(echo true)" >> $GITHUB_OUTPUT
echo "Complete"
diff --git a/.github/actions/kamel-config-cluster/output-config.sh b/.github/actions/kamel-config-cluster/output-config.sh
index 2b196f31d..8b552e56e 100755
--- a/.github/actions/kamel-config-cluster/output-config.sh
+++ b/.github/actions/kamel-config-cluster/output-config.sh
@@ -69,25 +69,25 @@ while getopts ":a:b:c:g:n:o:p:q:s:u:" opt; do
done
shift $((OPTIND-1))
-echo "::set-output name=cluster-image-registry-push-host::${PUSH_HOST}"
-echo "::set-output name=cluster-image-registry-pull-host::${PULL_HOST}"
-echo "::set-output name=cluster-image-registry-insecure::${INSECURE}"
-echo "::set-output name=cluster-kube-admin-user-ctx::${ADMIN_USER_CTX}"
-echo "::set-output name=cluster-kube-user-ctx::${USER_CTX}"
+echo "cluster-image-registry-push-host=${PUSH_HOST}" >> $GITHUB_OUTPUT
+echo "cluster-image-registry-pull-host=${PULL_HOST}" >> $GITHUB_OUTPUT
+echo "cluster-image-registry-insecure=${INSECURE}" >> $GITHUB_OUTPUT
+echo "cluster-kube-admin-user-ctx=${ADMIN_USER_CTX}" >> $GITHUB_OUTPUT
+echo "cluster-kube-user-ctx=${USER_CTX}" >> $GITHUB_OUTPUT
# Set the image namespace
-echo "::set-output name=cluster-image-namespace::${IMAGE_NAMESPACE}"
+echo "cluster-image-namespace=${IMAGE_NAMESPACE}" >> $GITHUB_OUTPUT
# Set the catalog source
-echo "::set-output name=cluster-catalog-source-name::${CATALOG_SOURCE_NAME}"
-echo "::set-output name=cluster-catalog-source-namespace::${CATALOG_SOURCE_NAMESPACE}"
+echo "cluster-catalog-source-name=${CATALOG_SOURCE_NAME}" >> $GITHUB_OUTPUT
+echo "cluster-catalog-source-namespace=${CATALOG_SOURCE_NAMESPACE}" >> $GITHUB_OUTPUT
#
# Export the flag for olm capability
#
-echo "::set-output name=cluster-has-olm::${HAS_OLM}"
+echo "cluster-has-olm=${HAS_OLM}" >> $GITHUB_OUTPUT
#
# Export the flag for testing using global operator
#
-echo "::set-output name=cluster-global-operator-namespace::${GLOBAL_OPERATOR_NAMESPACE}"
+echo "cluster-global-operator-namespace=${GLOBAL_OPERATOR_NAMESPACE}" >> $GITHUB_OUTPUT
diff --git a/.github/actions/kamel-prepare-env/action.yml b/.github/actions/kamel-prepare-env/action.yml
index 120d6fc7b..66cbaf7ef 100644
--- a/.github/actions/kamel-prepare-env/action.yml
+++ b/.github/actions/kamel-prepare-env/action.yml
@@ -95,7 +95,7 @@ runs:
# Install a version of kubectl for generic access to cluster
#
- id: install-kubectl
- uses: azure/setup-kubectl@v1
+ uses: azure/setup-kubectl@v3
if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
with:
version: 'latest'
[camel-k] 03/05: (e2e): Fixes error in kustomize removal check
Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit b8a2d90bb12725d22cf0e9e54489c1337161620b
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Fri Oct 14 14:03:45 2022 +0100
(e2e): Fixes error in kustomize removal check
Stops exit 1 happening if kustomize not available
---
.github/actions/kamel-prepare-env/action.yml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/.github/actions/kamel-prepare-env/action.yml b/.github/actions/kamel-prepare-env/action.yml
index 3fe70aa0a..120d6fc7b 100644
--- a/.github/actions/kamel-prepare-env/action.yml
+++ b/.github/actions/kamel-prepare-env/action.yml
@@ -79,9 +79,12 @@ runs:
if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
run: |
# reinstall kustomize to be always on the same version
- if [ $(which kustomize) == "0" ]; then
+ set +e
+ $(which kustomize &> /dev/null)
+ if [ "$?" == "0" ]; then
${{ env.SUDO }} rm $(which kustomize)
fi
+ set -e
make kustomize
# Add kustomize to PATH
[camel-k] 02/05: (e2e): Prepares environment for windows OS support
Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit e3958ef5facdb47c88d23ab0da2908681b248919
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Mon Jun 20 14:00:11 2022 +0100
(e2e): Prepares environment for windows OS support
* Removes the dotenv action from e2e test suite. No longer required and
does not support windows OS
* Assigns CLUSTER_TYPE in kamel-config-cluster. If not specified then default to
cluster type of kind
* Conditional use of sudo - only for linux
---
.github/actions/e2e-builder/action.yml | 1 -
.github/actions/e2e-common/action.yml | 1 -
.github/actions/e2e-install-native/action.yml | 1 -
.github/actions/e2e-install/action.yml | 1 -
.github/actions/e2e-knative-yaks/action.yml | 1 -
.github/actions/e2e-knative/action.yml | 1 -
.github/actions/e2e-upgrade/action.yml | 1 -
.github/actions/kamel-build-binary/build-binary.sh | 5 ++-
.../kamel-build-bundle/build-index-image.sh | 2 +-
.../actions/kamel-config-cluster-ocp3/action.yml | 26 ++++++-------
.github/actions/kamel-config-cluster/action.yaml | 17 ++++++---
.../kamel-install-knative/install-knative.sh | 2 +-
.github/actions/kamel-install-yaks/action.yml | 2 +-
.github/actions/kamel-prepare-env/action.yml | 44 ++++++++++++++--------
.github/workflows/builder.yml | 3 --
.github/workflows/common.yml | 3 --
.github/workflows/install.yml | 3 --
.github/workflows/knative.yml | 3 --
.github/workflows/release.yml | 3 --
.github/workflows/upgrade.yml | 3 --
.gitmodules | 1 -
21 files changed, 59 insertions(+), 65 deletions(-)
diff --git a/.github/actions/e2e-builder/action.yml b/.github/actions/e2e-builder/action.yml
index 96f0eb6a0..919a8c3f1 100644
--- a/.github/actions/e2e-builder/action.yml
+++ b/.github/actions/e2e-builder/action.yml
@@ -41,7 +41,6 @@ runs:
name: Configure Platform
uses: ./.github/actions/kamel-config-cluster
with:
- cluster-type: ${{ env.TEST_CLUSTER }}
cluster-config-data: ${{ inputs.cluster-config-data }}
cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
diff --git a/.github/actions/e2e-common/action.yml b/.github/actions/e2e-common/action.yml
index 12c6993e5..e75c35149 100644
--- a/.github/actions/e2e-common/action.yml
+++ b/.github/actions/e2e-common/action.yml
@@ -38,7 +38,6 @@ runs:
name: Configure Platform
uses: ./.github/actions/kamel-config-cluster
with:
- cluster-type: ${{ env.TEST_CLUSTER }}
cluster-config-data: ${{ inputs.cluster-config-data }}
cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
#
diff --git a/.github/actions/e2e-install-native/action.yml b/.github/actions/e2e-install-native/action.yml
index 1061ff8e5..37b633462 100644
--- a/.github/actions/e2e-install-native/action.yml
+++ b/.github/actions/e2e-install-native/action.yml
@@ -38,7 +38,6 @@ runs:
name: Configure Platform
uses: ./.github/actions/kamel-config-cluster
with:
- cluster-type: ${{ env.TEST_CLUSTER }}
cluster-config-data: ${{ inputs.cluster-config-data }}
cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
diff --git a/.github/actions/e2e-install/action.yml b/.github/actions/e2e-install/action.yml
index 04fc81da8..68fee7459 100644
--- a/.github/actions/e2e-install/action.yml
+++ b/.github/actions/e2e-install/action.yml
@@ -38,7 +38,6 @@ runs:
name: Configure Platform
uses: ./.github/actions/kamel-config-cluster
with:
- cluster-type: ${{ env.TEST_CLUSTER }}
cluster-config-data: ${{ inputs.cluster-config-data }}
cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
diff --git a/.github/actions/e2e-knative-yaks/action.yml b/.github/actions/e2e-knative-yaks/action.yml
index 68f072e76..3e624da8e 100644
--- a/.github/actions/e2e-knative-yaks/action.yml
+++ b/.github/actions/e2e-knative-yaks/action.yml
@@ -38,7 +38,6 @@ runs:
name: Configure Platform
uses: ./.github/actions/kamel-config-cluster
with:
- cluster-type: ${{ env.TEST_CLUSTER }}
cluster-config-data: ${{ inputs.cluster-config-data }}
cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
diff --git a/.github/actions/e2e-knative/action.yml b/.github/actions/e2e-knative/action.yml
index 4a69be056..f445d51bd 100644
--- a/.github/actions/e2e-knative/action.yml
+++ b/.github/actions/e2e-knative/action.yml
@@ -38,7 +38,6 @@ runs:
name: Configure Platform
uses: ./.github/actions/kamel-config-cluster
with:
- cluster-type: ${{ env.TEST_CLUSTER }}
cluster-config-data: ${{ inputs.cluster-config-data }}
cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
diff --git a/.github/actions/e2e-upgrade/action.yml b/.github/actions/e2e-upgrade/action.yml
index 8da9ee656..bacf81189 100644
--- a/.github/actions/e2e-upgrade/action.yml
+++ b/.github/actions/e2e-upgrade/action.yml
@@ -38,7 +38,6 @@ runs:
name: Configure Cluster
uses: ./.github/actions/kamel-config-cluster
with:
- cluster-type: ${{ env.TEST_CLUSTER }}
cluster-config-data: ${{ inputs.cluster-config-data }}
cluster-kube-config-data: ${{ inputs.cluster-kube-config-data }}
require-olm: true
diff --git a/.github/actions/kamel-build-binary/build-binary.sh b/.github/actions/kamel-build-binary/build-binary.sh
index ed7228af9..0ba377283 100755
--- a/.github/actions/kamel-build-binary/build-binary.sh
+++ b/.github/actions/kamel-build-binary/build-binary.sh
@@ -95,8 +95,9 @@ else
make ${RULES}
fi
-echo "Moving kamel binary to /usr/local/bin"
-sudo mv ./kamel /usr/local/bin
+echo "Moving kamel binary to be visible on PATH"
+
+${SUDO} mv ./kamel /usr/bin
echo "Kamel version installed: $(kamel version)"
#
diff --git a/.github/actions/kamel-build-bundle/build-index-image.sh b/.github/actions/kamel-build-bundle/build-index-image.sh
index e5d1fbbbc..48d5c2a79 100755
--- a/.github/actions/kamel-build-bundle/build-index-image.sh
+++ b/.github/actions/kamel-build-bundle/build-index-image.sh
@@ -155,7 +155,7 @@ if [ "${PULL_REGISTRY}" != "${PUSH_REGISTRY}" ]; then
#
# Only add PULL_HOST if not already added (avoids repeated appended)
#
- sudo sed -i "/${PULL_HOST}/!s/localhost/& ${PULL_HOST} /" /etc/hosts
+ ${SUDO} sed -i "/${PULL_HOST}/!s/localhost/& ${PULL_HOST} /" /etc/hosts
#
# Bring up the registry:2 instance if not already started
diff --git a/.github/actions/kamel-config-cluster-ocp3/action.yml b/.github/actions/kamel-config-cluster-ocp3/action.yml
index 6f26853d6..aa772b547 100644
--- a/.github/actions/kamel-config-cluster-ocp3/action.yml
+++ b/.github/actions/kamel-config-cluster-ocp3/action.yml
@@ -29,26 +29,26 @@ runs:
export OPENSHIFT_COMMIT=0cbc58b
export MAVEN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
- sudo rm -f /etc/resolv.conf
- sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
- sudo sh -c 'echo "DNS=8.8.8.8 4.4.4.4" >> /etc/systemd/resolved.conf'
- sudo service systemd-resolved restart
+ {{ env.SUDO }} rm -f /etc/resolv.conf
+ {{ env.SUDO }} ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
+ {{ env.SUDO }} sh -c 'echo "DNS=8.8.8.8 4.4.4.4" >> /etc/systemd/resolved.conf'
+ {{ env.SUDO }} service systemd-resolved restart
# set docker0 to promiscuous mode
- sudo ip link set docker0 promisc on
+ {{ env.SUDO }} ip link set docker0 promisc on
# Download and install the oc binary
- sudo mount --make-shared /
+ {{ env.SUDO }} mount --make-shared /
- sudo service docker stop
- sudo echo '{"insecure-registries": ["172.30.0.0/16"]}' | sudo tee /etc/docker/daemon.json > /dev/null
- sudo service docker start
+ {{ env.SUDO }} service docker stop
+ {{ env.SUDO }} echo '{"insecure-registries": ["172.30.0.0/16"]}' | {{ env.SUDO }} tee /etc/docker/daemon.json > /dev/null
+ {{ env.SUDO }} service docker start
DOWNLOAD_URL=https://github.com/openshift/origin/releases/download/$OPENSHIFT_VERSION/openshift-origin-client-tools-$OPENSHIFT_VERSION-$OPENSHIFT_COMMIT-linux-64bit.tar.gz
wget -O client.tar.gz ${DOWNLOAD_URL}
tar xvzOf client.tar.gz > oc.bin
- sudo mv oc.bin /usr/local/bin/oc
- sudo chmod 755 /usr/local/bin/oc
+ {{ env.SUDO }} mv oc.bin /usr/bin/oc
+ {{ env.SUDO }} chmod 755 /usr/bin/oc
- id: start-openshift
name: Start OpenShift Cluster
@@ -59,8 +59,8 @@ runs:
IP_ADDR="$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)"
# Setup cluster dir
- sudo mkdir -p /home/runner/lib/oc
- sudo chmod 777 /home/runner/lib/oc
+ {{ env.SUDO }} mkdir -p /home/runner/lib/oc
+ {{ env.SUDO }} chmod 777 /home/runner/lib/oc
cd /home/runner/lib/oc
# Start OpenShift
diff --git a/.github/actions/kamel-config-cluster/action.yaml b/.github/actions/kamel-config-cluster/action.yaml
index f58327aad..3f2b88e52 100644
--- a/.github/actions/kamel-config-cluster/action.yaml
+++ b/.github/actions/kamel-config-cluster/action.yaml
@@ -20,11 +20,10 @@ description: 'Delegates to respective cluster action depending on type of reques
inputs:
cluster-type:
- description: 'The type of cluster required: [kind, ocp3, custom]'
- required: true
- default: 'kind'
+ description: 'The type of cluster required: [kind, ocp3, custom] - optional (see Override Cluster Type step)'
+ required: false
cluster-config-data:
- description: 'Variables for the cluster configuration - required for custom cluster type only'
+ description: 'Variables for the cluster configuration - required for custom cluster type only optional (see Override Cluster Type step)'
required: false
cluster-kube-config-data:
description: 'Base16 encoded kube config - required for custom cluster type only'
@@ -43,12 +42,18 @@ runs:
#
# Have custom cluster-config-data so override cluster-type
#
+ echo "Have cluster-config-data so setting cluster-type to custom"
echo "CLUSTER_TYPE=custom" >> $GITHUB_ENV
- else
- echo "Info: No cluster configuration supplied."
+ elif [ -n "${{ inputs.cluster-type }}" ]; then
+ echo "Cluster-type specified so setting accordingly"
echo "CLUSTER_TYPE=${{ inputs.cluster-type }}" >> $GITHUB_ENV
+ else
+ echo "Info: No cluster configuration supplied. Default to kind."
+ echo "CLUSTER_TYPE=kind" >> $GITHUB_ENV
fi
+ echo "CLUSTER_TYPE -> ${{ env.CLUSTER_TYPE }}"
+
- id: execute-kind
name: Maybe Execute Kind Cluster
uses: ./.github/actions/kamel-config-cluster-kind
diff --git a/.github/actions/kamel-install-knative/install-knative.sh b/.github/actions/kamel-install-knative/install-knative.sh
index 8434afc94..ed529a568 100755
--- a/.github/actions/kamel-install-knative/install-knative.sh
+++ b/.github/actions/kamel-install-knative/install-knative.sh
@@ -26,7 +26,7 @@
set -e
# Prerequisites
-sudo wget https://github.com/mikefarah/yq/releases/download/v4.26.1/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq
+${SUDO} wget https://github.com/mikefarah/yq/releases/download/v4.26.1/yq_linux_amd64 -O /usr/bin/yq && ${SUDO} chmod +x /usr/bin/yq
set +e
diff --git a/.github/actions/kamel-install-yaks/action.yml b/.github/actions/kamel-install-yaks/action.yml
index 39f0f2f0b..7f21c1473 100644
--- a/.github/actions/kamel-install-yaks/action.yml
+++ b/.github/actions/kamel-install-yaks/action.yml
@@ -43,7 +43,7 @@ runs:
curl --fail -L https://github.com/citrusframework/yaks/releases/download/${DOWNLOAD_VERSION}/yaks-${{ inputs.version }}-linux-64bit.tar.gz -o yaks.tar.gz
tar -zxf yaks.tar.gz
- sudo mv yaks /usr/local/bin/
+ ${{ env.SUDO }} mv yaks /usr/bin/
- name: Install YAKS
shell: bash
diff --git a/.github/actions/kamel-prepare-env/action.yml b/.github/actions/kamel-prepare-env/action.yml
index 90e0bc8d5..3fe70aa0a 100644
--- a/.github/actions/kamel-prepare-env/action.yml
+++ b/.github/actions/kamel-prepare-env/action.yml
@@ -21,7 +21,21 @@ description: 'Initialise the test environment with tools. (Will only run once pe
runs:
using: "composite"
steps:
-
+ - name: Set Env Vars
+ shell: bash
+ run: |
+ if [ "$RUNNER_OS" == "Linux" ]; then
+ SUDO=sudo
+ fi
+
+ echo "SUDO=${SUDO}" >> $GITHUB_ENV
+ #
+ # This is a docker action so its pre-builds the image prior to
+ # running it. The building occurs prior to all steps regardless
+ # of where its located to run. Therefore, it must be run prior to
+ # clean-up since that step removes all docker image in order to
+ # claim back as much space as possible.
+ #
- name: Cleanup
shell: bash
if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
@@ -32,21 +46,19 @@ runs:
if [ "$RUNNER_OS" == "Linux" ]; then
echo "Cleaning up resources:"
- sudo swapoff -a
- sudo rm -f /swapfile
- sudo apt clean
- sudo rm -rf /usr/share/dotnet
- sudo rm -rf /opt/ghc
- sudo rm -rf "/usr/local/share/boost"
- sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- df -kh
- docker rmi $(docker image ls -aq) || true # Don't fail if image is not present
- df -kh
- else
- echo "OS $RUNNER_OS is not yet supported"
- exit 1
+ ${{ env.SUDO }} swapoff -a
+ ${{ env.SUDO }} rm -f /swapfile
+ ${{ env.SUDO }} apt clean
+ ${{ env.SUDO }} rm -rf /usr/share/dotnet
+ ${{ env.SUDO }} rm -rf /opt/ghc
+ ${{ env.SUDO }} rm -rf "/usr/local/share/boost"
+ ${{ env.SUDO }} rm -rf "$AGENT_TOOLSDIRECTORY"
fi
+ df -kh
+ docker rmi $(docker image ls -aq) || true # Don't fail if image is not present
+ df -kh
+
echo "Final status:"
df -h
@@ -67,7 +79,9 @@ runs:
if: ${{ env.KAMEL_PREPARE_ENV != 'true' }}
run: |
# reinstall kustomize to be always on the same version
- sudo rm $(which kustomize)
+ if [ $(which kustomize) == "0" ]; then
+ ${{ env.SUDO }} rm $(which kustomize)
+ fi
make kustomize
# Add kustomize to PATH
diff --git a/.github/workflows/builder.yml b/.github/workflows/builder.yml
index 4a00e2a5e..a72cce9cd 100644
--- a/.github/workflows/builder.yml
+++ b/.github/workflows/builder.yml
@@ -17,9 +17,6 @@
name: builder
-env:
- TEST_CLUSTER: kind
-
on:
pull_request:
branches:
diff --git a/.github/workflows/common.yml b/.github/workflows/common.yml
index f9dc3df4b..f1a1d5681 100644
--- a/.github/workflows/common.yml
+++ b/.github/workflows/common.yml
@@ -17,9 +17,6 @@
name: common
-env:
- TEST_CLUSTER: kind
-
on:
pull_request:
branches:
diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml
index ec41b023f..c48d4a045 100644
--- a/.github/workflows/install.yml
+++ b/.github/workflows/install.yml
@@ -17,9 +17,6 @@
name: install
-env:
- TEST_CLUSTER: kind
-
on:
pull_request:
branches:
diff --git a/.github/workflows/knative.yml b/.github/workflows/knative.yml
index 63ab9400d..34cd9e1df 100644
--- a/.github/workflows/knative.yml
+++ b/.github/workflows/knative.yml
@@ -17,9 +17,6 @@
name: knative
-env:
- TEST_CLUSTER: kind
-
on:
pull_request:
branches:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 4631d7a52..cad9d2704 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -17,9 +17,6 @@
# limitations under the License.
name: release
-env:
- TEST_CLUSTER: kind
-
on:
schedule:
- cron: "10 23 * * *"
diff --git a/.github/workflows/upgrade.yml b/.github/workflows/upgrade.yml
index 153a24cbe..802182494 100644
--- a/.github/workflows/upgrade.yml
+++ b/.github/workflows/upgrade.yml
@@ -17,9 +17,6 @@
name: upgrade
-env:
- TEST_CLUSTER: kind
-
on:
pull_request:
branches:
diff --git a/.gitmodules b/.gitmodules
index 5dd35b063..38b2437b4 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -4,4 +4,3 @@
[submodule ".github/actions/changelog"]
path = .github/actions/changelog
url = https://github.com/CharMixer/auto-changelog-action
-
[camel-k] 04/05: (e2e): make the use of paths os independent
Posted by ts...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tsato pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 0b8a1fe6a720830e2f578ed0011ff9a622073f6e
Author: phantomjinx <p....@phantomjinx.co.uk>
AuthorDate: Thu Dec 1 18:42:27 2022 +0000
(e2e): make the use of paths os independent
* Uses FromSlash in tests to ensure comparisons on Windows are not affected
by direction of slashes
* Uses filepath.Base as path.Base fails to return the final name when
running on Windows
* Uses filepath.Join as path.Join, where appropriate, to return os
corrected paths
* Tests / Resources
* Uses filepath.ToSlash to make paths unix-like for consistent storage
and easy comparison
* jvm
* Ensure the classpath default paths are always converted to unix-style
* cmd/source/util.go
* Handles difference between how linux and windows deal with an invalid
path. Since a PathError is returned from the PermissionDenied test as
well then handling this through the error message is the only alternative
---
cmd/util/vfs-gen/main.go | 2 +-
pkg/builder/image.go | 13 +++---
pkg/builder/quarkus.go | 15 +++----
pkg/builder/s2i.go | 5 +--
pkg/builder/spectrum.go | 5 +--
pkg/cmd/config_test.go | 9 ++--
pkg/cmd/local/local.go | 30 ++++++-------
pkg/cmd/local/workdir.go | 25 ++++++-----
pkg/cmd/modeline.go | 5 +--
pkg/cmd/modeline_test.go | 78 ++++++++++++++++-----------------
pkg/cmd/run_support.go | 7 ++-
pkg/cmd/source/source.go | 4 +-
pkg/cmd/source/util.go | 8 ++++
pkg/cmd/source/util_test.go | 26 ++++++++++-
pkg/controller/build/build_pod.go | 14 +++---
pkg/controller/build/monitor_routine.go | 6 +--
pkg/install/kamelets.go | 3 +-
pkg/resources/resources_support.go | 5 ++-
pkg/trait/container.go | 4 +-
pkg/trait/jvm.go | 8 ++--
pkg/trait/jvm_test.go | 16 ++++---
pkg/trait/knative_service_test.go | 5 ++-
pkg/trait/openapi.go | 7 ++-
pkg/trait/trait_test.go | 6 +--
pkg/trait/trait_types.go | 17 +++----
pkg/util/camel/camel_dependencies.go | 3 +-
pkg/util/camel/camel_util.go | 16 +++----
pkg/util/camel/catalog.go | 4 +-
pkg/util/digest/digest.go | 4 +-
pkg/util/docker/docker.go | 10 ++---
pkg/util/docker/docker_base.go | 4 +-
pkg/util/jvm/keystore.go | 4 +-
pkg/util/maven/maven_command.go | 14 +++---
pkg/util/util.go | 2 +-
34 files changed, 211 insertions(+), 173 deletions(-)
diff --git a/cmd/util/vfs-gen/main.go b/cmd/util/vfs-gen/main.go
index 121d3646b..df8d94e01 100644
--- a/cmd/util/vfs-gen/main.go
+++ b/cmd/util/vfs-gen/main.go
@@ -110,7 +110,7 @@ func main() {
//
err = vfsgen.Generate(fs, vfsgen.Options{
Filename: resourceFile,
- PackageName: path.Base(destDir),
+ PackageName: filepath.Base(destDir),
})
if err != nil {
log.Fatalln(err)
diff --git a/pkg/builder/image.go b/pkg/builder/image.go
index a005f42f2..5bd5c46f0 100644
--- a/pkg/builder/image.go
+++ b/pkg/builder/image.go
@@ -21,6 +21,7 @@ import (
"io/ioutil"
"os"
"path"
+ "path/filepath"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
@@ -68,7 +69,7 @@ func nativeImageContext(ctx *builderContext) error {
ctx.Artifacts = []v1.Artifact{
{
ID: runner,
- Location: path.Join(ctx.Path, "maven", "target", runner),
+ Location: filepath.Join(ctx.Path, "maven", "target", runner),
Target: runner,
},
}
@@ -87,7 +88,7 @@ func executableDockerfile(ctx *builderContext) error {
USER nonroot
`)
- err := ioutil.WriteFile(path.Join(ctx.Path, ContextDir, "Dockerfile"), dockerfile, 0o400)
+ err := ioutil.WriteFile(filepath.Join(ctx.Path, ContextDir, "Dockerfile"), dockerfile, 0o400)
if err != nil {
return err
}
@@ -111,7 +112,7 @@ func jvmDockerfile(ctx *builderContext) error {
USER 1000
`)
- err := ioutil.WriteFile(path.Join(ctx.Path, ContextDir, "Dockerfile"), dockerfile, 0o400)
+ err := ioutil.WriteFile(filepath.Join(ctx.Path, ContextDir, "Dockerfile"), dockerfile, 0o400)
if err != nil {
return err
}
@@ -153,7 +154,7 @@ func imageContext(ctx *builderContext, selector artifactsSelector) error {
return err
}
- contextDir := path.Join(ctx.Path, ContextDir)
+ contextDir := filepath.Join(ctx.Path, ContextDir)
err = os.MkdirAll(contextDir, 0o700)
if err != nil {
@@ -161,7 +162,7 @@ func imageContext(ctx *builderContext, selector artifactsSelector) error {
}
for _, entry := range ctx.SelectedArtifacts {
- _, err := util.CopyFile(entry.Location, path.Join(contextDir, entry.Target))
+ _, err := util.CopyFile(entry.Location, filepath.Join(contextDir, entry.Target))
if err != nil {
return err
}
@@ -169,7 +170,7 @@ func imageContext(ctx *builderContext, selector artifactsSelector) error {
for _, entry := range ctx.Resources {
filePath, fileName := path.Split(entry.Target)
- fullPath := path.Join(contextDir, filePath, fileName)
+ fullPath := filepath.Join(contextDir, filePath, fileName)
if err := util.WriteFileWithContent(fullPath, entry.Content); err != nil {
return err
}
diff --git a/pkg/builder/quarkus.go b/pkg/builder/quarkus.go
index 2061a160f..f5ad3ef79 100644
--- a/pkg/builder/quarkus.go
+++ b/pkg/builder/quarkus.go
@@ -21,7 +21,6 @@ import (
"context"
"fmt"
"os"
- "path"
"path/filepath"
"strings"
@@ -146,7 +145,7 @@ func GenerateQuarkusProjectCommon(camelQuarkusVersion string, runtimeVersion str
}
func buildQuarkusRunner(ctx *builderContext) error {
- mc := maven.NewContext(path.Join(ctx.Path, "maven"))
+ mc := maven.NewContext(filepath.Join(ctx.Path, "maven"))
mc.GlobalSettings = ctx.Maven.GlobalSettings
mc.UserSettings = ctx.Maven.UserSettings
mc.SettingsSecurity = ctx.Maven.SettingsSecurity
@@ -155,7 +154,7 @@ func buildQuarkusRunner(ctx *builderContext) error {
if ctx.Maven.TrustStoreName != "" {
mc.ExtraMavenOpts = append(mc.ExtraMavenOpts,
- "-Djavax.net.ssl.trustStore="+path.Join(ctx.Path, ctx.Maven.TrustStoreName),
+ "-Djavax.net.ssl.trustStore="+filepath.Join(ctx.Path, ctx.Maven.TrustStoreName),
"-Djavax.net.ssl.trustStorePassword="+ctx.Maven.TrustStorePass,
)
}
@@ -169,7 +168,7 @@ func buildQuarkusRunner(ctx *builderContext) error {
}
func BuildQuarkusRunnerCommon(ctx context.Context, mc maven.Context, project maven.Project) error {
- resourcesPath := path.Join(mc.Path, "src", "main", "resources")
+ resourcesPath := filepath.Join(mc.Path, "src", "main", "resources")
if err := os.MkdirAll(resourcesPath, os.ModePerm); err != nil {
return errors.Wrap(err, "failure while creating resource folder")
}
@@ -179,7 +178,7 @@ func BuildQuarkusRunnerCommon(ctx context.Context, mc maven.Context, project mav
// may fail the build.
// In the future there should be a way to provide build information from secrets,
// configmap, etc.
- if _, err := os.Create(path.Join(resourcesPath, "application.properties")); err != nil {
+ if _, err := os.Create(filepath.Join(resourcesPath, "application.properties")); err != nil {
return errors.Wrap(err, "failure while creating application.properties")
}
@@ -194,7 +193,7 @@ func BuildQuarkusRunnerCommon(ctx context.Context, mc maven.Context, project mav
}
func computeQuarkusDependencies(ctx *builderContext) error {
- mc := maven.NewContext(path.Join(ctx.Path, "maven"))
+ mc := maven.NewContext(filepath.Join(ctx.Path, "maven"))
mc.GlobalSettings = ctx.Maven.GlobalSettings
mc.UserSettings = ctx.Maven.UserSettings
mc.SettingsSecurity = ctx.Maven.SettingsSecurity
@@ -215,7 +214,7 @@ func ProcessQuarkusTransitiveDependencies(mc maven.Context) ([]v1.Artifact, erro
var artifacts []v1.Artifact
// Quarkus fast-jar format is split into various sub-directories in quarkus-app
- quarkusAppDir := path.Join(mc.Path, "target", "quarkus-app")
+ quarkusAppDir := filepath.Join(mc.Path, "target", "quarkus-app")
// Discover application dependencies from the Quarkus fast-jar directory tree
err := filepath.Walk(quarkusAppDir, func(filePath string, info os.FileInfo, err error) error {
@@ -234,7 +233,7 @@ func ProcessQuarkusTransitiveDependencies(mc maven.Context) ([]v1.Artifact, erro
artifacts = append(artifacts, v1.Artifact{
ID: filepath.Base(fileRelPath),
Location: filePath,
- Target: path.Join(DependenciesDir, fileRelPath),
+ Target: filepath.Join(DependenciesDir, fileRelPath),
Checksum: "sha1:" + sha1,
})
}
diff --git a/pkg/builder/s2i.go b/pkg/builder/s2i.go
index d523e843b..140d3ad95 100644
--- a/pkg/builder/s2i.go
+++ b/pkg/builder/s2i.go
@@ -26,7 +26,6 @@ import (
"fmt"
"io"
"os"
- "path"
"path/filepath"
"strings"
"time"
@@ -145,7 +144,7 @@ func (t *s2iTask) Do(ctx context.Context) v1.BuildStatus {
}
err = util.WithTempDir(t.build.Name+"-s2i-", func(tmpDir string) error {
- archive := path.Join(tmpDir, "archive.tar.gz")
+ archive := filepath.Join(tmpDir, "archive.tar.gz")
contextDir := t.task.ContextDir
if contextDir == "" {
@@ -157,7 +156,7 @@ func (t *s2iTask) Do(ctx context.Context) v1.BuildStatus {
if err != nil {
return err
}
- contextDir = path.Join(pwd, ContextDir)
+ contextDir = filepath.Join(pwd, ContextDir)
}
archiveFile, err := os.Create(archive)
diff --git a/pkg/builder/spectrum.go b/pkg/builder/spectrum.go
index bcfac8e3f..d43f52954 100644
--- a/pkg/builder/spectrum.go
+++ b/pkg/builder/spectrum.go
@@ -23,7 +23,6 @@ import (
"io"
"io/ioutil"
"os"
- "path"
"path/filepath"
"runtime"
"strings"
@@ -67,7 +66,7 @@ func (t *spectrumTask) Do(ctx context.Context) v1.BuildStatus {
if err != nil {
return status.Failed(err)
}
- contextDir = path.Join(pwd, ContextDir)
+ contextDir = filepath.Join(pwd, ContextDir)
}
exists, err := util.DirectoryExists(contextDir)
@@ -132,7 +131,7 @@ func (t *spectrumTask) Do(ctx context.Context) v1.BuildStatus {
}
go readSpectrumLogs(newStdR)
- digest, err := spectrum.Build(options, contextDir+":"+path.Join(DeploymentDir))
+ digest, err := spectrum.Build(options, contextDir+":"+filepath.Join(DeploymentDir)) //nolint
if err != nil {
_ = os.RemoveAll(registryConfigDir)
return status.Failed(err)
diff --git a/pkg/cmd/config_test.go b/pkg/cmd/config_test.go
index 57d5a981e..ca299d775 100644
--- a/pkg/cmd/config_test.go
+++ b/pkg/cmd/config_test.go
@@ -20,6 +20,7 @@ package cmd
import (
"fmt"
"os"
+ "path/filepath"
"strings"
"testing"
@@ -85,14 +86,14 @@ func TestConfigFolderFlagToSub(t *testing.T) {
_, rootCmd, _ := initializeConfigCmdOptions(t, false)
output, err := test.ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "sub")
assert.Nil(t, err)
- assert.True(t, strings.Contains(output, fmt.Sprintf(" .kamel/%s", DefaultConfigLocation)), "The output is unexpected: "+output)
+ assert.True(t, strings.Contains(output, filepath.FromSlash(fmt.Sprintf(".kamel/%s", DefaultConfigLocation))), "The output is unexpected: "+output)
}
func TestConfigFolderFlagToHome(t *testing.T) {
_, rootCmd, _ := initializeConfigCmdOptions(t, false)
output, err := test.ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "home")
assert.Nil(t, err)
- assert.True(t, strings.Contains(output, fmt.Sprintf("/.kamel/%s", DefaultConfigLocation)), "The output is unexpected: "+output)
+ assert.True(t, strings.Contains(output, filepath.FromSlash(fmt.Sprintf(".kamel/%s", DefaultConfigLocation))), "The output is unexpected: "+output)
}
func TestConfigFolderFlagToEnv(t *testing.T) {
@@ -101,7 +102,7 @@ func TestConfigFolderFlagToEnv(t *testing.T) {
_, rootCmd, _ := initializeConfigCmdOptions(t, false)
output, err := test.ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "env")
assert.Nil(t, err)
- assert.True(t, strings.Contains(output, fmt.Sprintf("/foo/bar/%s", DefaultConfigLocation)), "The output is unexpected: "+output)
+ assert.True(t, strings.Contains(output, filepath.FromSlash(fmt.Sprintf("foo/bar/%s", DefaultConfigLocation))), "The output is unexpected: "+output)
}
func TestConfigFolderFlagToEnvWithConfigName(t *testing.T) {
@@ -114,7 +115,7 @@ func TestConfigFolderFlagToEnvWithConfigName(t *testing.T) {
_, rootCmd, _ := initializeConfigCmdOptions(t, false)
output, err := test.ExecuteCommand(rootCmd, cmdConfig, "--list", "--folder", "env")
assert.Nil(t, err)
- assert.True(t, strings.Contains(output, "/foo/bar/config.yaml"), "The output is unexpected: "+output)
+ assert.True(t, strings.Contains(output, filepath.FromSlash("/foo/bar/config.yaml")), "The output is unexpected: "+output)
}
func TestConfigDefaultNamespace(t *testing.T) {
diff --git a/pkg/cmd/local/local.go b/pkg/cmd/local/local.go
index 353e7a1f9..0032e0eee 100644
--- a/pkg/cmd/local/local.go
+++ b/pkg/cmd/local/local.go
@@ -23,7 +23,7 @@ import (
"fmt"
"io/ioutil"
"os"
- "path"
+ "path/filepath"
"sort"
"strings"
@@ -99,7 +99,7 @@ func getTopLevelDependencies(ctx context.Context, catalog *camel.RuntimeCatalog,
sourceSpec := v1.SourceSpec{
DataSpec: v1.DataSpec{
- Name: path.Base(src),
+ Name: filepath.Base(src),
Content: data,
Compression: false,
},
@@ -176,7 +176,7 @@ func getRegularFilesInDir(directory string, dirnameInPath bool) ([]string, error
// Do not include hidden files or sub-directories.
if !file.IsDir() && !strings.HasPrefix(fileName, ".") {
if dirnameInPath {
- dirFiles = append(dirFiles, path.Join(directory, fileName))
+ dirFiles = append(dirFiles, filepath.Join(directory, fileName))
} else {
dirFiles = append(dirFiles, fileName)
}
@@ -373,7 +373,7 @@ func UpdateIntegrationProperties(properties []string, propertyFiles []string, ha
relocatedPropertyFiles := []string{}
dir := GetLocalPropertiesDir()
for _, propertyFile := range propertyFiles {
- relocatedPropertyFile := path.Join(dir, path.Base(propertyFile))
+ relocatedPropertyFile := filepath.Join(dir, filepath.Base(propertyFile))
if _, err := util.CopyFile(propertyFile, relocatedPropertyFile); err != nil {
return nil, err
}
@@ -383,7 +383,7 @@ func UpdateIntegrationProperties(properties []string, propertyFiles []string, ha
if !hasIntegrationDir {
// Output list of properties to property file if any CLI properties were given.
if len(properties) > 0 {
- propertyFilePath := path.Join(dir, "CLI.properties")
+ propertyFilePath := filepath.Join(dir, "CLI.properties")
if err := ioutil.WriteFile(propertyFilePath, []byte(strings.Join(properties, "\n")), 0o600); err != nil {
return nil, err
}
@@ -407,9 +407,9 @@ func updateIntegrationDependencies(dependencies []string) error {
var targetPath string
basePath := util.SubstringFrom(dependency, util.QuarkusDependenciesBaseDirectory)
if basePath != "" {
- targetPath = path.Join(dir, basePath)
+ targetPath = filepath.Join(dir, basePath)
} else {
- targetPath = path.Join(dir, path.Base(dependency))
+ targetPath = filepath.Join(dir, filepath.Base(dependency))
}
if _, err := util.CopyFile(dependency, targetPath); err != nil {
return err
@@ -426,7 +426,7 @@ func updateIntegrationRoutes(routes []string) error {
dir := getLocalRoutesDir()
for _, route := range routes {
- if _, err := util.CopyFile(route, path.Join(dir, path.Base(route))); err != nil {
+ if _, err := util.CopyFile(route, filepath.Join(dir, filepath.Base(route))); err != nil {
return err
}
}
@@ -476,7 +476,7 @@ func CopyIntegrationFilesToDirectory(files []string, directory string) ([]string
// Copy files to new location. Also create the list with relocated files.
relocatedFilesList := []string{}
for _, filePath := range files {
- newFilePath := path.Join(directory, path.Base(filePath))
+ newFilePath := filepath.Join(directory, filepath.Base(filePath))
if _, err := util.CopyFile(filePath, newFilePath); err != nil {
return relocatedFilesList, err
}
@@ -499,8 +499,8 @@ func CopyQuarkusAppFiles(dependenciesDir string, quarkusDir string) error {
}
for _, file := range files {
if strings.HasSuffix(file, ".dat") || strings.HasSuffix(file, "-bytecode.jar") {
- source := path.Join(dependenciesDir, file)
- destination := path.Join(quarkusDir, file)
+ source := filepath.Join(dependenciesDir, file)
+ destination := filepath.Join(quarkusDir, file)
if _, err = util.CopyFile(source, destination); err != nil {
return err
}
@@ -522,8 +522,8 @@ func CopyLibFiles(dependenciesDir string, libDir string) error {
}
for _, dependencyJar := range fileNames {
- source := path.Join(dependenciesDir, dependencyJar)
- destination := path.Join(libDir, dependencyJar)
+ source := filepath.Join(dependenciesDir, dependencyJar)
+ destination := filepath.Join(libDir, dependencyJar)
if _, err = util.CopyFile(source, destination); err != nil {
return err
}
@@ -545,8 +545,8 @@ func CopyAppFile(dependenciesDir string, appDir string) error {
for _, dependencyJar := range fileNames {
if strings.HasPrefix(dependencyJar, "camel-k-integration-") {
- source := path.Join(dependenciesDir, dependencyJar)
- destination := path.Join(appDir, dependencyJar)
+ source := filepath.Join(dependenciesDir, dependencyJar)
+ destination := filepath.Join(appDir, dependencyJar)
if _, err = util.CopyFile(source, destination); err != nil {
return err
}
diff --git a/pkg/cmd/local/workdir.go b/pkg/cmd/local/workdir.go
index 3ab67f5ba..1a7eecc6b 100644
--- a/pkg/cmd/local/workdir.go
+++ b/pkg/cmd/local/workdir.go
@@ -21,6 +21,7 @@ import (
"io/ioutil"
"os"
"path"
+ "path/filepath"
"strings"
"github.com/apache/camel-k/pkg/util"
@@ -50,7 +51,7 @@ func DeleteMavenWorkingDirectory() error {
// getLocalDependenciesDir returns <mavenWorkingDirectory>/dependencies.
func getLocalDependenciesDir() string {
- return path.Join(MavenWorkingDirectory, util.DefaultDependenciesDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.DefaultDependenciesDirectoryName)
}
func createLocalDependenciesDirectory() error {
@@ -75,7 +76,7 @@ func createLocalDependenciesDirectory() error {
// GetLocalPropertiesDir returns <mavenWorkingDirectory>/properties.
func GetLocalPropertiesDir() string {
- return path.Join(MavenWorkingDirectory, util.DefaultPropertiesDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.DefaultPropertiesDirectoryName)
}
func CreateLocalPropertiesDirectory() error {
@@ -101,7 +102,7 @@ func CreateLocalPropertiesDirectory() error {
// getLocalRoutesDir returns <mavenWorkingDirectory>/routes.
func getLocalRoutesDir() string {
- return path.Join(MavenWorkingDirectory, util.DefaultRoutesDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.DefaultRoutesDirectoryName)
}
func createLocalRoutesDirectory() error {
@@ -126,7 +127,7 @@ func createLocalRoutesDirectory() error {
// getLocalQuarkusDir returns <mavenWorkingDirectory>/quarkus.
func getLocalQuarkusDir() string {
- return path.Join(MavenWorkingDirectory, util.CustomQuarkusDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.CustomQuarkusDirectoryName)
}
func createLocalQuarkusDirectory() error {
@@ -151,7 +152,7 @@ func createLocalQuarkusDirectory() error {
// getLocalAppDir returns <mavenWorkingDirectory>/app.
func getLocalAppDir() string {
- return path.Join(MavenWorkingDirectory, util.CustomAppDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.CustomAppDirectoryName)
}
func createLocalAppDirectory() error {
@@ -176,7 +177,7 @@ func createLocalAppDirectory() error {
// getLocalLibDir returns <mavenWorkingDirectory>/lib/main.
func getLocalLibDir() string {
- return path.Join(MavenWorkingDirectory, util.CustomLibDirectoryName)
+ return filepath.Join(MavenWorkingDirectory, util.CustomLibDirectoryName)
}
func createLocalLibDirectory() error {
@@ -200,30 +201,30 @@ func createLocalLibDirectory() error {
}
func GetCustomDependenciesDir(dir string) string {
- return path.Join(dir, util.DefaultDependenciesDirectoryName)
+ return filepath.Join(dir, util.DefaultDependenciesDirectoryName)
}
func GetCustomPropertiesDir(dir string) string {
- return path.Join(dir, util.DefaultPropertiesDirectoryName)
+ return filepath.Join(dir, util.DefaultPropertiesDirectoryName)
}
func GetCustomRoutesDir(dir string) string {
- return path.Join(dir, util.DefaultRoutesDirectoryName)
+ return filepath.Join(dir, util.DefaultRoutesDirectoryName)
}
func GetCustomQuarkusDir(dir string) string {
parentDir := path.Dir(strings.TrimSuffix(dir, "/"))
- return path.Join(parentDir, util.CustomQuarkusDirectoryName)
+ return filepath.Join(parentDir, util.CustomQuarkusDirectoryName)
}
func GetCustomLibDir(dir string) string {
parentDir := path.Dir(strings.TrimSuffix(dir, "/"))
- return path.Join(parentDir, util.CustomLibDirectoryName)
+ return filepath.Join(parentDir, util.CustomLibDirectoryName)
}
func GetCustomAppDir(dir string) string {
parentDir := path.Dir(strings.TrimSuffix(dir, "/"))
- return path.Join(parentDir, "app")
+ return filepath.Join(parentDir, "app")
}
func DeleteLocalIntegrationDirs(dir string) error {
diff --git a/pkg/cmd/modeline.go b/pkg/cmd/modeline.go
index 4ef02caa2..5a7f2a698 100644
--- a/pkg/cmd/modeline.go
+++ b/pkg/cmd/modeline.go
@@ -20,7 +20,6 @@ package cmd
import (
"context"
"fmt"
- "path"
"path/filepath"
"strings"
@@ -231,7 +230,7 @@ func extractModelineOptionsFromSource(resolvedSource source.Source) ([]modeline.
baseDir := filepath.Dir(resolvedSource.Origin)
refPath := o.Value
if !filepath.IsAbs(refPath) {
- full := path.Join(baseDir, refPath)
+ full := filepath.Join(baseDir, refPath)
o.Value = full
ops[i] = o
}
@@ -239,7 +238,7 @@ func extractModelineOptionsFromSource(resolvedSource source.Source) ([]modeline.
baseDir := filepath.Dir(resolvedSource.Origin)
refPath := getRefPathOrProperty(o.Value)
if !filepath.IsAbs(refPath) {
- full := getFullPathOrProperty(o.Value, path.Join(baseDir, refPath))
+ full := getFullPathOrProperty(o.Value, filepath.Join(baseDir, refPath))
o.Value = full
ops[i] = o
}
diff --git a/pkg/cmd/modeline_test.go b/pkg/cmd/modeline_test.go
index 854bd52a9..f810380e9 100644
--- a/pkg/cmd/modeline_test.go
+++ b/pkg/cmd/modeline_test.go
@@ -22,7 +22,7 @@ import (
"fmt"
"io/ioutil"
"os"
- "path"
+ "path/filepath"
"testing"
"github.com/apache/camel-k/pkg/util"
@@ -35,7 +35,7 @@ func TestModelineRunSimple(t *testing.T) {
file := `
// camel-k: dependency=mvn:org.my:lib:1.0
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -53,7 +53,7 @@ func TestModelineRunSimple(t *testing.T) {
func TestModelineRunHelp(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
// no file created
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
cmd, flags, err := NewKamelWithModelineCommand(context.TODO(), []string{"kamel", "run", fileName, "--help"})
assert.NoError(t, err)
@@ -71,7 +71,7 @@ func TestModelineRunChain(t *testing.T) {
file := `
// camel-k: dependency=mvn:org.my:lib:2.0
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -91,14 +91,14 @@ func TestModelineRunMultipleFiles(t *testing.T) {
file := `
// camel-k: dependency=mvn:org.my:lib1:3.0
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
file2 := `
// camel-k: dependency=mvn:org.my:lib2:3.0
`
- fileName2 := path.Join(dir, "ext.groovy")
+ fileName2 := filepath.Join(dir, "ext.groovy")
err = ioutil.WriteFile(fileName2, []byte(file2), 0o400)
assert.NoError(t, err)
@@ -115,14 +115,14 @@ func TestModelineRunMultipleFiles(t *testing.T) {
func TestModelineRunProperty(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: property=my-prop=my-val
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -139,7 +139,7 @@ func TestModelineRunProperty(t *testing.T) {
func TestModelineRunDuplicatedProperties(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
@@ -148,7 +148,7 @@ func TestModelineRunDuplicatedProperties(t *testing.T) {
// camel-k: property=prop2=false
// camel-k: property=foo=bar
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -165,7 +165,7 @@ func TestModelineRunDuplicatedProperties(t *testing.T) {
func TestModelineRunDuplicatedBuildProperties(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
@@ -174,7 +174,7 @@ func TestModelineRunDuplicatedBuildProperties(t *testing.T) {
// camel-k: build-property=prop2=false
// camel-k: build-property=foo=bar
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -197,21 +197,21 @@ func TestModelineRunDuplicatedBuildProperties(t *testing.T) {
func TestModelineRunPropertyFiles(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: property=file:application.properties
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
propFile := `
a=b
`
- propFileName := path.Join(subDir, "application.properties")
+ propFileName := filepath.Join(subDir, "application.properties")
err = ioutil.WriteFile(propFileName, []byte(propFile), 0o400)
assert.NoError(t, err)
@@ -228,14 +228,14 @@ func TestModelineRunPropertyFiles(t *testing.T) {
func TestModelineRunBuildProperty(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: build-property=my-build-prop=my-val
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -252,21 +252,21 @@ func TestModelineRunBuildProperty(t *testing.T) {
func TestModelineRunBuildPropertyFiles(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: build-property=file:application.properties
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
propFile := `
a=b
`
- propFileName := path.Join(subDir, "application.properties")
+ propFileName := filepath.Join(subDir, "application.properties")
err = ioutil.WriteFile(propFileName, []byte(propFile), 0o400)
assert.NoError(t, err)
@@ -283,7 +283,7 @@ func TestModelineRunBuildPropertyFiles(t *testing.T) {
func TestModelineRunDuplicateTraits(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
@@ -292,7 +292,7 @@ func TestModelineRunDuplicateTraits(t *testing.T) {
// camel-k: trait=trait2=false
// camel-k: trait=foo=bar
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -309,14 +309,14 @@ func TestModelineRunDuplicateTraits(t *testing.T) {
func TestModelineRunConfigConfigmap(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: config=configmap:my-cm
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -333,14 +333,14 @@ func TestModelineRunConfigConfigmap(t *testing.T) {
func TestModelineRunConfigSecret(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: config=secret:my-secret
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -357,21 +357,21 @@ func TestModelineRunConfigSecret(t *testing.T) {
func TestModelineRunConfigFile(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: config=file:application.properties
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
propFile := `
a=b
`
- propFileName := path.Join(subDir, "application.properties")
+ propFileName := filepath.Join(subDir, "application.properties")
err = ioutil.WriteFile(propFileName, []byte(propFile), 0o400)
assert.NoError(t, err)
@@ -388,14 +388,14 @@ func TestModelineRunConfigFile(t *testing.T) {
func TestModelineRunResourceConfigmap(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: resource=configmap:my-cm
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -412,14 +412,14 @@ func TestModelineRunResourceConfigmap(t *testing.T) {
func TestModelineRunResourceSecret(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: resource=secret:my-secret
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -436,21 +436,21 @@ func TestModelineRunResourceSecret(t *testing.T) {
func TestModelineRunResourceFile(t *testing.T) {
err := util.WithTempDir("camel-k-test-", func(dir string) error {
- subDir := path.Join(dir, "sub")
+ subDir := filepath.Join(dir, "sub")
err := os.Mkdir(subDir, 0o700)
assert.NoError(t, err)
file := `
// camel-k: resource=file:application.properties
`
- fileName := path.Join(subDir, "simple.groovy")
+ fileName := filepath.Join(subDir, "simple.groovy")
err = ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
propFile := `
a=b
`
- propFileName := path.Join(subDir, "application.properties")
+ propFileName := filepath.Join(subDir, "application.properties")
err = ioutil.WriteFile(propFileName, []byte(propFile), 0o400)
assert.NoError(t, err)
@@ -471,7 +471,7 @@ func TestModelineInspectSimple(t *testing.T) {
file := `
// camel-k: dependency=mvn:org.my:lib:1.0
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -493,7 +493,7 @@ func TestModelineInspectMultipleDeps(t *testing.T) {
// camel-k: dependency=mvn:org.my:lib:1.0
// camel-k: dependency=camel-k:camel-dep
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
@@ -514,7 +514,7 @@ func TestModelineQuotedPodTemplate(t *testing.T) {
file := `
// camel-k: pod-template='{ "containers": [], "securityContext": { "supplementalGroups": [ 553 ] }, "volumes": [] } }'
`
- fileName := path.Join(dir, "simple.groovy")
+ fileName := filepath.Join(dir, "simple.groovy")
err := ioutil.WriteFile(fileName, []byte(file), 0o400)
assert.NoError(t, err)
diff --git a/pkg/cmd/run_support.go b/pkg/cmd/run_support.go
index e929a67f3..812c7d326 100644
--- a/pkg/cmd/run_support.go
+++ b/pkg/cmd/run_support.go
@@ -24,7 +24,6 @@ import (
"net/http"
"net/url"
"os"
- "path"
"path/filepath"
"reflect"
"strings"
@@ -74,7 +73,7 @@ func parseConfigAndGenCm(ctx context.Context, cmd *cobra.Command, c client.Clien
if config.ContentType() == resource.ContentTypeText {
resourceType = v1.ResourceTypeConfig
}
- resourceSpec, err := binaryOrTextResource(path.Base(config.Name()), rawData, contentType, enableCompression, resourceType, config.DestinationPath())
+ resourceSpec, err := binaryOrTextResource(filepath.Base(config.Name()), rawData, contentType, enableCompression, resourceType, config.DestinationPath())
if err != nil {
return nil, err
}
@@ -189,9 +188,9 @@ func downloadDependency(ctx context.Context, url url.URL) (string, error) {
return "", err
}
defer res.Body.Close()
- base := path.Base(url.Path)
+ base := filepath.Base(url.Path)
if base == "." || base == "/" || filepath.Ext(base) == "" {
- base = path.Base(url.String())
+ base = filepath.Base(url.String())
if base == "." || base == "/" {
base = "tmp"
}
diff --git a/pkg/cmd/source/source.go b/pkg/cmd/source/source.go
index 4daeb89c2..3f04d0061 100644
--- a/pkg/cmd/source/source.go
+++ b/pkg/cmd/source/source.go
@@ -23,7 +23,7 @@ import (
"net/http"
"net/url"
"os"
- "path"
+ "path/filepath"
"strings"
"github.com/apache/camel-k/pkg/util"
@@ -53,7 +53,7 @@ func newSource(location string, compress bool, loadContent func() ([]byte, error
locPath = location
}
src := Source{
- Name: path.Base(locPath),
+ Name: filepath.Base(locPath),
Origin: location,
Location: location,
Compress: compress,
diff --git a/pkg/cmd/source/util.go b/pkg/cmd/source/util.go
index 3e2b6a787..3ad2dc9ed 100644
--- a/pkg/cmd/source/util.go
+++ b/pkg/cmd/source/util.go
@@ -19,7 +19,9 @@ package source
import (
"fmt"
+ "io/fs"
"os"
+ "runtime"
"strings"
"github.com/pkg/errors"
@@ -43,6 +45,12 @@ func IsLocalAndFileExists(uri string) (bool, error) {
if os.IsNotExist(err) {
return false, nil
}
+
+ if _, ok := err.(*fs.PathError); ok && runtime.GOOS == "windows" { // nolint
+ // Windows returns a PathError rather than NotExist is path is invalid
+ return false, nil
+ }
+
// If it is a different error (ie, permission denied) we should report it back
return false, errors.Wrap(err, fmt.Sprintf("file system error while looking for %s", uri))
}
diff --git a/pkg/cmd/source/util_test.go b/pkg/cmd/source/util_test.go
index 53de90c9b..586743d2b 100644
--- a/pkg/cmd/source/util_test.go
+++ b/pkg/cmd/source/util_test.go
@@ -21,6 +21,9 @@ limitations under the License.
package source
import (
+ "os"
+ "path/filepath"
+ "runtime"
"testing"
"github.com/stretchr/testify/assert"
@@ -37,8 +40,29 @@ func TestCorrectFileValuesButNotFound(t *testing.T) {
assert.False(t, value2)
}
+func isWindows() bool {
+ return runtime.GOOS == "windows"
+}
+
func TestPermissionDenied(t *testing.T) {
- value, err := IsLocalAndFileExists("/root/test")
+ dir := "/tmp/filedir"
+
+ if isWindows() {
+ t.Skip("Test not reliably producing a result on a windows OS")
+ }
+
+ err := os.Mkdir(dir, 0700)
+ assert.Nil(t, err)
+
+ filename := filepath.Join(dir, "file.txt")
+ f, err := os.Create(filename)
+ assert.Nil(t, err)
+ defer f.Close()
+
+ err = os.Chmod(dir, 0000)
+ assert.Nil(t, err)
+
+ value, err := IsLocalAndFileExists(filename)
// must not panic because a permission error
assert.NotNil(t, err)
assert.False(t, value)
diff --git a/pkg/controller/build/build_pod.go b/pkg/controller/build/build_pod.go
index 42385d95c..257405928 100644
--- a/pkg/controller/build/build_pod.go
+++ b/pkg/controller/build/build_pod.go
@@ -21,7 +21,7 @@ import (
"context"
"fmt"
"os"
- "path"
+ "path/filepath"
"strconv"
"strings"
@@ -230,7 +230,7 @@ func addBuildTaskToPod(build *v1.Build, taskName string, pod *corev1.Pod) {
"--task-name",
taskName,
},
- WorkingDir: path.Join(builderDir, build.Name),
+ WorkingDir: filepath.Join(builderDir, build.Name),
Env: proxyFromEnvironment(),
}
@@ -336,7 +336,7 @@ func addBuildahTaskToPod(ctx context.Context, c ctrl.Reader, build *v1.Build, ta
Command: []string{"/bin/sh", "-c"},
Args: []string{strings.Join(args, " && ")},
Env: env,
- WorkingDir: path.Join(builderDir, build.Name, builder.ContextDir),
+ WorkingDir: filepath.Join(builderDir, build.Name, builder.ContextDir),
VolumeMounts: volumeMounts,
}
@@ -355,7 +355,7 @@ func addKanikoTaskToPod(ctx context.Context, c ctrl.Reader, build *v1.Build, tas
args := []string{
"--dockerfile=Dockerfile",
- "--context=" + path.Join(builderDir, build.Name, builder.ContextDir),
+ "--context=" + filepath.Join(builderDir, build.Name, builder.ContextDir),
"--destination=" + task.Image,
"--cache=" + strconv.FormatBool(cache),
"--cache-dir=" + builder.KanikoCacheDir,
@@ -452,7 +452,7 @@ func addKanikoTaskToPod(ctx context.Context, c ctrl.Reader, build *v1.Build, tas
ImagePullPolicy: corev1.PullIfNotPresent,
Args: args,
Env: env,
- WorkingDir: path.Join(builderDir, build.Name, builder.ContextDir),
+ WorkingDir: filepath.Join(builderDir, build.Name, builder.ContextDir),
VolumeMounts: volumeMounts,
}
@@ -469,7 +469,7 @@ func addContainerToPod(build *v1.Build, container corev1.Container, pod *corev1.
if hasBuilderVolume(pod) {
container.VolumeMounts = append(container.VolumeMounts, corev1.VolumeMount{
Name: builderVolume,
- MountPath: path.Join(builderDir, build.Name),
+ MountPath: filepath.Join(builderDir, build.Name),
})
}
@@ -563,7 +563,7 @@ func addRegistrySecret(name string, secret registrySecret, volumes *[]corev1.Vol
if secret.refEnv != "" {
*env = append(*env, corev1.EnvVar{
Name: secret.refEnv,
- Value: path.Join(secret.mountPath, secret.destination),
+ Value: filepath.Join(secret.mountPath, secret.destination),
})
}
}
diff --git a/pkg/controller/build/monitor_routine.go b/pkg/controller/build/monitor_routine.go
index 42f5a7902..2820c8a70 100644
--- a/pkg/controller/build/monitor_routine.go
+++ b/pkg/controller/build/monitor_routine.go
@@ -23,7 +23,7 @@ import (
"fmt"
"io/ioutil"
"os"
- "path"
+ "path/filepath"
"sync"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -137,13 +137,13 @@ tasks:
status.Failed(fmt.Errorf("cannot determine context directory for task %s", t.Name))
break tasks
}
- t.ContextDir = path.Join(buildDir, builder.ContextDir)
+ t.ContextDir = filepath.Join(buildDir, builder.ContextDir)
} else if t := task.S2i; t != nil && t.ContextDir == "" {
if buildDir == "" {
status.Failed(fmt.Errorf("cannot determine context directory for task %s", t.Name))
break tasks
}
- t.ContextDir = path.Join(buildDir, builder.ContextDir)
+ t.ContextDir = filepath.Join(buildDir, builder.ContextDir)
}
// Execute the task
diff --git a/pkg/install/kamelets.go b/pkg/install/kamelets.go
index 569453734..4f8102a85 100644
--- a/pkg/install/kamelets.go
+++ b/pkg/install/kamelets.go
@@ -25,7 +25,6 @@ import (
"io/fs"
"net/http"
"os"
- "path"
"path/filepath"
"strings"
"sync"
@@ -90,7 +89,7 @@ func KameletCatalog(ctx context.Context, c client.Client, namespace string) erro
}
// We may want to throttle the creation of Go routines if the number of bundled Kamelets increases.
g.Go(func() error {
- kamelet, err := loadKamelet(path.Join(kameletDir, f.Name()), namespace)
+ kamelet, err := loadKamelet(filepath.Join(kameletDir, f.Name()), namespace)
if err != nil {
return err
}
diff --git a/pkg/resources/resources_support.go b/pkg/resources/resources_support.go
index 28fa9ab4f..85774a3a0 100644
--- a/pkg/resources/resources_support.go
+++ b/pkg/resources/resources_support.go
@@ -22,6 +22,7 @@ import (
"io/ioutil"
"net/http"
"os"
+ "path"
"path/filepath"
"strings"
"text/template"
@@ -43,6 +44,7 @@ func ResourceAsString(name string) (string, error) {
// Resource provides an easy way to access to embedded assets.
func Resource(name string) ([]byte, error) {
name = strings.Trim(name, " ")
+ name = filepath.ToSlash(name)
if !strings.HasPrefix(name, "/") {
name = "/" + name
}
@@ -115,6 +117,7 @@ func WithPrefix(pathPrefix string) ([]string, error) {
// Resources lists all file names in the given path (starts with '/').
func Resources(dirName string) ([]string, error) {
+ dirName = filepath.ToSlash(dirName)
dir, err := openAsset(dirName)
if err != nil {
if os.IsNotExist(err) {
@@ -142,7 +145,7 @@ func Resources(dirName string) ([]string, error) {
var res []string
for _, f := range files {
if !f.IsDir() {
- res = append(res, filepath.Join(dirName, f.Name()))
+ res = append(res, path.Join(dirName, f.Name()))
}
}
diff --git a/pkg/trait/container.go b/pkg/trait/container.go
index bf2205473..b42f1e2df 100644
--- a/pkg/trait/container.go
+++ b/pkg/trait/container.go
@@ -19,7 +19,7 @@ package trait
import (
"fmt"
- "path"
+ "path/filepath"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
@@ -162,7 +162,7 @@ func (t *containerTrait) configureContainer(e *Environment) error {
}
envvar.SetVal(&container.Env, digest.IntegrationDigestEnvVar, e.Integration.Status.Digest)
- envvar.SetVal(&container.Env, "CAMEL_K_CONF", path.Join(camel.BasePath, "application.properties"))
+ envvar.SetVal(&container.Env, "CAMEL_K_CONF", filepath.Join(camel.BasePath, "application.properties"))
envvar.SetVal(&container.Env, "CAMEL_K_CONF_D", camel.ConfDPath)
e.addSourcesProperties()
diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go
index 05609ff9e..60a4fbac2 100644
--- a/pkg/trait/jvm.go
+++ b/pkg/trait/jvm.go
@@ -20,7 +20,7 @@ package trait
import (
"fmt"
"net/url"
- "path"
+ "path/filepath"
"sort"
"strings"
@@ -102,8 +102,8 @@ func (t *jvmTrait) Apply(e *Environment) error {
classpath := strset.New()
classpath.Add("./resources")
- classpath.Add(camel.ConfigResourcesMountPath)
- classpath.Add(camel.ResourcesDefaultMountPath)
+ classpath.Add(filepath.ToSlash(camel.ConfigResourcesMountPath))
+ classpath.Add(filepath.ToSlash(camel.ResourcesDefaultMountPath))
if t.Classpath != "" {
classpath.Add(strings.Split(t.Classpath, ":")...)
}
@@ -116,7 +116,7 @@ func (t *jvmTrait) Apply(e *Environment) error {
// In case of an external created kit, we do not have any information about
// the classpath, so we assume the all jars in /deployments/dependencies/ have
// to be taken into account.
- dependencies := path.Join(builder.DeploymentDir, builder.DependenciesDir)
+ dependencies := filepath.Join(builder.DeploymentDir, builder.DependenciesDir)
classpath.Add(
dependencies+"/*",
dependencies+"/app/*",
diff --git a/pkg/trait/jvm_test.go b/pkg/trait/jvm_test.go
index 8fe4b772f..ad2d750f2 100644
--- a/pkg/trait/jvm_test.go
+++ b/pkg/trait/jvm_test.go
@@ -19,6 +19,7 @@ package trait
import (
"fmt"
+ "path/filepath"
"sort"
"strings"
"testing"
@@ -40,6 +41,11 @@ import (
"github.com/apache/camel-k/pkg/util/test"
)
+var (
+ crMountPath = filepath.ToSlash(camel.ConfigResourcesMountPath)
+ rdMountPath = filepath.ToSlash(camel.ResourcesDefaultMountPath)
+)
+
func TestConfigureJvmTraitInRightPhasesDoesSucceed(t *testing.T) {
trait, environment := createNominalJvmTest(v1.IntegrationKitTypePlatform)
@@ -103,12 +109,12 @@ func TestApplyJvmTraitWithDeploymentResource(t *testing.T) {
assert.Nil(t, err)
- cp := strset.New("./resources", camel.ConfigResourcesMountPath, camel.ResourcesDefaultMountPath, "/mount/path").List()
+ cp := strset.New("./resources", crMountPath, rdMountPath, "/mount/path").List()
sort.Strings(cp)
assert.Equal(t, []string{
"-cp",
- fmt.Sprintf("./resources:%s:%s:/mount/path", camel.ConfigResourcesMountPath, camel.ResourcesDefaultMountPath),
+ fmt.Sprintf("./resources:%s:%s:/mount/path", crMountPath, rdMountPath),
"io.quarkus.bootstrap.runner.QuarkusEntryPoint",
}, d.Spec.Template.Spec.Containers[0].Args)
}
@@ -135,12 +141,12 @@ func TestApplyJvmTraitWithKNativeResource(t *testing.T) {
assert.Nil(t, err)
- cp := strset.New("./resources", camel.ConfigResourcesMountPath, camel.ResourcesDefaultMountPath, "/mount/path").List()
+ cp := strset.New("./resources", crMountPath, rdMountPath, "/mount/path").List()
sort.Strings(cp)
assert.Equal(t, []string{
"-cp",
- fmt.Sprintf("./resources:%s:%s:/mount/path", camel.ConfigResourcesMountPath, camel.ResourcesDefaultMountPath),
+ fmt.Sprintf("./resources:%s:%s:/mount/path", crMountPath, rdMountPath),
"io.quarkus.bootstrap.runner.QuarkusEntryPoint",
}, s.Spec.Template.Spec.Containers[0].Args)
}
@@ -244,7 +250,7 @@ func TestApplyJvmTraitWithClasspath(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, []string{
"-cp",
- fmt.Sprintf("./resources:%s:%s:/mount/path:%s:%s", camel.ConfigResourcesMountPath, camel.ResourcesDefaultMountPath,
+ fmt.Sprintf("./resources:%s:%s:/mount/path:%s:%s", crMountPath, rdMountPath,
"/path/to/another/dep.jar", "/path/to/my-dep.jar"),
"io.quarkus.bootstrap.runner.QuarkusEntryPoint",
}, d.Spec.Template.Spec.Containers[0].Args)
diff --git a/pkg/trait/knative_service_test.go b/pkg/trait/knative_service_test.go
index d2f42e0aa..7f59faf74 100644
--- a/pkg/trait/knative_service_test.go
+++ b/pkg/trait/knative_service_test.go
@@ -18,6 +18,7 @@ limitations under the License.
package trait
import (
+ "path/filepath"
"testing"
"github.com/stretchr/testify/assert"
@@ -175,8 +176,8 @@ func TestKnativeService(t *testing.T) {
assert.Equal(t, "file:/etc/camel/sources/routes.js", environment.ApplicationProperties["camel.k.sources[0].location"])
assert.Equal(t, "js", environment.ApplicationProperties["camel.k.sources[0].language"])
assert.Equal(t, "true", environment.ApplicationProperties["camel.k.sources[0].compressed"])
- test.EnvVarHasValue(t, spec.Containers[0].Env, "CAMEL_K_CONF", "/etc/camel/application.properties")
- test.EnvVarHasValue(t, spec.Containers[0].Env, "CAMEL_K_CONF_D", "/etc/camel/conf.d")
+ test.EnvVarHasValue(t, spec.Containers[0].Env, "CAMEL_K_CONF", filepath.FromSlash("/etc/camel/application.properties"))
+ test.EnvVarHasValue(t, spec.Containers[0].Env, "CAMEL_K_CONF_D", filepath.FromSlash("/etc/camel/conf.d"))
}
func TestKnativeServiceWithCustomContainerName(t *testing.T) {
diff --git a/pkg/trait/openapi.go b/pkg/trait/openapi.go
index 8615b1b07..f34589c5b 100644
--- a/pkg/trait/openapi.go
+++ b/pkg/trait/openapi.go
@@ -22,7 +22,6 @@ import (
"fmt"
"io/ioutil"
"os"
- "path"
"path/filepath"
"strconv"
"strings"
@@ -194,7 +193,7 @@ func (t *openAPITrait) generateOpenAPIConfigMap(e *Environment, resource v1.Data
}
func (t *openAPITrait) createNewOpenAPIConfigMap(e *Environment, resource v1.DataSpec, tmpDir, generatedContentName string) error {
- tmpDir = path.Join(tmpDir, generatedContentName)
+ tmpDir = filepath.Join(tmpDir, generatedContentName)
err := os.MkdirAll(tmpDir, os.ModePerm)
if err != nil {
return err
@@ -208,8 +207,8 @@ func (t *openAPITrait) createNewOpenAPIConfigMap(e *Environment, resource v1.Dat
}
}
- in := path.Join(tmpDir, resource.Name)
- out := path.Join(tmpDir, "openapi-dsl.xml")
+ in := filepath.Join(tmpDir, resource.Name)
+ out := filepath.Join(tmpDir, "openapi-dsl.xml")
err = ioutil.WriteFile(in, content, 0o400)
if err != nil {
diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go
index 114c6fe00..63fcb07d0 100644
--- a/pkg/trait/trait_test.go
+++ b/pkg/trait/trait_test.go
@@ -18,7 +18,7 @@ limitations under the License.
package trait
import (
- "path"
+ "path/filepath"
"testing"
"github.com/stretchr/testify/assert"
@@ -233,7 +233,7 @@ func TestConfigureVolumesAndMountsTextResourcesAndProperties(t *testing.T) {
m := findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "test-configmap" })
assert.NotNil(t, m)
- assert.Equal(t, path.Join(camel.ConfigConfigmapsMountPath, "test-configmap"), m.MountPath)
+ assert.Equal(t, filepath.Join(camel.ConfigConfigmapsMountPath, "test-configmap"), m.MountPath)
v = findVolume(vols, func(v corev1.Volume) bool { return v.Name == "test-secret" })
assert.NotNil(t, v)
@@ -242,7 +242,7 @@ func TestConfigureVolumesAndMountsTextResourcesAndProperties(t *testing.T) {
m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "test-secret" })
assert.NotNil(t, m)
- assert.Equal(t, path.Join(camel.ConfigSecretsMountPath, "test-secret"), m.MountPath)
+ assert.Equal(t, filepath.Join(camel.ConfigSecretsMountPath, "test-secret"), m.MountPath)
v = findVolume(vols, func(v corev1.Volume) bool { return v.Name == "testvolume-data" })
assert.NotNil(t, v)
diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go
index 39c800077..b38b9a7d8 100644
--- a/pkg/trait/trait_types.go
+++ b/pkg/trait/trait_types.go
@@ -21,6 +21,7 @@ import (
"context"
"fmt"
"path"
+ "path/filepath"
"sort"
"strings"
@@ -405,8 +406,8 @@ func (e *Environment) addSourcesProperties() {
e.ApplicationProperties = make(map[string]string)
}
for i, s := range e.Integration.Sources() {
- srcName := strings.TrimPrefix(s.Name, "/")
- src := "file:" + path.Join(camel.SourcesMountPath, srcName)
+ srcName := strings.TrimPrefix(filepath.ToSlash(s.Name), "/")
+ src := "file:" + path.Join(filepath.ToSlash(camel.SourcesMountPath), srcName)
e.ApplicationProperties[fmt.Sprintf("camel.k.sources[%d].location", i)] = src
simpleName := srcName
@@ -460,7 +461,7 @@ func (e *Environment) configureVolumesAndMounts(vols *[]corev1.Volume, mnts *[]c
}
resName := strings.TrimPrefix(s.Name, "/")
refName := fmt.Sprintf("i-source-%03d", i)
- resPath := path.Join(camel.SourcesMountPath, resName)
+ resPath := filepath.Join(camel.SourcesMountPath, resName)
vol := getVolume(refName, "configmap", cmName, cmKey, resName)
mnt := getMount(refName, resPath, resName, true)
@@ -476,9 +477,9 @@ func (e *Environment) configureVolumesAndMounts(vols *[]corev1.Volume, mnts *[]c
var mountPath string
switch propertiesType {
case "application":
- mountPath = path.Join(camel.BasePath, resName)
+ mountPath = filepath.Join(camel.BasePath, resName)
case "user":
- mountPath = path.Join(camel.ConfDPath, resName)
+ mountPath = filepath.Join(camel.ConfDPath, resName)
}
if propertiesType != "" {
@@ -521,7 +522,7 @@ func (e *Environment) configureVolumesAndMounts(vols *[]corev1.Volume, mnts *[]c
if len(e.ServiceBindingSecret) > 0 {
secret := e.ServiceBindingSecret
refName := kubernetes.SanitizeLabel(secret)
- mountPath := path.Join(camel.ServiceBindingsMountPath, strings.ToLower(secret))
+ mountPath := filepath.Join(camel.ServiceBindingsMountPath, strings.ToLower(secret))
vol := getVolume(refName, "secret", secret, "", "")
mnt := getMount(refName, mountPath, "", true)
@@ -613,14 +614,14 @@ func getMountPoint(resourceName string, mountPoint string, storagetype, resource
return mountPoint
}
if resourceType == "data" {
- return path.Join(camel.ResourcesDefaultMountPath, resourceName)
+ return filepath.Join(camel.ResourcesDefaultMountPath, resourceName)
}
defaultMountPoint := camel.ConfigConfigmapsMountPath
if storagetype == "secret" {
defaultMountPoint = camel.ConfigSecretsMountPath
}
- return path.Join(defaultMountPoint, resourceName)
+ return filepath.Join(defaultMountPoint, resourceName)
}
func (e *Environment) collectConfigurationValues(configurationType string) []string {
diff --git a/pkg/util/camel/camel_dependencies.go b/pkg/util/camel/camel_dependencies.go
index abe230f08..7ef91d326 100644
--- a/pkg/util/camel/camel_dependencies.go
+++ b/pkg/util/camel/camel_dependencies.go
@@ -20,7 +20,6 @@ package camel
import (
"fmt"
"io"
- "path"
"path/filepath"
"strings"
@@ -221,7 +220,7 @@ func addRegistryMavenDependency(project *maven.Project, dependency string) error
"artifact",
},
Configuration: map[string]string{
- "outputDirectory": path.Join(outputDirectory, filepath.Dir(outputFileRelativePath)),
+ "outputDirectory": filepath.Join(outputDirectory, filepath.Dir(outputFileRelativePath)),
"outputFileName": filepath.Base(outputFileRelativePath),
"groupId": gav.GroupID,
"artifactId": gav.ArtifactID,
diff --git a/pkg/util/camel/camel_util.go b/pkg/util/camel/camel_util.go
index 7b6215881..4e252c906 100644
--- a/pkg/util/camel/camel_util.go
+++ b/pkg/util/camel/camel_util.go
@@ -18,7 +18,7 @@ limitations under the License.
package camel
import (
- "path"
+ "path/filepath"
"sort"
"strings"
@@ -30,13 +30,13 @@ import (
var (
BasePath = "/etc/camel"
- ConfDPath = path.Join(BasePath, "conf.d")
- SourcesMountPath = path.Join(BasePath, "sources")
- ResourcesDefaultMountPath = path.Join(BasePath, "resources")
- ConfigResourcesMountPath = path.Join(ConfDPath, "_resources")
- ConfigConfigmapsMountPath = path.Join(ConfDPath, "_configmaps")
- ConfigSecretsMountPath = path.Join(ConfDPath, "_secrets")
- ServiceBindingsMountPath = path.Join(ConfDPath, "_servicebindings")
+ ConfDPath = filepath.Join(BasePath, "conf.d")
+ SourcesMountPath = filepath.Join(BasePath, "sources")
+ ResourcesDefaultMountPath = filepath.Join(BasePath, "resources")
+ ConfigResourcesMountPath = filepath.Join(ConfDPath, "_resources")
+ ConfigConfigmapsMountPath = filepath.Join(ConfDPath, "_configmaps")
+ ConfigSecretsMountPath = filepath.Join(ConfDPath, "_secrets")
+ ServiceBindingsMountPath = filepath.Join(ConfDPath, "_servicebindings")
)
func findBestMatch(catalogs []v1.CamelCatalog, runtime v1.RuntimeSpec) (*RuntimeCatalog, error) {
diff --git a/pkg/util/camel/catalog.go b/pkg/util/camel/catalog.go
index 360f5ed12..7918fd775 100644
--- a/pkg/util/camel/catalog.go
+++ b/pkg/util/camel/catalog.go
@@ -19,7 +19,7 @@ package camel
import (
"context"
- "path"
+ "path/filepath"
yaml2 "gopkg.in/yaml.v2"
@@ -148,7 +148,7 @@ func GenerateCatalogCommon(
return err
}
- content, err := util.ReadFile(path.Join(tmpDir, "catalog.yaml"))
+ content, err := util.ReadFile(filepath.Join(tmpDir, "catalog.yaml"))
if err != nil {
return err
}
diff --git a/pkg/util/digest/digest.go b/pkg/util/digest/digest.go
index ee119a452..ddadc615b 100644
--- a/pkg/util/digest/digest.go
+++ b/pkg/util/digest/digest.go
@@ -27,7 +27,7 @@ import (
"fmt"
"hash"
"io"
- "path"
+ "path/filepath"
"sort"
"strconv"
"strings"
@@ -311,7 +311,7 @@ func sortedTraitAnnotationsKeys(it *v1.Integration) []string {
}
func ComputeSHA1(elem ...string) (string, error) {
- file := path.Join(elem...)
+ file := filepath.Join(elem...)
// #nosec G401
h := sha1.New()
diff --git a/pkg/util/docker/docker.go b/pkg/util/docker/docker.go
index eca77307f..37d298190 100644
--- a/pkg/util/docker/docker.go
+++ b/pkg/util/docker/docker.go
@@ -19,7 +19,7 @@ package docker
import (
"os/exec"
- "path"
+ "path/filepath"
"strings"
"github.com/apache/camel-k/pkg/util"
@@ -38,7 +38,7 @@ func CreateBaseImageDockerFile() error {
dockerFile = append(dockerFile, RUNMavenInstall())
// Write <BaseWorkingDirectory>/Dockerfile
- baseDockerFilePath := path.Join(BaseWorkingDirectory, "Dockerfile")
+ baseDockerFilePath := filepath.Join(BaseWorkingDirectory, "Dockerfile")
if err := util.WriteToFile(baseDockerFilePath, strings.Join(dockerFile, "\n")); err != nil {
return err
}
@@ -82,7 +82,7 @@ func CreateIntegrationImageDockerFile(integrationRunCmd *exec.Cmd, startsFromLoc
dockerFile = append(dockerFile, CMDShellWrap(strings.Join(integrationRunCmd.Args, " ")))
// Write <IntegrationWorkingDirectory>/Dockerfile
- integrationDockerFilePath := path.Join(IntegrationWorkingDirectory, "Dockerfile")
+ integrationDockerFilePath := filepath.Join(IntegrationWorkingDirectory, "Dockerfile")
err := util.WriteToFile(integrationDockerFilePath, strings.Join(dockerFile, "\n"))
if err != nil {
return err
@@ -139,7 +139,7 @@ func GetContainerRoutesDir() string {
func ContainerizeFilePaths(currentFilePaths []string, newDir string) []string {
newFilePaths := []string{}
for _, currentFilePath := range currentFilePaths {
- newFilePaths = append(newFilePaths, newDir+containerFileSeparator+path.Base(currentFilePath))
+ newFilePaths = append(newFilePaths, newDir+containerFileSeparator+filepath.Base(currentFilePath))
}
return newFilePaths
@@ -153,7 +153,7 @@ func ContainerizeDependencyPaths(dependencyPaths []string, newDir string) []stri
if newDependencyPath != "" {
newDependencyPaths = append(newDependencyPaths, newDir+newDependencyPath)
} else {
- newDependencyPaths = append(newDependencyPaths, newDir+containerFileSeparator+path.Base(currentDependencyPath))
+ newDependencyPaths = append(newDependencyPaths, newDir+containerFileSeparator+filepath.Base(currentDependencyPath))
}
}
return newDependencyPaths
diff --git a/pkg/util/docker/docker_base.go b/pkg/util/docker/docker_base.go
index 5fba82e95..f91f60bc1 100644
--- a/pkg/util/docker/docker_base.go
+++ b/pkg/util/docker/docker_base.go
@@ -18,7 +18,7 @@ limitations under the License.
package docker
import (
- "path"
+ "path/filepath"
"strings"
"github.com/apache/camel-k/pkg/util"
@@ -56,7 +56,7 @@ func BuildImageArgs(dockerFileDir string, imageName string, sourceDir string) []
args = append(args, "build")
// Add path to Dockerfile:
- dockerFile := path.Join(dockerFileDir, "Dockerfile")
+ dockerFile := filepath.Join(dockerFileDir, "Dockerfile")
args = append(args, DockerfilePathArg(dockerFile)...)
diff --git a/pkg/util/jvm/keystore.go b/pkg/util/jvm/keystore.go
index 9788fa362..1721227b9 100644
--- a/pkg/util/jvm/keystore.go
+++ b/pkg/util/jvm/keystore.go
@@ -23,7 +23,7 @@ import (
"fmt"
"os"
"os/exec"
- "path"
+ "path/filepath"
"strings"
"github.com/apache/camel-k/pkg/util"
@@ -56,7 +56,7 @@ func GenerateKeystore(ctx context.Context, keystoreDir, keystoreName, keystorePa
// JVM truststore.
javaHome, ok := os.LookupEnv("JAVA_HOME")
if ok {
- caCertsPath := path.Join(javaHome, "lib/security/cacerts")
+ caCertsPath := filepath.Join(javaHome, "lib/security/cacerts")
args := strings.Fields(fmt.Sprintf("-importkeystore -noprompt -srckeystore %s -srcstorepass %s -destkeystore %s -deststorepass %s", caCertsPath, "changeit", keystoreName, keystorePass))
cmd := exec.CommandContext(ctx, "keytool", args...)
cmd.Dir = keystoreDir
diff --git a/pkg/util/maven/maven_command.go b/pkg/util/maven/maven_command.go
index 2440a4328..c0cc4d764 100644
--- a/pkg/util/maven/maven_command.go
+++ b/pkg/util/maven/maven_command.go
@@ -24,7 +24,7 @@ import (
"io/ioutil"
"os"
"os/exec"
- "path"
+ "path/filepath"
"regexp"
"runtime"
"strconv"
@@ -62,14 +62,14 @@ func (c *Command) Do(ctx context.Context) error {
}
}
- settingsPath := path.Join(c.context.Path, "settings.xml")
+ settingsPath := filepath.Join(c.context.Path, "settings.xml")
if settingsExists, err := util.FileExists(settingsPath); err != nil {
return err
} else if settingsExists {
args = append(args, "--global-settings", settingsPath)
}
- settingsPath = path.Join(c.context.Path, "user-settings.xml")
+ settingsPath = filepath.Join(c.context.Path, "user-settings.xml")
if settingsExists, err := util.FileExists(settingsPath); err != nil {
return err
} else if settingsExists {
@@ -183,19 +183,19 @@ func generateProjectStructure(context Context, project Project) error {
}
if context.GlobalSettings != nil {
- if err := util.WriteFileWithContent(path.Join(context.Path, "settings.xml"), context.GlobalSettings); err != nil {
+ if err := util.WriteFileWithContent(filepath.Join(context.Path, "settings.xml"), context.GlobalSettings); err != nil {
return err
}
}
if context.UserSettings != nil {
- if err := util.WriteFileWithContent(path.Join(context.Path, "user-settings.xml"), context.UserSettings); err != nil {
+ if err := util.WriteFileWithContent(filepath.Join(context.Path, "user-settings.xml"), context.UserSettings); err != nil {
return err
}
}
if context.SettingsSecurity != nil {
- if err := util.WriteFileWithContent(path.Join(context.Path, "settings-security.xml"), context.SettingsSecurity); err != nil {
+ if err := util.WriteFileWithContent(filepath.Join(context.Path, "settings-security.xml"), context.SettingsSecurity); err != nil {
return err
}
}
@@ -218,7 +218,7 @@ func generateProjectStructure(context Context, project Project) error {
if len(bytes) > 0 {
Log.Infof("write entry: %s (%d bytes)", k, len(bytes))
- err = util.WriteFileWithContent(path.Join(context.Path, k), bytes)
+ err = util.WriteFileWithContent(filepath.Join(context.Path, k), bytes)
if err != nil {
return err
}
diff --git a/pkg/util/util.go b/pkg/util/util.go
index 80fb19910..750aada65 100644
--- a/pkg/util/util.go
+++ b/pkg/util/util.go
@@ -330,7 +330,7 @@ func WriteFileWithBytesMarshallerContent(basePath string, filePath string, conte
return err
}
- return WriteFileWithContent(path.Join(basePath, filePath), data)
+ return WriteFileWithContent(filepath.Join(basePath, filePath), data)
}
func FindAllDistinctStringSubmatch(data string, regexps ...*regexp.Regexp) []string {