mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
* Get values from context * Move Devfile param to WatchParams and biuld adapter only once * Move pkg/devfile/adapters/kubernetes/* into pkg/dev/kubedev * Rename Push to reconcile and split in 2 parts: components and innreloop * Pass out ans errout as startOptions * Embed StartOptions into PushParameters * Embed StartOptions into WatchParameters * Fix passing startoptions * Deduplicate options (out, ...) * Revert adding unwanted files * Fix wait app ready
61 lines
2.1 KiB
Go
61 lines
2.1 KiB
Go
package kubedev
|
|
|
|
import (
|
|
"context"
|
|
|
|
devfilev1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
|
|
"github.com/devfile/library/v2/pkg/devfile/parser"
|
|
|
|
"github.com/redhat-developer/odo/pkg/component"
|
|
"github.com/redhat-developer/odo/pkg/devfile/image"
|
|
"github.com/redhat-developer/odo/pkg/exec"
|
|
"github.com/redhat-developer/odo/pkg/kclient"
|
|
odolabels "github.com/redhat-developer/odo/pkg/labels"
|
|
"github.com/redhat-developer/odo/pkg/libdevfile"
|
|
"github.com/redhat-developer/odo/pkg/remotecmd"
|
|
"github.com/redhat-developer/odo/pkg/testingutil/filesystem"
|
|
)
|
|
|
|
type runHandler struct {
|
|
fs filesystem.Filesystem
|
|
execClient exec.Client
|
|
appName string
|
|
componentName string
|
|
devfile parser.DevfileObj
|
|
kubeClient kclient.ClientInterface
|
|
path string
|
|
componentExists bool
|
|
podName string
|
|
|
|
ctx context.Context
|
|
}
|
|
|
|
var _ libdevfile.Handler = (*runHandler)(nil)
|
|
|
|
func (a *runHandler) ApplyImage(img devfilev1.Component) error {
|
|
return image.BuildPushSpecificImage(a.ctx, a.fs, img, true)
|
|
}
|
|
|
|
func (a *runHandler) ApplyKubernetes(kubernetes devfilev1.Component) error {
|
|
return component.ApplyKubernetes(odolabels.ComponentDevMode, a.appName, a.componentName, a.devfile, kubernetes, a.kubeClient, a.path)
|
|
}
|
|
|
|
func (a *runHandler) ApplyOpenShift(openshift devfilev1.Component) error {
|
|
return component.ApplyKubernetes(odolabels.ComponentDevMode, a.appName, a.componentName, a.devfile, openshift, a.kubeClient, a.path)
|
|
}
|
|
|
|
func (a *runHandler) Execute(ctx context.Context, command devfilev1.Command) error {
|
|
return component.ExecuteRunCommand(ctx, a.execClient, a.kubeClient, command, a.componentExists, a.podName, a.appName, a.componentName)
|
|
|
|
}
|
|
|
|
// IsRemoteProcessForCommandRunning returns true if the command is running
|
|
func (a *runHandler) IsRemoteProcessForCommandRunning(ctx context.Context, command devfilev1.Command, podName string) (bool, error) {
|
|
remoteProcess, err := remotecmd.NewKubeExecProcessHandler(a.execClient).GetProcessInfoForCommand(ctx, remotecmd.CommandDefinition{Id: command.Id}, podName, command.Exec.Component)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
return remoteProcess.Status == remotecmd.Running, nil
|
|
}
|