Skip to content

Commit b0a590f

Browse files
committed
refactor: use single shell implementation
1 parent 33e7e6d commit b0a590f

File tree

28 files changed

+173
-357
lines changed

28 files changed

+173
-357
lines changed

pkg/devspace/build/builder/custom/custom.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/runtime"
66
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
7-
"github.com/loft-sh/devspace/pkg/util/shell"
7+
"github.com/loft-sh/devspace/pkg/devspace/pipeline/engine"
88
"github.com/sirupsen/logrus"
99
"io"
1010
"strings"
@@ -163,7 +163,7 @@ func (b *Builder) Build(ctx *devspacecontext.Context) error {
163163

164164
ctx.Log.Infof("Build %s:%s with custom command '%s %s'", b.imageConf.Image, b.imageTags[0], commandPath, strings.Join(args, " "))
165165
if len(args) == 0 {
166-
err = shell.ExecuteShellCommand(ctx.Context, ctx.WorkingDir, writer, writer, nil, nil, commandPath, args...)
166+
err = engine.ExecuteSimpleShellCommand(ctx.Context, ctx.WorkingDir, writer, writer, nil, nil, commandPath, args...)
167167
if err != nil {
168168
return errors.Errorf("error building image: %v", err)
169169
}

pkg/devspace/command/command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ package command
22

33
import (
44
"context"
5+
"github.com/loft-sh/devspace/pkg/devspace/pipeline/engine"
56
"io"
67
"strings"
78

89
"github.com/loft-sh/devspace/pkg/util/command"
9-
"github.com/loft-sh/devspace/pkg/util/shell"
1010

1111
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
1212

@@ -42,7 +42,7 @@ func ExecuteCommand(ctx context.Context, commands map[string]*latest.CommandConf
4242
}
4343

4444
// execute the command in a shell
45-
return shell.ExecuteShellCommand(ctx, dir, stdout, stderr, stdin, nil, shellCommand, args...)
45+
return engine.ExecuteSimpleShellCommand(ctx, dir, stdout, stderr, stdin, nil, shellCommand, args...)
4646
}
4747

4848
shellArgs = append(shellArgs, args...)

pkg/devspace/config/loader/variable/command_variable.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ package variable
33
import (
44
"bytes"
55
"context"
6+
"github.com/loft-sh/devspace/pkg/devspace/pipeline/engine"
67
"strings"
78

89
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
910
"github.com/loft-sh/devspace/pkg/util/command"
10-
"github.com/loft-sh/devspace/pkg/util/shell"
1111
"github.com/pkg/errors"
1212
)
1313

@@ -52,7 +52,7 @@ func execCommand(ctx context.Context, varName string, definition *latest.Variabl
5252
stdErrWriter := &bytes.Buffer{}
5353
var err error
5454
if args == nil {
55-
err = shell.ExecuteShellCommand(ctx, dir, writer, stdErrWriter, nil, nil, cmd)
55+
err = engine.ExecuteSimpleShellCommand(ctx, dir, writer, stdErrWriter, nil, nil, cmd)
5656
} else {
5757
err = command.Command(ctx, dir, writer, stdErrWriter, nil, cmd, args...)
5858
}

pkg/devspace/config/loader/variable/expression/expression.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import (
44
"bytes"
55
"context"
66
"fmt"
7+
"github.com/loft-sh/devspace/pkg/devspace/pipeline/engine"
78
"os"
89
"regexp"
910
"strconv"
1011
"strings"
1112

1213
"github.com/loft-sh/devspace/pkg/devspace/deploy/deployer/kubectl/walk"
13-
"github.com/loft-sh/devspace/pkg/util/shell"
1414
"gopkg.in/yaml.v3"
1515
)
1616

@@ -77,7 +77,7 @@ func ResolveExpressions(ctx context.Context, value, dir string) (interface{}, er
7777

7878
stdout := &bytes.Buffer{}
7979
stderr := &bytes.Buffer{}
80-
err := shell.ExecuteShellCommand(ctx, dir, stdout, stderr, nil, nil, match[1], os.Args[1:]...)
80+
err := engine.ExecuteSimpleShellCommand(ctx, dir, stdout, stderr, nil, nil, match[1], os.Args[1:]...)
8181
if err != nil {
8282
return nil, fmt.Errorf("error executing config expression %s: %v (stdout: %s, stderr: %s)", match[1], err, stdout.String(), stderr.String())
8383
}

pkg/devspace/configure/deployment.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"github.com/loft-sh/devspace/pkg/devspace/pipeline/engine"
78
"github.com/sirupsen/logrus"
89
"net/http"
910
"os"
@@ -13,7 +14,6 @@ import (
1314

1415
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
1516
"github.com/loft-sh/devspace/pkg/util/ptr"
16-
"github.com/loft-sh/devspace/pkg/util/shell"
1717
"github.com/loft-sh/devspace/pkg/util/survey"
1818
"github.com/loft-sh/devspace/pkg/util/yamlutil"
1919
)
@@ -262,7 +262,7 @@ func (m *manager) AddHelmDeployment(deploymentName string) error {
262262
m.log.WriteString(logrus.InfoLevel, "\n")
263263
m.log.Infof("Cloning external repo `%s` containing to retrieve Helm chart", gitRepo)
264264

265-
err = shell.ExecuteShellCommand(context.TODO(), "", os.Stdout, os.Stderr, nil, nil, gitCommand)
265+
err = engine.ExecuteSimpleShellCommand(context.TODO(), "", os.Stdout, os.Stderr, nil, nil, gitCommand)
266266
if err != nil {
267267
m.log.WriteString(logrus.InfoLevel, "\n")
268268
m.log.Errorf("Unable to clone repository `%s` (branch: %s)", gitRepo, gitBranch)

pkg/devspace/hook/local_command.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"encoding/json"
77
runtimevar "github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/runtime"
88
devspacecontext "github.com/loft-sh/devspace/pkg/devspace/context"
9+
"github.com/loft-sh/devspace/pkg/devspace/pipeline/engine"
910
"io"
1011
"os"
1112
"strings"
@@ -14,7 +15,6 @@ import (
1415
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
1516
"github.com/loft-sh/devspace/pkg/devspace/dependency/types"
1617
"github.com/loft-sh/devspace/pkg/util/command"
17-
"github.com/loft-sh/devspace/pkg/util/shell"
1818
"github.com/pkg/errors"
1919
)
2020

@@ -64,7 +64,7 @@ func (l *localCommandHook) Execute(ctx *devspacecontext.Context, hook *latest.Ho
6464
}()
6565

6666
if hook.Args == nil {
67-
return shell.ExecuteShellCommand(ctx.Context, ctx.WorkingDir, io.MultiWriter(l.Stdout, stdout), io.MultiWriter(l.Stderr, stderr), nil, extraEnv, hookCommand)
67+
return engine.ExecuteSimpleShellCommand(ctx.Context, ctx.WorkingDir, io.MultiWriter(l.Stdout, stdout), io.MultiWriter(l.Stderr, stderr), nil, extraEnv, hookCommand)
6868
}
6969

7070
// else we execute it directly
File renamed without changes.

pkg/devspace/pipeline/engine/commands/cat_test.go renamed to pkg/devspace/pipeline/engine/basichandler/commands/cat_test.go

File renamed without changes.

pkg/devspace/pipeline/engine/commands/is_command.go renamed to pkg/devspace/pipeline/engine/basichandler/commands/is_command.go

File renamed without changes.

pkg/devspace/pipeline/engine/commands/is_equal.go renamed to pkg/devspace/pipeline/engine/basichandler/commands/is_equal.go

File renamed without changes.

0 commit comments

Comments
 (0)