This is an automated email from the ASF dual-hosted git repository. nferraro pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k.git
commit f0e73852e519c7d197b5d44405fbc16360ab8b41 Author: Nicola Ferraro <ni.ferr...@gmail.com> AuthorDate: Fri May 8 12:56:04 2020 +0200 Fix #1449: fix lint and typos --- docs/modules/ROOT/pages/cli/modeline.adoc | 4 ++-- pkg/cmd/modeline.go | 2 +- pkg/cmd/modeline_test.go | 14 +++++++------- pkg/cmd/run.go | 4 ++++ pkg/util/modeline/parser_test.go | 3 ++- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/docs/modules/ROOT/pages/cli/modeline.adoc b/docs/modules/ROOT/pages/cli/modeline.adoc index 9f58304..7d77da3 100644 --- a/docs/modules/ROOT/pages/cli/modeline.adoc +++ b/docs/modules/ROOT/pages/cli/modeline.adoc @@ -6,7 +6,7 @@ For example, take the following integration file: .Hello.java ---- -// camel-k: dependency=mvn:org.my:application:1.0 // <1> +// camel-k: dependency=mvn:org.my/application:1.0 // <1> import org.apache.camel.builder.RouteBuilder; @@ -32,7 +32,7 @@ The `kamel` CLI will alert you, printing the full command in the shell: ---- $ kamel run Hello.java Modeline options have been loaded from source files -Full command: kamel run Hello.java --dependency mvn:org.my:application:1.0 +Full command: kamel run Hello.java --dependency mvn:org.my/application:1.0 ... ---- diff --git a/pkg/cmd/modeline.go b/pkg/cmd/modeline.go index caa1310..aee189e 100644 --- a/pkg/cmd/modeline.go +++ b/pkg/cmd/modeline.go @@ -84,7 +84,7 @@ func createKamelWithModelineCommand(ctx context.Context, args []string, processe var files = append([]string(nil), fg.Args()...) files = append(files, sources...) - var opts []modeline.Option + opts := make([]modeline.Option, 0) for _, f := range files { if processedFiles[f] { continue diff --git a/pkg/cmd/modeline_test.go b/pkg/cmd/modeline_test.go index 33de320..4206b6d 100644 --- a/pkg/cmd/modeline_test.go +++ b/pkg/cmd/modeline_test.go @@ -34,7 +34,7 @@ func TestModelineRunSimple(t *testing.T) { defer os.RemoveAll(dir) file := ` - // camel-k: dependency=mvn:org.my:lib:1.0 + // camel-k: dependency=mvn:org.my/lib:1.0 ` fileName := path.Join(dir, "simple.groovy") err = ioutil.WriteFile(fileName, []byte(file), 0777) @@ -43,7 +43,7 @@ func TestModelineRunSimple(t *testing.T) { cmd, flags, err := NewKamelWithModelineCommand(context.TODO(), []string{"kamel", "run", fileName}) assert.NoError(t, err) assert.NotNil(t, cmd) - assert.Equal(t, []string{"run", fileName, "--dependency", "mvn:org.my:lib:1.0"}, flags) + assert.Equal(t, []string{"run", fileName, "--dependency", "mvn:org.my/lib:1.0"}, flags) } func TestModelineRunHelp(t *testing.T) { @@ -65,16 +65,16 @@ func TestModelineRunChain(t *testing.T) { defer os.RemoveAll(dir) file := ` - // camel-k: dependency=mvn:org.my:lib:1.0 + // camel-k: dependency=mvn:org.my/lib:2.0 ` fileName := path.Join(dir, "simple.groovy") err = ioutil.WriteFile(fileName, []byte(file), 0777) assert.NoError(t, err) - cmd, flags, err := NewKamelWithModelineCommand(context.TODO(), []string{"kamel", "run", "-d", "mvn:org.my:lib2:1.0", fileName}) + cmd, flags, err := NewKamelWithModelineCommand(context.TODO(), []string{"kamel", "run", "-d", "mvn:org.my/lib2:1.0", fileName}) assert.NoError(t, err) assert.NotNil(t, cmd) - assert.Equal(t, []string{"run", "-d", "mvn:org.my:lib2:1.0", fileName, "--dependency", "mvn:org.my:lib:1.0"}, flags) + assert.Equal(t, []string{"run", "-d", "mvn:org.my/lib2:1.0", fileName, "--dependency", "mvn:org.my/lib:2.0"}, flags) } func TestModelineRunMultipleFiles(t *testing.T) { @@ -90,7 +90,7 @@ func TestModelineRunMultipleFiles(t *testing.T) { assert.NoError(t, err) file2 := ` - // camel-k: dependency=mvn:org.my:lib:1.0 + // camel-k: dependency=mvn:org.my/lib:3.0 ` fileName2 := path.Join(dir, "ext.groovy") err = ioutil.WriteFile(fileName2, []byte(file2), 0777) @@ -99,7 +99,7 @@ func TestModelineRunMultipleFiles(t *testing.T) { cmd, flags, err := NewKamelWithModelineCommand(context.TODO(), []string{"kamel", "run", fileName}) assert.NoError(t, err) assert.NotNil(t, cmd) - assert.Equal(t, []string{"run", fileName, "--source", fileName2, "--dependency", "mvn:org.my:lib:1.0"}, flags) + assert.Equal(t, []string{"run", fileName, "--source", fileName2, "--dependency", "mvn:org.my/lib:3.0"}, flags) } func TestModelineRunPropertyFiles(t *testing.T) { diff --git a/pkg/cmd/run.go b/pkg/cmd/run.go index c5faea6..6392f2e 100644 --- a/pkg/cmd/run.go +++ b/pkg/cmd/run.go @@ -299,6 +299,7 @@ func (o *runCmdOptions) run(cmd *cobra.Command, args []string) error { } } if o.Logs || o.Dev || o.Wait { + // nolint: errcheck go watch.HandleIntegrationEvents(o.Context, integration, func(event *corev1.Event) bool { fmt.Fprintln(cmd.OutOrStdout(), event.Message) return true @@ -589,6 +590,9 @@ func (o *runCmdOptions) updateIntegrationCode(c client.Client, sources []string) // Hold the resource from the operator controller clone.Status.Phase = v1.IntegrationPhaseUpdating err = c.Status().Update(o.Context, clone) + if err != nil { + return nil, err + } // Update the spec integration.ResourceVersion = clone.ResourceVersion err = c.Update(o.Context, &integration) diff --git a/pkg/util/modeline/parser_test.go b/pkg/util/modeline/parser_test.go index 0a703db..9e91c3f 100644 --- a/pkg/util/modeline/parser_test.go +++ b/pkg/util/modeline/parser_test.go @@ -1,8 +1,9 @@ package modeline import ( - "github.com/stretchr/testify/assert" "testing" + + "github.com/stretchr/testify/assert" ) func TestParseGroovyFile(t *testing.T) {