Skip to content

Commit 18ebc5a

Browse files
committed
Move handler to pkg/component package
1 parent 4ca7421 commit 18ebc5a

File tree

7 files changed

+18
-20
lines changed

7 files changed

+18
-20
lines changed

pkg/component/delete/delete.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616

1717
"github.com/redhat-developer/odo/pkg/component"
1818
"github.com/redhat-developer/odo/pkg/configAutomount"
19-
"github.com/redhat-developer/odo/pkg/dev/common"
2019
"github.com/redhat-developer/odo/pkg/exec"
2120
"github.com/redhat-developer/odo/pkg/kclient"
2221
odolabels "github.com/redhat-developer/odo/pkg/labels"
@@ -221,7 +220,7 @@ func (do *DeleteComponentClient) ExecutePreStopEvents(ctx context.Context, devfi
221220

222221
klog.V(4).Infof("Executing %q event commands for component %q", libdevfile.PreStop, componentName)
223222
// ignore the failures if any; delete should not fail because preStop events failed to execute
224-
handler := common.NewRunHandler(
223+
handler := component.NewRunHandler(
225224
ctx,
226225
do.kubeClient,
227226
do.execClient,

pkg/dev/common/exec_handler_test.go renamed to pkg/component/exec_handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package common
1+
package component
22

33
/*
44
var (

pkg/dev/common/handler.go renamed to pkg/component/handler.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package common
1+
package component
22

33
import (
44
"context"
@@ -8,7 +8,6 @@ import (
88
"github.com/devfile/library/v2/pkg/devfile/parser"
99
"k8s.io/klog"
1010

11-
"github.com/redhat-developer/odo/pkg/component"
1211
envcontext "github.com/redhat-developer/odo/pkg/config/context"
1312
"github.com/redhat-developer/odo/pkg/configAutomount"
1413
"github.com/redhat-developer/odo/pkg/devfile/image"
@@ -94,7 +93,7 @@ func (a *runHandler) ApplyKubernetes(kubernetes devfilev1.Component, kind v1alph
9493
}
9594
switch platform := a.platformClient.(type) {
9695
case kclient.ClientInterface:
97-
return component.ApplyKubernetes(mode, appName, componentName, a.devfile, kubernetes, platform, a.path)
96+
return ApplyKubernetes(mode, appName, componentName, a.devfile, kubernetes, platform, a.path)
9897
default:
9998
klog.V(4).Info("apply kubernetes commands are not implemented on podman")
10099
log.Warningf("Apply Kubernetes components are not supported on Podman. Skipping: %v.", kubernetes.Name)
@@ -113,7 +112,7 @@ func (a *runHandler) ApplyOpenShift(openshift devfilev1.Component, kind v1alpha2
113112
}
114113
switch platform := a.platformClient.(type) {
115114
case kclient.ClientInterface:
116-
return component.ApplyKubernetes(mode, appName, componentName, a.devfile, openshift, platform, a.path)
115+
return ApplyKubernetes(mode, appName, componentName, a.devfile, openshift, platform, a.path)
117116
default:
118117
klog.V(4).Info("apply OpenShift commands are not implemented on podman")
119118
log.Warningf("Apply OpenShift components are not supported on Podman. Skipping: %v.", openshift.Name)
@@ -127,11 +126,11 @@ func (a *runHandler) ExecuteNonTerminatingCommand(ctx context.Context, command d
127126
appName = odocontext.GetApplication(a.ctx)
128127
)
129128
if isContainerRunning(command.Exec.Component, a.containersRunning) {
130-
return component.ExecuteRunCommand(ctx, a.execClient, a.platformClient, command, a.ComponentExists, a.podName, appName, componentName)
129+
return ExecuteRunCommand(ctx, a.execClient, a.platformClient, command, a.ComponentExists, a.podName, appName, componentName)
131130
}
132131
switch platform := a.platformClient.(type) {
133132
case kclient.ClientInterface:
134-
return component.ExecuteInNewContainer(ctx, platform, a.configAutomountClient, a.devfile, componentName, appName, command)
133+
return ExecuteInNewContainer(ctx, platform, a.configAutomountClient, a.devfile, componentName, appName, command)
135134
default:
136135
klog.V(4).Info("executing a command in a new container is not implemented on podman")
137136
log.Warningf("executing a command in a new container is not implemented on podman. Skipping: %v.", command.Id)
@@ -145,11 +144,11 @@ func (a *runHandler) ExecuteTerminatingCommand(ctx context.Context, command devf
145144
appName = odocontext.GetApplication(a.ctx)
146145
)
147146
if isContainerRunning(command.Exec.Component, a.containersRunning) {
148-
return component.ExecuteTerminatingCommand(ctx, a.execClient, a.platformClient, command, a.ComponentExists, a.podName, appName, componentName, a.msg, false)
147+
return ExecuteTerminatingCommand(ctx, a.execClient, a.platformClient, command, a.ComponentExists, a.podName, appName, componentName, a.msg, false)
149148
}
150149
switch platform := a.platformClient.(type) {
151150
case kclient.ClientInterface:
152-
return component.ExecuteInNewContainer(ctx, platform, a.configAutomountClient, a.devfile, componentName, appName, command)
151+
return ExecuteInNewContainer(ctx, platform, a.configAutomountClient, a.devfile, componentName, appName, command)
153152
default:
154153
klog.V(4).Info("executing a command in a new container is not implemented on podman")
155154
log.Warningf("executing a command in a new container is not implemented on podman. Skipping: %v.", command.Id)

pkg/dev/common/handler_test.go renamed to pkg/component/handler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package common
1+
package component
22

33
import (
44
"context"

pkg/deploy/deploy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
88
"github.com/devfile/library/v2/pkg/devfile/parser"
99

10+
"github.com/redhat-developer/odo/pkg/component"
1011
"github.com/redhat-developer/odo/pkg/configAutomount"
11-
"github.com/redhat-developer/odo/pkg/dev/common"
1212
"github.com/redhat-developer/odo/pkg/devfile/image"
1313
"github.com/redhat-developer/odo/pkg/kclient"
1414
"github.com/redhat-developer/odo/pkg/libdevfile"
@@ -39,7 +39,7 @@ func (o *DeployClient) Deploy(ctx context.Context) error {
3939
path = filepath.Dir(devfilePath)
4040
)
4141

42-
handler := common.NewRunHandler(
42+
handler := component.NewRunHandler(
4343
ctx,
4444
o.kubeClient,
4545
nil,

pkg/dev/kubedev/innerloop.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (o *DevClient) innerloop(ctx context.Context, parameters common.PushParamet
9090
if !componentStatus.PostStartEventsDone && libdevfile.HasPostStartEvents(parameters.Devfile) {
9191
// PostStart events from the devfile will only be executed when the component
9292
// didn't previously exist
93-
handler := common.NewRunHandler(
93+
handler := component.NewRunHandler(
9494
ctx,
9595
o.kubernetesClient,
9696
o.execClient,
@@ -122,7 +122,7 @@ func (o *DevClient) innerloop(ctx context.Context, parameters common.PushParamet
122122
var running bool
123123
var isComposite bool
124124

125-
cmdHandler := common.NewRunHandler(
125+
cmdHandler := component.NewRunHandler(
126126
ctx,
127127
o.kubernetesClient,
128128
o.execClient,
@@ -161,7 +161,7 @@ func (o *DevClient) innerloop(ctx context.Context, parameters common.PushParamet
161161
// Invoke the build command once (before calling libdevfile.ExecuteCommandByNameAndKind), as, if cmd is a composite command,
162162
// the handler we pass will be called for each command in that composite command.
163163
doExecuteBuildCommand := func() error {
164-
execHandler := common.NewRunHandler(
164+
execHandler := component.NewRunHandler(
165165
ctx,
166166
o.kubernetesClient,
167167
o.execClient,

pkg/dev/podmandev/reconcile.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (o *DevClient) reconcile(
6464
// PostStart events from the devfile will only be executed when the component
6565
// didn't previously exist
6666
if !componentStatus.PostStartEventsDone && libdevfile.HasPostStartEvents(devfileObj) {
67-
execHandler := common.NewRunHandler(
67+
execHandler := component.NewRunHandler(
6868
ctx,
6969
o.podmanClient,
7070
o.execClient,
@@ -86,7 +86,7 @@ func (o *DevClient) reconcile(
8686

8787
if execRequired {
8888
doExecuteBuildCommand := func() error {
89-
execHandler := common.NewRunHandler(
89+
execHandler := component.NewRunHandler(
9090
ctx,
9191
o.podmanClient,
9292
o.execClient,
@@ -114,7 +114,7 @@ func (o *DevClient) reconcile(
114114
cmdName = options.DebugCommand
115115
}
116116

117-
cmdHandler := common.NewRunHandler(
117+
cmdHandler := component.NewRunHandler(
118118
ctx,
119119
o.podmanClient,
120120
o.execClient,

0 commit comments

Comments
 (0)