Skip to content

Commit 852077f

Browse files
committed
Review
1 parent 8c6f335 commit 852077f

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

pkg/dev/common/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func Run(
3030

3131
pod, err := platformClient.GetPodUsingComponentName(componentName)
3232
if err != nil {
33-
return fmt.Errorf("unable to get pod for component %s: %w. Please check the command odo dev is running", componentName, err)
33+
return fmt.Errorf("unable to get pod for component %s: %w. Please check the command 'odo dev' is running", componentName, err)
3434
}
3535

3636
handler := component.NewRunHandler(

pkg/dev/podmandev/run.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func (o *DevClient) Run(
1111
ctx context.Context,
1212
commandName string,
1313
) error {
14-
klog.V(4).Infof("running command %q on cluster", commandName)
14+
klog.V(4).Infof("running command %q on podman", commandName)
1515
return common.Run(
1616
ctx,
1717
commandName,

pkg/libdevfile/libdevfile.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ func ExecuteCommandByNameAndKind(ctx context.Context, devfileObj parser.DevfileO
6666
return executeCommand(ctx, devfileObj, cmd, handler)
6767
}
6868

69-
// ExecuteCommandByNameAndKind executes the specified command cmdName of the given kind in the Devfile.
70-
// If cmdName is empty, it executes the default command for the given kind or returns an error if there is no default command.
69+
// ExecuteCommandByName executes the specified command cmdName in the Devfile.
7170
// If ignoreCommandNotFound is true, nothing is executed if the command is not found and no error is returned.
7271
func ExecuteCommandByName(ctx context.Context, devfileObj parser.DevfileObj, cmdName string, handler Handler, ignoreCommandNotFound bool) error {
7372
commands, err := devfileObj.Data.GetCommands(

pkg/odo/cli/run/run.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ func (o *RunOptions) Validate(ctx context.Context) error {
6868
commands, err := devfileObj.Data.GetCommands(common.DevfileOptions{
6969
FilterByName: o.commandName,
7070
})
71-
if err != nil || len(commands) != 1 {
71+
if err != nil {
72+
return err
73+
}
74+
if len(commands) != 1 {
7275
return errors.NewNoCommandNameInDevfileError(o.commandName)
7376
}
7477

tests/examples/source/devfiles/nodejs/devfile-for-run.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ components:
1717
- name: "3000-tcp"
1818
targetPort: 3000
1919
mountSources: true
20+
- name: other-container
21+
container:
22+
image: registry.access.redhat.com/ubi8/nodejs-12:1-36
23+
command: ["tail"]
24+
args: ["-f", "/dev/null"]
25+
memoryLimit: 1024Mi
2026
- name: config
2127
kubernetes:
2228
inlined: |
@@ -67,6 +73,11 @@ commands:
6773
component: runtime
6874
commandLine: touch /tmp/new-file
6975
workingDir: ${PROJECTS_ROOT}
76+
- id: create-file-in-other-container
77+
exec:
78+
component: other-container
79+
commandLine: touch /tmp/new-file-in-other-container
80+
workingDir: ${PROJECTS_ROOT}
7081
- id: deploy-config
7182
apply:
7283
component: config

tests/integration/cmd_run_test.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ var _ = Describe("odo run command tests", func() {
7373
It("should fail if odo dev is not running", func() {
7474
output := helper.Cmd("odo", "run", "build").ShouldFail().Err()
7575
Expect(output).To(ContainSubstring(`unable to get pod for component`))
76-
Expect(output).To(ContainSubstring(`Please check the command odo dev is running`))
76+
Expect(output).To(ContainSubstring(`Please check the command 'odo dev' is running`))
7777
})
7878

7979
for _, podman := range []bool{false, true} {
@@ -108,6 +108,13 @@ var _ = Describe("odo run command tests", func() {
108108
component.Exec("runtime", []string{"ls", "/tmp/new-file"}, pointer.Bool(true))
109109
})
110110

111+
By("executing an exec command in another container", func() {
112+
output := helper.Cmd("odo", "run", "create-file-in-other-container", "--platform", platform).ShouldPass().Out()
113+
Expect(output).To(ContainSubstring("Executing command in container (command: create-file-in-other-container)"))
114+
component := helper.NewComponent(cmpName, "app", labels.ComponentDevMode, commonVar.Project, commonVar.CliRunner)
115+
component.Exec("other-container", []string{"ls", "/tmp/new-file-in-other-container"}, pointer.Bool(true))
116+
})
117+
111118
if !podman {
112119
By("executing apply command on Kubernetes component", func() {
113120
output := helper.Cmd("odo", "run", "deploy-config", "--platform", platform).ShouldPass().Out()

0 commit comments

Comments
 (0)