You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2021/06/03 09:17:35 UTC
[camel-k] 04/09: feat(cmd/run): modeline --config support
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit a5fff82ad252a29edf814be75ef6c96069a6ba36
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Thu May 27 10:26:21 2021 +0200
feat(cmd/run): modeline --config support
Ref #2003
---
pkg/cmd/modeline.go | 1 -
pkg/cmd/modeline_test.go | 51 ++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/pkg/cmd/modeline.go b/pkg/cmd/modeline.go
index d6fe533..2a06910 100644
--- a/pkg/cmd/modeline.go
+++ b/pkg/cmd/modeline.go
@@ -53,7 +53,6 @@ var (
// file options must be considered relative to the source files they belong to
fileOptions = map[string]bool{
"resource": true,
- "config": true,
"open-api": true,
"property-file": true,
}
diff --git a/pkg/cmd/modeline_test.go b/pkg/cmd/modeline_test.go
index 912e741..8dc2c75 100644
--- a/pkg/cmd/modeline_test.go
+++ b/pkg/cmd/modeline_test.go
@@ -203,6 +203,57 @@ func TestModelineRunBuildPropertyFiles(t *testing.T) {
assert.Equal(t, []string{"run", fileName, "--build-property=file:application.properties"}, flags)
}
+func TestModelineRunConfigSecret(t *testing.T) {
+ dir, err := ioutil.TempDir("", "camel-k-test-")
+ assert.NoError(t, err)
+ defer os.RemoveAll(dir)
+
+ subDir := path.Join(dir, "sub")
+ err = os.Mkdir(subDir, 0777)
+ assert.NoError(t, err)
+
+ file := `
+ // camel-k: config=secret:my-secret
+ `
+ fileName := path.Join(subDir, "simple.groovy")
+ err = ioutil.WriteFile(fileName, []byte(file), 0777)
+ assert.NoError(t, err)
+
+ cmd, flags, err := NewKamelWithModelineCommand(context.TODO(), []string{"kamel", "run", fileName})
+ assert.NoError(t, err)
+ assert.NotNil(t, cmd)
+ assert.Equal(t, []string{"run", fileName, "--config=secret:my-secret"}, flags)
+}
+
+func TestModelineRunConfigFile(t *testing.T) {
+ dir, err := ioutil.TempDir("", "camel-k-test-")
+ assert.NoError(t, err)
+ defer os.RemoveAll(dir)
+
+ subDir := path.Join(dir, "sub")
+ err = os.Mkdir(subDir, 0777)
+ assert.NoError(t, err)
+
+ file := `
+ // camel-k: config=file:application.properties
+ `
+ fileName := path.Join(subDir, "simple.groovy")
+ err = ioutil.WriteFile(fileName, []byte(file), 0777)
+ assert.NoError(t, err)
+
+ propFile := `
+ a=b
+ `
+ propFileName := path.Join(dir, "application.properties")
+ err = ioutil.WriteFile(propFileName, []byte(propFile), 0777)
+ assert.NoError(t, err)
+
+ cmd, flags, err := NewKamelWithModelineCommand(context.TODO(), []string{"kamel", "run", fileName})
+ assert.NoError(t, err)
+ assert.NotNil(t, cmd)
+ assert.Equal(t, []string{"run", fileName, "--config=file:application.properties"}, flags)
+}
+
func TestModelineInspectSimple(t *testing.T) {
dir, err := ioutil.TempDir("", "camel-k-test-")
assert.NoError(t, err)