-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…#6857) * Add a run command * Check command name passed as arg * Check platform is available * Add a Run method to the DevClient * Run command on cluster * Add test with run command on cluster * Implement and test run on podman * Enhance test to check that command has been executed in container * Fix `odo help` test * Refactor common code for podman/cluster * Test Apply commands on Kubernetes/Images * Test a msg is displayed when executing odo run without odo dev * Review * makes GetRunningPodFromSelector return only Running pods on Podman
- Loading branch information
Showing
22 changed files
with
574 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package common | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/redhat-developer/odo/pkg/component" | ||
"github.com/redhat-developer/odo/pkg/configAutomount" | ||
"github.com/redhat-developer/odo/pkg/devfile/image" | ||
"github.com/redhat-developer/odo/pkg/exec" | ||
"github.com/redhat-developer/odo/pkg/libdevfile" | ||
odocontext "github.com/redhat-developer/odo/pkg/odo/context" | ||
"github.com/redhat-developer/odo/pkg/platform" | ||
"github.com/redhat-developer/odo/pkg/testingutil/filesystem" | ||
) | ||
|
||
func Run( | ||
ctx context.Context, | ||
commandName string, | ||
platformClient platform.Client, | ||
execClient exec.Client, | ||
configAutomountClient configAutomount.Client, | ||
filesystem filesystem.Filesystem, | ||
) error { | ||
var ( | ||
componentName = odocontext.GetComponentName(ctx) | ||
devfileObj = odocontext.GetEffectiveDevfileObj(ctx) | ||
devfilePath = odocontext.GetDevfilePath(ctx) | ||
) | ||
|
||
pod, err := platformClient.GetPodUsingComponentName(componentName) | ||
if err != nil { | ||
return fmt.Errorf("unable to get pod for component %s: %w. Please check the command 'odo dev' is running", componentName, err) | ||
} | ||
|
||
handler := component.NewRunHandler( | ||
ctx, | ||
platformClient, | ||
execClient, | ||
configAutomountClient, | ||
pod.Name, | ||
false, | ||
component.GetContainersNames(pod), | ||
"Executing command in container", | ||
|
||
filesystem, | ||
image.SelectBackend(ctx), | ||
*devfileObj, | ||
devfilePath, | ||
) | ||
|
||
return libdevfile.ExecuteCommandByName(ctx, *devfileObj, commandName, handler, false) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package kubedev | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/redhat-developer/odo/pkg/dev/common" | ||
"k8s.io/klog" | ||
) | ||
|
||
func (o *DevClient) Run( | ||
ctx context.Context, | ||
commandName string, | ||
) error { | ||
klog.V(4).Infof("running command %q on cluster", commandName) | ||
return common.Run( | ||
ctx, | ||
commandName, | ||
o.kubernetesClient, | ||
o.execClient, | ||
o.configAutomountClient, | ||
o.filesystem, | ||
) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package podmandev | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/redhat-developer/odo/pkg/dev/common" | ||
"k8s.io/klog" | ||
) | ||
|
||
func (o *DevClient) Run( | ||
ctx context.Context, | ||
commandName string, | ||
) error { | ||
klog.V(4).Infof("running command %q on podman", commandName) | ||
return common.Run( | ||
ctx, | ||
commandName, | ||
o.podmanClient, | ||
o.execClient, | ||
nil, // TODO(feloy) set when running on new container is supported on podman | ||
o.fs, | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.