Skip to content

Commit

Permalink
Merge pull request #2184 from FabianKramm/print-feat
Browse files Browse the repository at this point in the history
refactor: allow env variables to pass through
  • Loading branch information
FabianKramm authored Jul 20, 2022
2 parents d673fe7 + dbe911c commit 103068f
Show file tree
Hide file tree
Showing 445 changed files with 1,568 additions and 1,630 deletions.
3 changes: 2 additions & 1 deletion cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"io/ioutil"
"mvdan.cc/sh/v3/expand"
"os"
"path/filepath"
"regexp"
Expand Down Expand Up @@ -858,7 +859,7 @@ func appendToIgnoreFile(ignoreFile, content string) error {
func getProjectName() (string, string, error) {
projectName := ""
projectNamespace := ""
gitRemote, err := command.Output(context.TODO(), "", "git", "config", "--get", "remote.origin.url")
gitRemote, err := command.Output(context.TODO(), "", expand.ListEnviron(os.Environ()...), "git", "config", "--get", "remote.origin.url")
if err == nil {
sep := "/"
projectParts := strings.Split(string(regexp.MustCompile(`^.*?://[^/]+?/([^.]+)(\.git)?`).ReplaceAll(gitRemote, []byte("$1"))), sep)
Expand Down
8 changes: 5 additions & 3 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package cmd
import (
"context"
"fmt"
"github.com/loft-sh/devspace/pkg/devspace/pipeline/env"
"io"
"mvdan.cc/sh/v3/expand"
"os"
"strings"

Expand Down Expand Up @@ -257,7 +259,7 @@ func executeShellCommand(ctx context.Context, shellCommand string, variables map
}

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

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

shellArgs = append(shellArgs, args...)
return command.CommandWithEnv(ctx, dir, stdout, stderr, stdin, extraEnv, shellCommand, shellArgs...)
return command.Command(ctx, dir, env.NewVariableEnvProvider(expand.ListEnviron(os.Environ()...), extraEnv), stdout, stderr, stdin, shellCommand, shellArgs...)
}

// RunCommandCmd holds the cmd flags of a run command
Expand Down
5 changes: 2 additions & 3 deletions docs/pages/configuration/_partials/v2beta1/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import PartialCommandsreference from "./commands_reference.mdx"

## `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}

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.
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.

</summary>

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

## `<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}

Name is the name of a command that is used via `devspace run NAME`
Name is the name of a command that is used via 'devspace run NAME'.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

### `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}

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.
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.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

### `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}

AppendArgs will append arguments passed to the DevSpace command automatically to
the specified command.
AppendArgs will append arguments passed to the DevSpace command automatically to the specified command.

</summary>

Expand Down
3 changes: 1 addition & 2 deletions docs/pages/configuration/_partials/v2beta1/commands/args.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

### `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}

Args are optional and if defined, command is not executed within a shell
and rather directly.
Args are optional and if defined, command is not executed within a shell and rather directly.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `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}

Command is the command that should be executed. For example: 'echo 123'
Command is the command that should be executed. For example: 'echo 123'.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `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}

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

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `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}

Internal commands are not show in list and are usable through run_command
Internal commands are not show in list and are usable through run_command.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `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}

Section can be used to group similar commands together in `devspace list commands`
Section can be used to group similar commands together in 'devspace list commands'.

</summary>

Expand Down
8 changes: 2 additions & 6 deletions docs/pages/configuration/_partials/v2beta1/dependencies.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import PartialDependenciesreference from "./dependencies_reference.mdx"

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

Dependencies are sub devspace projects that lie in a local folder or remote git repository that can be executed
from within the pipeline. In contrast to imports, these projects pose as separate fully functional DevSpace projects
that typically lie including source code in a different folder and can be used to compose a full microservice
application that will be deployed by DevSpace. Each dependency name can only be used once and if you want to use
the same project multiple times, make sure to use a different name for each of those instances.
Dependencies are sub devspace projects that lie in a local folder or remote git repository that can be executed from within the pipeline.

</summary>

Expand All @@ -21,7 +17,7 @@ the same project multiple times, make sure to use a different name for each of t

## `<dependency_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> {#dependencies-name}

Name is used internally
Name is used internally.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `branch` <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> {#dependencies-branch}

Branch is the git branch to pull
Branch is the git branch to pull.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `cloneArgs` <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> {#dependencies-cloneArgs}

CloneArgs are additional arguments that should be supplied to the git CLI
CloneArgs are additional arguments that should be supplied to the git CLI.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `disablePull` <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> {#dependencies-disablePull}

DisablePull will disable pulling every time DevSpace is reevaluating this source
DisablePull will disable pulling every time DevSpace is reevaluating this source.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

### `disableShallow` <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> {#dependencies-disableShallow}

DisableShallow can be used to turn off shallow clones as these are the default used
by devspace
DisableShallow can be used to turn off shallow clones as these are the default used by devspace.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

### `git` <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> {#dependencies-git}

Git is the remote repository to download the artifact from. You can either use
https projects or ssh projects here, but need to make sure git can pull the project.
This option is mutually exclusive with the path option.
Git is the remote repository to download the artifact from. You can either use https projects or ssh projects here, but need to make sure git can pull the project. This option is mutually exclusive with the path option.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `ignoreDependencies` <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> {#dependencies-ignoreDependencies}

IgnoreDependencies defines if dependencies of the dependency should be excluded
IgnoreDependencies defines if dependencies of the dependency should be excluded.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `namespace` <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> {#dependencies-namespace}

Namespace specifies the namespace this dependency should be deployed to
Namespace specifies the namespace this dependency should be deployed to.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `overwriteVars` <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> {#dependencies-overwriteVars}

OverwriteVars specifies if DevSpace should pass the parent variables to the dependency
OverwriteVars specifies if DevSpace should pass the parent variables to the dependency.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

### `path` <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> {#dependencies-path}

Path is the local path where DevSpace can find the artifact.
This option is mutually exclusive with the path option.
Path is the local path where DevSpace can find the artifact. This option is mutually exclusive with the git option.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `pipeline` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">string</span> <span className="config-field-default">deploy</span> <span className="config-field-enum"></span> {#dependencies-pipeline}

Pipeline is the pipeline to deploy by default. Defaults to 'deploy'
Pipeline is the pipeline to deploy by default. Defaults to 'deploy'.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `revision` <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> {#dependencies-revision}

Revision is the git revision to pull
Revision is the git revision to pull.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `subPath` <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> {#dependencies-subPath}

SubPath is a path within the git repository where the artifact lies in
SubPath is a path within the git repository where the artifact lies in.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `tag` <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> {#dependencies-tag}

Tag is the tag to pull
Tag is the tag to pull.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### `vars` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">&lt;var_name&gt;:string</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#dependencies-vars}

Vars are variables that should be passed to the dependency
Vars are variables that should be passed to the dependency.

</summary>

Expand Down
4 changes: 1 addition & 3 deletions docs/pages/configuration/_partials/v2beta1/deployments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import PartialDeploymentsreference from "./deployments_reference.mdx"
## `deployments` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type">&lt;deployment_name&gt;:object</span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#deployments}

Deployments holds configuration of how DevSpace should deploy resources to Kubernetes. By default, DevSpace will deploy all defined deployments.
If you are using a custom pipeline, you can dynamically define which deployment is deployed at which time during the
execution.

</summary>

Expand All @@ -19,7 +17,7 @@ execution.

## `<deployment_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> {#deployments-name}

Name of the deployment
Name of the deployment.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PartialHelmreference from "./helm_reference.mdx"

### `helm` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type"></span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#deployments-helm}

Helm tells DevSpace to deploy this deployment via helm
Helm tells DevSpace to deploy this deployment via helm.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PartialChartreference from "./chart_reference.mdx"

#### `chart` <span className="config-field-required" data-required="false">required</span> <span className="config-field-type"></span> <span className="config-field-default"></span> <span className="config-field-enum"></span> {#deployments-helm-chart}

Chart holds the chart configuration and where DevSpace can find the chart
Chart holds the chart configuration and where DevSpace can find the chart.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

##### `branch` <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> {#deployments-helm-chart-branch}

Branch is the git branch to pull
Branch is the git branch to pull.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

##### `cloneArgs` <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> {#deployments-helm-chart-cloneArgs}

CloneArgs are additional arguments that should be supplied to the git CLI
CloneArgs are additional arguments that should be supplied to the git CLI.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

##### `disablePull` <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> {#deployments-helm-chart-disablePull}

DisablePull will disable pulling every time DevSpace is reevaluating this source
DisablePull will disable pulling every time DevSpace is reevaluating this source.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@

##### `disableShallow` <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> {#deployments-helm-chart-disableShallow}

DisableShallow can be used to turn off shallow clones as these are the default used
by devspace
DisableShallow can be used to turn off shallow clones as these are the default used by devspace.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

##### `git` <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> {#deployments-helm-chart-git}

Git is the remote repository to download the artifact from. You can either use
https projects or ssh projects here, but need to make sure git can pull the project.
This option is mutually exclusive with the path option.
Git is the remote repository to download the artifact from. You can either use https projects or ssh projects here, but need to make sure git can pull the project. This option is mutually exclusive with the path option.

</summary>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

##### `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> {#deployments-helm-chart-name}

Name is the name of the helm chart to deploy. Can also be a local path
Name is the name of the helm chart to deploy. Can also be a local path.

</summary>

Expand Down
Loading

0 comments on commit 103068f

Please sign in to comment.