You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pc...@apache.org on 2022/03/14 08:54:46 UTC

[camel-k] branch main updated: fix(cli): resource file with same content

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

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


The following commit(s) were added to refs/heads/main by this push:
     new fd64646  fix(cli): resource file with same content
fd64646 is described below

commit fd6464604cc6fbd764cb1b5c63f7503a9d764de6
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu Mar 10 14:56:22 2022 +0100

    fix(cli): resource file with same content
    
    Closes #3077
---
 e2e/common/config/config_test.go                | 10 ++++++++++
 e2e/common/config/files/resources-data-same.txt |  1 +
 pkg/trait/mount.go                              |  6 ++----
 3 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/e2e/common/config/config_test.go b/e2e/common/config/config_test.go
index 4e459d7..6904df1 100644
--- a/e2e/common/config/config_test.go
+++ b/e2e/common/config/config_test.go
@@ -209,6 +209,16 @@ func TestRunConfigExamples(t *testing.T) {
 			Eventually(AutogeneratedConfigmapsCount(ns), TestTimeoutShort).Should(Equal(0))
 		})
 
+		t.Run("Plain text resource file with same content", func(t *testing.T) {
+			Expect(Kamel("run", "-n", ns, "./files/resource-file-route.groovy", "--resource", "file:./files/resources-data.txt",
+				"--resource", "file:./files/resources-data-same.txt").Execute()).To(Succeed())
+			Eventually(IntegrationPodPhase(ns, "resource-file-route"), TestTimeoutMedium).Should(Equal(corev1.PodRunning))
+			Eventually(IntegrationConditionStatus(ns, "resource-file-route", v1.IntegrationConditionReady), TestTimeoutShort).Should(Equal(corev1.ConditionTrue))
+			Eventually(IntegrationLogs(ns, "resource-file-route"), TestTimeoutShort).Should(ContainSubstring("the file body"))
+			Expect(Kamel("delete", "--all", "-n", ns).Execute()).To(Succeed())
+			Eventually(AutogeneratedConfigmapsCount(ns), TestTimeoutShort).Should(Equal(0))
+		})
+
 		// Build-Properties
 		t.Run("Build time property", func(t *testing.T) {
 			Expect(Kamel("run", "-n", ns, "./files/build-property-route.groovy", "--build-property", "quarkus.application.name=my-super-application").Execute()).To(Succeed())
diff --git a/e2e/common/config/files/resources-data-same.txt b/e2e/common/config/files/resources-data-same.txt
new file mode 100644
index 0000000..dff7947
--- /dev/null
+++ b/e2e/common/config/files/resources-data-same.txt
@@ -0,0 +1 @@
+the file body
\ No newline at end of file
diff --git a/pkg/trait/mount.go b/pkg/trait/mount.go
index 2159692..6c8976a 100644
--- a/pkg/trait/mount.go
+++ b/pkg/trait/mount.go
@@ -183,14 +183,12 @@ func (t *mountTrait) attachResource(e *Environment, conf *utilResource.Config) {
 
 func (t *mountTrait) mountResource(vols *[]corev1.Volume, mnts *[]corev1.VolumeMount, conf *utilResource.Config) {
 	refName := kubernetes.SanitizeLabel(conf.Name())
-	dstDir := ""
+	dstDir := conf.DestinationPath()
 	dstFile := ""
 	if conf.DestinationPath() != "" {
 		if conf.Key() != "" {
-			dstDir = filepath.Dir(conf.DestinationPath())
 			dstFile = filepath.Base(conf.DestinationPath())
 		} else {
-			dstDir = conf.DestinationPath()
 			dstFile = conf.Key()
 		}
 	}
@@ -200,7 +198,7 @@ func (t *mountTrait) mountResource(vols *[]corev1.Volume, mnts *[]corev1.VolumeM
 	if conf.StorageType() == utilResource.StorageTypePVC {
 		readOnly = false
 	}
-	mnt := getMount(refName, mntPath, "", readOnly)
+	mnt := getMount(refName, mntPath, dstFile, readOnly)
 
 	*vols = append(*vols, *vol)
 	*mnts = append(*mnts, *mnt)