This is an automated email from the ASF dual-hosted git repository. astefanutti pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit 73339cf8657de13cff07a0dc4723cf74f27f9f95 Author: Pasquale Congiusti <[email protected]> AuthorDate: Wed Jun 16 12:21:41 2021 +0200 chore(cmd/run): single resource dir and cli syntax description Ref #2003 --- docs/modules/ROOT/pages/cli/modeline.adoc | 4 ++-- e2e/common/config/files/resource-configmap-route.groovy | 2 +- e2e/common/config/files/resource-file-binary-route.groovy | 2 +- e2e/common/config/files/resource-file-route.groovy | 2 +- e2e/common/config/files/resource-secret-route.groovy | 2 +- examples/user-config/resource-configmap-route.groovy | 2 +- examples/user-config/resource-file-binary-route.groovy | 2 +- examples/user-config/resource-file-route.groovy | 2 +- examples/user-config/resource-secret-route.groovy | 2 +- pkg/cmd/run.go | 4 ++-- pkg/trait/jvm.go | 2 +- pkg/trait/jvm_test.go | 8 ++++---- pkg/trait/trait_test.go | 10 +++++----- pkg/trait/trait_types.go | 11 ++++------- 14 files changed, 26 insertions(+), 29 deletions(-) diff --git a/docs/modules/ROOT/pages/cli/modeline.adoc b/docs/modules/ROOT/pages/cli/modeline.adoc index ac1b734..e54de1c 100644 --- a/docs/modules/ROOT/pages/cli/modeline.adoc +++ b/docs/modules/ROOT/pages/cli/modeline.adoc @@ -70,7 +70,7 @@ The following is a partial list of useful options: |Add a build time property or properties file (syntax: _[my-key=my-value\|file:/path/to/my-conf.properties]_ |config -|Add a runtime configuration from a Configmap, a Secret or a file (syntax: _[configmap\|secret\|file]:name[/key]_) +|Add a runtime configuration from a Configmap, a Secret or a file (syntax: _[configmap\|secret\|file]:name[/key]_, where name represents the local file path or the configmap/secret name and key optionally represents the configmap/secret key to be filtered) |dependency |An external library that should be included, e.g. for Maven dependencies `dependency=mvn:org.my:app:1.0` @@ -94,7 +94,7 @@ The following is a partial list of useful options: |Add a runtime property or properties file (syntax: _[my-key=my-value\|file:/path/to/my-conf.properties]_) |resource -|Add a runtime resource from a Configmap, a Secret or a file (syntax: _[configmap\|secret\|file]:name[/key][@path]_) +|Add a runtime resource from a Configmap, a Secret or a file (syntax: _[configmap\|secret\|file]:name[/key][@path]_, where name represents the local file path or the configmap/secret name, key optionally represents the configmap/secret key to be filtered and path represents the destination path) |trait |Configure a trait, e.g. `trait=service.enabled=false` diff --git a/e2e/common/config/files/resource-configmap-route.groovy b/e2e/common/config/files/resource-configmap-route.groovy index 3df9e05..6cccf02 100644 --- a/e2e/common/config/files/resource-configmap-route.groovy +++ b/e2e/common/config/files/resource-configmap-route.groovy @@ -16,5 +16,5 @@ * limitations under the License. */ -from('file:/etc/camel/data/configmaps/my-cm/?fileName=my-configmap-key&noop=true&idempotent=false') +from('file:/etc/camel/resources/my-cm/?fileName=my-configmap-key&noop=true&idempotent=false') .log('resource file content is: ${body}') diff --git a/e2e/common/config/files/resource-file-binary-route.groovy b/e2e/common/config/files/resource-file-binary-route.groovy index c6faa9a..ff50ad1 100644 --- a/e2e/common/config/files/resource-file-binary-route.groovy +++ b/e2e/common/config/files/resource-file-binary-route.groovy @@ -16,7 +16,7 @@ * limitations under the License. */ -from('file:/etc/camel/data/resources/?fileName=resources-data.zip&noop=true&idempotent=false') +from('file:/etc/camel/resources/?fileName=resources-data.zip&noop=true&idempotent=false') .routeId('resources-zip') .unmarshal().zipFile() .log('resource file unzipped content is: ${body}') diff --git a/e2e/common/config/files/resource-file-route.groovy b/e2e/common/config/files/resource-file-route.groovy index 6ab0338..d515385 100644 --- a/e2e/common/config/files/resource-file-route.groovy +++ b/e2e/common/config/files/resource-file-route.groovy @@ -16,5 +16,5 @@ * limitations under the License. */ -from('file:/etc/camel/data/resources/?fileName=resources-data.txt&noop=true&idempotent=false') +from('file:/etc/camel/resources/?fileName=resources-data.txt&noop=true&idempotent=false') .log('resource file content is: ${body}') diff --git a/e2e/common/config/files/resource-secret-route.groovy b/e2e/common/config/files/resource-secret-route.groovy index c2e5685..63f4c76 100644 --- a/e2e/common/config/files/resource-secret-route.groovy +++ b/e2e/common/config/files/resource-secret-route.groovy @@ -16,5 +16,5 @@ * limitations under the License. */ -from('file:/etc/camel/data/secrets/my-sec/?fileName=my-secret-key&noop=true&idempotent=false') +from('file:/etc/camel/resources/my-sec/?fileName=my-secret-key&noop=true&idempotent=false') .log('resource file content is: ${body}') diff --git a/examples/user-config/resource-configmap-route.groovy b/examples/user-config/resource-configmap-route.groovy index 1d7ef24..5d0a522 100644 --- a/examples/user-config/resource-configmap-route.groovy +++ b/examples/user-config/resource-configmap-route.groovy @@ -23,5 +23,5 @@ // kamel run --resource configmap:my-cm resource-configmap-route.groovy --dev // -from('file:/etc/camel/data/configmaps/my-cm/?fileName=my-configmap-key&noop=true&idempotent=false') +from('file:/etc/camel/resources/my-cm/?fileName=my-configmap-key&noop=true&idempotent=false') .log('resource file content is: ${body}') diff --git a/examples/user-config/resource-file-binary-route.groovy b/examples/user-config/resource-file-binary-route.groovy index 2121c26..eef04d1 100644 --- a/examples/user-config/resource-file-binary-route.groovy +++ b/examples/user-config/resource-file-binary-route.groovy @@ -21,7 +21,7 @@ // kamel run --resource resources-data.zip resource-file-binary-route.groovy -d camel-zipfile --dev // -from('file:/etc/camel/data/resources/?fileName=resources-data.zip&noop=true&idempotent=false') +from('file:/etc/camel/resources/?fileName=resources-data.zip&noop=true&idempotent=false') .routeId('resources-zip') .unmarshal().zipFile() .log('resource file unzipped content is: ${body}') diff --git a/examples/user-config/resource-file-route.groovy b/examples/user-config/resource-file-route.groovy index f39f4e5..63d6298 100644 --- a/examples/user-config/resource-file-route.groovy +++ b/examples/user-config/resource-file-route.groovy @@ -21,5 +21,5 @@ // kamel run --resource file:resources-data.txt resource-file-route.groovy --dev // -from('file:/etc/camel/data/resources/?fileName=resources-data.txt&noop=true&idempotent=false') +from('file:/etc/camel/resources/?fileName=resources-data.txt&noop=true&idempotent=false') .log('resource file content is: ${body}') diff --git a/examples/user-config/resource-secret-route.groovy b/examples/user-config/resource-secret-route.groovy index b46bb49..c6dc923 100644 --- a/examples/user-config/resource-secret-route.groovy +++ b/examples/user-config/resource-secret-route.groovy @@ -23,5 +23,5 @@ // kamel run --resource secret:my-sec resource-secret-route.groovy --dev // -from('file:/etc/camel/data/secrets/my-sec/?fileName=my-secret-key&noop=true&idempotent=false') +from('file:/etc/camel/my-sec/?fileName=my-secret-key&noop=true&idempotent=false') .log('resource file content is: ${body}') diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go index e6d42b4..d85e71a 100644 --- a/pkg/cmd/run.go +++ b/pkg/cmd/run.go @@ -81,8 +81,8 @@ func newCmdRun(rootCmdOptions *RootCmdOptions) (*cobra.Command, *runCmdOptions) cmd.Flags().StringP("kit", "k", "", "The kit used to run the integration") cmd.Flags().StringArrayP("property", "p", nil, "Add a runtime property or properties file (syntax: [my-key=my-value|file:/path/to/my-conf.properties])") cmd.Flags().StringArray("build-property", nil, "Add a build time property or properties file (syntax: [my-key=my-value|file:/path/to/my-conf.properties])") - cmd.Flags().StringArray("config", nil, "Add a runtime configuration from a Configmap, a Secret or a file (syntax: [configmap|secret|file]:name[/key])") - cmd.Flags().StringArray("resource", nil, "Add a runtime resource from a Configmap, a Secret or a file (syntax: [configmap|secret|file]:name[/key][@path])") + cmd.Flags().StringArray("config", nil, "Add a runtime configuration from a Configmap, a Secret or a file (syntax: [configmap|secret|file]:name[/key], where name represents the local file path or the configmap/secret name and key optionally represents the configmap/secret key to be filtered)") + cmd.Flags().StringArray("resource", nil, "Add a runtime resource from a Configmap, a Secret or a file (syntax: [configmap|secret|file]:name[/key][@path], where name represents the local file path or the configmap/secret name, key optionally represents the configmap/secret key to be filtered and path represents the destination path)") cmd.Flags().StringArray("configmap", nil, "[Deprecated] Add a ConfigMap") cmd.Flags().StringArray("secret", nil, "[Deprecated] Add a Secret") cmd.Flags().StringArray("maven-repository", nil, "Add a maven repository") diff --git a/pkg/trait/jvm.go b/pkg/trait/jvm.go index c30a3aa..44da721 100644 --- a/pkg/trait/jvm.go +++ b/pkg/trait/jvm.go @@ -97,7 +97,7 @@ func (t *jvmTrait) Apply(e *Environment) error { classpath.Add("./resources") classpath.Add(configResourcesMountPath) - classpath.Add(dataResourcesMountPath) + classpath.Add(resourcesDefaultMountPath) for _, artifact := range kit.Status.Artifacts { classpath.Add(artifact.Target) diff --git a/pkg/trait/jvm_test.go b/pkg/trait/jvm_test.go index f5bc7d1..b568133 100644 --- a/pkg/trait/jvm_test.go +++ b/pkg/trait/jvm_test.go @@ -104,12 +104,12 @@ func TestApplyJvmTraitWithDeploymentResource(t *testing.T) { assert.Nil(t, err) - cp := strset.New("./resources", configResourcesMountPath, dataResourcesMountPath, "/mount/path").List() + cp := strset.New("./resources", configResourcesMountPath, resourcesDefaultMountPath, "/mount/path").List() sort.Strings(cp) assert.Equal(t, []string{ "-cp", - fmt.Sprintf("./resources:%s:%s:/mount/path", configResourcesMountPath, dataResourcesMountPath), + fmt.Sprintf("./resources:%s:%s:/mount/path", configResourcesMountPath, resourcesDefaultMountPath), "io.quarkus.bootstrap.runner.QuarkusEntryPoint", }, d.Spec.Template.Spec.Containers[0].Args) } @@ -136,12 +136,12 @@ func TestApplyJvmTraitWithKNativeResource(t *testing.T) { assert.Nil(t, err) - cp := strset.New("./resources", configResourcesMountPath, dataResourcesMountPath, "/mount/path").List() + cp := strset.New("./resources", configResourcesMountPath, resourcesDefaultMountPath, "/mount/path").List() sort.Strings(cp) assert.Equal(t, []string{ "-cp", - fmt.Sprintf("./resources:%s:%s:/mount/path", configResourcesMountPath, dataResourcesMountPath), + fmt.Sprintf("./resources:%s:%s:/mount/path", configResourcesMountPath, resourcesDefaultMountPath), "io.quarkus.bootstrap.runner.QuarkusEntryPoint", }, s.Spec.Template.Spec.Containers[0].Args) } diff --git a/pkg/trait/trait_test.go b/pkg/trait/trait_test.go index f49a5b0..100056d 100644 --- a/pkg/trait/trait_test.go +++ b/pkg/trait/trait_test.go @@ -315,7 +315,7 @@ func TestConfigureVolumesAndMountsTextResourcesAndProperties(t *testing.T) { m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "i-resource-001" }) assert.NotNil(t, m) - assert.Equal(t, "/etc/camel/data/resources/res2.txt", m.MountPath) + assert.Equal(t, "/etc/camel/resources/res2.txt", m.MountPath) v = findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == TestDeploymentName+"-resource-002" }) assert.NotNil(t, v) @@ -326,7 +326,7 @@ func TestConfigureVolumesAndMountsTextResourcesAndProperties(t *testing.T) { m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "i-resource-002" }) assert.NotNil(t, m) - assert.Equal(t, "/etc/camel/data/resources/res3.txt", m.MountPath) + assert.Equal(t, "/etc/camel/resources/res3.txt", m.MountPath) v = findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == TestDeploymentName+"-resource-003" }) assert.NotNil(t, v) @@ -337,7 +337,7 @@ func TestConfigureVolumesAndMountsTextResourcesAndProperties(t *testing.T) { m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == "i-resource-003" }) assert.NotNil(t, m) - assert.Equal(t, "/etc/camel/data/resources/res4.txt", m.MountPath) + assert.Equal(t, "/etc/camel/resources/res4.txt", m.MountPath) v = findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "test-configmap" }) assert.NotNil(t, v) @@ -480,7 +480,7 @@ func TestConfigureVolumesAndMountsBinaryAndTextResources(t *testing.T) { m := findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == v.Name }) assert.NotNil(t, m) - assert.Equal(t, "/etc/camel/data/resources/res1.bin", m.MountPath) + assert.Equal(t, "/etc/camel/resources/res1.bin", m.MountPath) v = findVolume(vols, func(v corev1.Volume) bool { return v.ConfigMap.Name == "my-cm2" }) assert.NotNil(t, v) @@ -491,7 +491,7 @@ func TestConfigureVolumesAndMountsBinaryAndTextResources(t *testing.T) { m = findVVolumeMount(mnts, func(m corev1.VolumeMount) bool { return m.Name == v.Name }) assert.NotNil(t, m) - assert.Equal(t, "/etc/camel/data/resources/res2.txt", m.MountPath) + assert.Equal(t, "/etc/camel/resources/res2.txt", m.MountPath) } func TestOnlySomeTraitsInfluenceBuild(t *testing.T) { diff --git a/pkg/trait/trait_types.go b/pkg/trait/trait_types.go index 6b3a23d..f22e3d5 100644 --- a/pkg/trait/trait_types.go +++ b/pkg/trait/trait_types.go @@ -51,10 +51,7 @@ var ( basePath = "/etc/camel" confDPath = path.Join(basePath, "conf.d") sourcesMountPath = path.Join(basePath, "sources") - dataDefaultMountPath = path.Join(basePath, "data") - dataResourcesMountPath = path.Join(dataDefaultMountPath, "resources") - dataConfigmapsMountPath = path.Join(dataDefaultMountPath, "configmaps") - dataSecretsMountPath = path.Join(dataDefaultMountPath, "secrets") + resourcesDefaultMountPath = path.Join(basePath, "resources") configResourcesMountPath = path.Join(confDPath, "_resources") configConfigmapsMountPath = path.Join(confDPath, "_configmaps") configSecretsMountPath = path.Join(confDPath, "_secrets") @@ -818,7 +815,7 @@ func getResourcePath(resourceName string, maybePath string, resourceType v1.Reso // otherwise return a default path, according to the resource type switch resourceType { case v1.ResourceTypeData: - return path.Join(dataResourcesMountPath, resourceName) + return path.Join(resourcesDefaultMountPath, resourceName) } // Default, config type return path.Join(configResourcesMountPath, resourceName) @@ -831,7 +828,7 @@ func getConfigmapMountPoint(resourceName string, maybeMountPoint string, resourc } switch resourceType { case "data": - return path.Join(dataConfigmapsMountPath, resourceName) + return path.Join(resourcesDefaultMountPath, resourceName) } // Default, config type return path.Join(configConfigmapsMountPath, resourceName) @@ -844,7 +841,7 @@ func getSecretMountPoint(resourceName string, maybeMountPoint string, resourceTy } switch resourceType { case "data": - return path.Join(dataSecretsMountPath, resourceName) + return path.Join(resourcesDefaultMountPath, resourceName) } // Default, config type return path.Join(configSecretsMountPath, resourceName)
