Skip to content

Commit

Permalink
Fix #1449: fix lint and typos
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaferraro committed May 8, 2020
1 parent 0478b50 commit 852231f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/cli/modeline.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
...
----

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/modeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions pkg/cmd/modeline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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)
Expand All @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion pkg/util/modeline/parser_test.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package modeline

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/assert"
)

func TestParseGroovyFile(t *testing.T) {
Expand Down

0 comments on commit 852231f

Please sign in to comment.