Skip to content

Commit 103068f

Browse files
authored
Merge pull request #2184 from FabianKramm/print-feat
refactor: allow env variables to pass through
2 parents d673fe7 + dbe911c commit 103068f

File tree

445 files changed

+1568
-1630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

445 files changed

+1568
-1630
lines changed

cmd/init.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"context"
66
"fmt"
77
"io/ioutil"
8+
"mvdan.cc/sh/v3/expand"
89
"os"
910
"path/filepath"
1011
"regexp"
@@ -858,7 +859,7 @@ func appendToIgnoreFile(ignoreFile, content string) error {
858859
func getProjectName() (string, string, error) {
859860
projectName := ""
860861
projectNamespace := ""
861-
gitRemote, err := command.Output(context.TODO(), "", "git", "config", "--get", "remote.origin.url")
862+
gitRemote, err := command.Output(context.TODO(), "", expand.ListEnviron(os.Environ()...), "git", "config", "--get", "remote.origin.url")
862863
if err == nil {
863864
sep := "/"
864865
projectParts := strings.Split(string(regexp.MustCompile(`^.*?://[^/]+?/([^.]+)(\.git)?`).ReplaceAll(gitRemote, []byte("$1"))), sep)

cmd/run.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package cmd
33
import (
44
"context"
55
"fmt"
6+
"github.com/loft-sh/devspace/pkg/devspace/pipeline/env"
67
"io"
8+
"mvdan.cc/sh/v3/expand"
79
"os"
810
"strings"
911

@@ -257,7 +259,7 @@ func executeShellCommand(ctx context.Context, shellCommand string, variables map
257259
}
258260

259261
// execute the command in a shell
260-
err := engine.ExecuteSimpleShellCommand(ctx, dir, stdout, stderr, stdin, extraEnv, shellCommand, args...)
262+
err := engine.ExecuteSimpleShellCommand(ctx, dir, env.NewVariableEnvProvider(expand.ListEnviron(os.Environ()...), extraEnv), stdout, stderr, stdin, shellCommand, args...)
261263
if err != nil {
262264
if status, ok := interp.IsExitStatus(err); ok {
263265
return &exit.ReturnCodeError{
@@ -292,7 +294,7 @@ func ExecuteCommand(ctx context.Context, cmd *latest.CommandConfig, variables ma
292294
}
293295

294296
// execute the command in a shell
295-
err := engine.ExecuteSimpleShellCommand(ctx, dir, stdout, stderr, stdin, extraEnv, shellCommand, args...)
297+
err := engine.ExecuteSimpleShellCommand(ctx, dir, env.NewVariableEnvProvider(expand.ListEnviron(os.Environ()...), extraEnv), stdout, stderr, stdin, shellCommand, args...)
296298
if err != nil {
297299
if status, ok := interp.IsExitStatus(err); ok {
298300
return &exit.ReturnCodeError{
@@ -307,7 +309,7 @@ func ExecuteCommand(ctx context.Context, cmd *latest.CommandConfig, variables ma
307309
}
308310

309311
shellArgs = append(shellArgs, args...)
310-
return command.CommandWithEnv(ctx, dir, stdout, stderr, stdin, extraEnv, shellCommand, shellArgs...)
312+
return command.Command(ctx, dir, env.NewVariableEnvProvider(expand.ListEnviron(os.Environ()...), extraEnv), stdout, stderr, stdin, shellCommand, shellArgs...)
311313
}
312314

313315
// RunCommandCmd holds the cmd flags of a run command

docs/pages/configuration/_partials/v2beta1/commands.mdx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import PartialCommandsreference from "./commands_reference.mdx"
77

88
## `commands` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">&lt;command_name&gt;:object</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#commands}
99

10-
Commands are custom commands that can be executed via 'devspace run COMMAND'. These commands are run within a pseudo bash
11-
that also allows executing special commands such as run_watch or is_equal.
10+
Commands are custom commands that can be executed via 'devspace run COMMAND'. These commands are run within a pseudo bash that also allows executing special commands such as run_watch or is_equal.
1211

1312
</summary>
1413

@@ -18,7 +17,7 @@ that also allows executing special commands such as run_watch or is_equal.
1817

1918
## `<command_name>` <span className="config-field-required" data-required="true">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#commands-name}
2019

21-
Name is the name of a command that is used via `devspace run NAME`
20+
Name is the name of a command that is used via 'devspace run NAME'.
2221

2322
</summary>
2423

docs/pages/configuration/_partials/v2beta1/commands/after.mdx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
### `after` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#commands-after}
66

7-
After is executed after the command was run. It is executed also when
8-
the command was interrupted which will set the env variable COMMAND_INTERRUPT
9-
to true as well as when the command errored which will set the error string to
10-
COMMAND_ERROR.
7+
After is executed after the command was run. It is executed also when the command was interrupted which will set the env variable COMMAND_INTERRUPT to true as well as when the command errored which will set the error string to COMMAND_ERROR.
118

129
</summary>
1310

docs/pages/configuration/_partials/v2beta1/commands/appendArgs.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
### `appendArgs` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">boolean</span> <span className="config-field-default">false</span> <span className="config-field-enum"></span> {#commands-appendArgs}
66

7-
AppendArgs will append arguments passed to the DevSpace command automatically to
8-
the specified command.
7+
AppendArgs will append arguments passed to the DevSpace command automatically to the specified command.
98

109
</summary>
1110

docs/pages/configuration/_partials/v2beta1/commands/args.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
### `args` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string[]</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#commands-args}
66

7-
Args are optional and if defined, command is not executed within a shell
8-
and rather directly.
7+
Args are optional and if defined, command is not executed within a shell and rather directly.
98

109
</summary>
1110

docs/pages/configuration/_partials/v2beta1/commands/command.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### `command` <span className="config-field-required" data-required="true">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#commands-command}
66

7-
Command is the command that should be executed. For example: 'echo 123'
7+
Command is the command that should be executed. For example: 'echo 123'.
88

99
</summary>
1010

docs/pages/configuration/_partials/v2beta1/commands/description.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### `description` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#commands-description}
66

7-
Description describes what the command is doing and can be seen in `devspace list commands`
7+
Description describes what the command is doing and can be seen in 'devspace list commands'.
88

99
</summary>
1010

docs/pages/configuration/_partials/v2beta1/commands/internal.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### `internal` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">boolean</span> <span className="config-field-default">false</span> <span className="config-field-enum"></span> {#commands-internal}
66

7-
Internal commands are not show in list and are usable through run_command
7+
Internal commands are not show in list and are usable through run_command.
88

99
</summary>
1010

docs/pages/configuration/_partials/v2beta1/commands/section.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### `section` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#commands-section}
66

7-
Section can be used to group similar commands together in `devspace list commands`
7+
Section can be used to group similar commands together in 'devspace list commands'.
88

99
</summary>
1010

0 commit comments

Comments
 (0)