Skip to content

Commit 49a16a2

Browse files
authored
Merge pull request #1812 from FabianKramm/master
runtime variables
2 parents e539ff4 + 99fc3e6 commit 49a16a2

File tree

374 files changed

+5835
-4253
lines changed

Some content is hidden

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

374 files changed

+5835
-4253
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ images:
613613
context: ./db # Build with --context=./db
614614
# The following lines define custom tag schemata for this image
615615
tags:
616-
- devspace-${DEVSPACE_GIT_COMMIT}-######
616+
- devspace-${devspace.git.commit}-######
617617
```
618618
Take a look at the documentation for more information about [configuring builds with Docker](https://devspace.sh/cli/docs/configuration/images/docker). <img src="static/img/line.svg" height="1">
619619

@@ -886,7 +886,7 @@ images:
886886
default:
887887
image: john/image-name
888888
tags:
889-
- ${DEVSPACE_GIT_COMMIT}-${DEVSPACE_TIMESTAMP}
889+
- ${devspace.git.commit}-${devspace.timestamp}
890890
- latest
891891
```
892892

cmd/attach.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ devspace attach -n my-namespace
5151

5252
attachCmd.Flags().StringVarP(&cmd.Container, "container", "c", "", "Container name within pod where to execute command")
5353
attachCmd.Flags().StringVar(&cmd.Pod, "pod", "", "Pod to open a shell to")
54-
attachCmd.Flags().StringVar(&cmd.ImageSelector, "image-selector", "", "The image to search a pod for (e.g. nginx, nginx:latest, image(app), nginx:tag(app))")
54+
attachCmd.Flags().StringVar(&cmd.ImageSelector, "image-selector", "", "The image to search a pod for (e.g. nginx, nginx:latest, ${runtime.images.app}, nginx:${runtime.images.app.tag})")
5555
attachCmd.Flags().StringVar(&cmd.Image, "image", "", "Image is the config name of an image to select in the devspace config (e.g. 'default'), it is NOT a docker image like myuser/myimage")
5656
attachCmd.Flags().StringVarP(&cmd.LabelSelector, "label-selector", "l", "", "Comma separated key=value selector list (e.g. release=test)")
5757

cmd/dev.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package cmd
22

33
import (
44
"fmt"
5+
runtimevar "github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/runtime"
6+
"github.com/loft-sh/devspace/pkg/devspace/imageselector"
57
"io"
68
"os"
79
"strings"
@@ -11,11 +13,9 @@ import (
1113
"github.com/loft-sh/devspace/pkg/devspace/config"
1214
"github.com/loft-sh/devspace/pkg/devspace/config/legacy"
1315
"github.com/loft-sh/devspace/pkg/devspace/dependency/types"
14-
"github.com/loft-sh/devspace/pkg/devspace/deploy/deployer/util"
1516
"github.com/loft-sh/devspace/pkg/devspace/dev"
1617
"github.com/loft-sh/devspace/pkg/devspace/docker"
1718
"github.com/loft-sh/devspace/pkg/devspace/hook"
18-
"github.com/loft-sh/devspace/pkg/util/imageselector"
1919
"github.com/loft-sh/devspace/pkg/util/interrupt"
2020
"github.com/loft-sh/devspace/pkg/util/survey"
2121

@@ -607,7 +607,7 @@ func (cmd *DevCmd) startOutput(configInterface config.Config, dependencies []typ
607607

608608
var imageSelectors []imageselector.ImageSelector
609609
if config.Dev.Terminal != nil && config.Dev.Terminal.ImageSelector != "" {
610-
imageSelector, err := util.ResolveImageAsImageSelector(config.Dev.Terminal.ImageSelector, configInterface, dependencies)
610+
imageSelector, err := runtimevar.NewRuntimeResolver(true).FillRuntimeVariablesAsImageSelector(config.Dev.Terminal.ImageSelector, configInterface, dependencies)
611611
if err != nil {
612612
return 0, err
613613
}
@@ -776,7 +776,7 @@ func (cmd *DevCmd) loadConfig(configOptions *loader.ConfigOptions) (config.Confi
776776
}
777777

778778
c.Dev.Terminal = &latest.Terminal{
779-
ImageSelector: fmt.Sprintf("image(%s):tag(%s)", imageName, imageName),
779+
ImageSelector: fmt.Sprintf("${runtime.images.%s.image}:${runtime.images.%s.tag}", imageName, imageName),
780780
}
781781
} else {
782782
c.Dev.Terminal.Disabled = false

cmd/enter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ devspace enter -c my-container
5656
devspace enter bash -n my-namespace
5757
devspace enter bash -l release=test
5858
devspace enter bash --image-selector nginx:latest
59-
devspace enter bash --image-selector "image(app):tag(app)"
59+
devspace enter bash --image-selector "${runtime.images.app.image}:${runtime.images.app.tag}"
6060
#######################################################`,
6161
RunE: func(cobraCmd *cobra.Command, args []string) error {
6262
plugin.SetPluginCommand(cobraCmd, args)
@@ -68,7 +68,7 @@ devspace enter bash --image-selector "image(app):tag(app)"
6868
enterCmd.Flags().StringVar(&cmd.Pod, "pod", "", "Pod to open a shell to")
6969
enterCmd.Flags().StringVar(&cmd.Image, "image", "", "Image is the config name of an image to select in the devspace config (e.g. 'default'), it is NOT a docker image like myuser/myimage")
7070
enterCmd.Flags().StringVarP(&cmd.LabelSelector, "label-selector", "l", "", "Comma separated key=value selector list (e.g. release=test)")
71-
enterCmd.Flags().StringVar(&cmd.ImageSelector, "image-selector", "", "The image to search a pod for (e.g. nginx, nginx:latest, image(app), nginx:tag(app))")
71+
enterCmd.Flags().StringVar(&cmd.ImageSelector, "image-selector", "", "The image to search a pod for (e.g. nginx, nginx:latest, ${runtime.images.app}, nginx:${runtime.images.app.tag})")
7272
enterCmd.Flags().StringVar(&cmd.WorkingDirectory, "workdir", "", "The working directory where to open the terminal or execute the command")
7373

7474
enterCmd.Flags().BoolVar(&cmd.Pick, "pick", true, "Select a pod / container if multiple are found")

cmd/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package cmd
22

33
import (
44
"fmt"
5+
"github.com/loft-sh/devspace/pkg/devspace/imageselector"
56
"io/ioutil"
67
"net/http"
78
"os"
@@ -23,7 +24,6 @@ import (
2324
"github.com/loft-sh/devspace/pkg/util/dockerfile"
2425
"github.com/loft-sh/devspace/pkg/util/factory"
2526
"github.com/loft-sh/devspace/pkg/util/fsutil"
26-
"github.com/loft-sh/devspace/pkg/util/imageselector"
2727
"github.com/loft-sh/devspace/pkg/util/log"
2828
"github.com/loft-sh/devspace/pkg/util/survey"
2929
"github.com/mgutz/ansi"

cmd/logs.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@ package cmd
22

33
import (
44
"fmt"
5+
runtimevar "github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/runtime"
6+
"github.com/loft-sh/devspace/pkg/devspace/imageselector"
57

68
"github.com/loft-sh/devspace/cmd/flags"
79
config2 "github.com/loft-sh/devspace/pkg/devspace/config"
810
"github.com/loft-sh/devspace/pkg/devspace/config/generated"
911
"github.com/loft-sh/devspace/pkg/devspace/config/loader"
1012
"github.com/loft-sh/devspace/pkg/devspace/dependency"
1113
"github.com/loft-sh/devspace/pkg/devspace/dependency/types"
12-
"github.com/loft-sh/devspace/pkg/devspace/deploy/deployer/util"
1314
"github.com/loft-sh/devspace/pkg/devspace/hook"
1415
"github.com/loft-sh/devspace/pkg/devspace/kubectl"
1516
"github.com/loft-sh/devspace/pkg/devspace/plugin"
1617
"github.com/loft-sh/devspace/pkg/devspace/services/targetselector"
1718
"github.com/loft-sh/devspace/pkg/util/factory"
18-
"github.com/loft-sh/devspace/pkg/util/imageselector"
1919
"github.com/loft-sh/devspace/pkg/util/log"
2020
"github.com/loft-sh/devspace/pkg/util/message"
2121
"github.com/pkg/errors"
@@ -67,7 +67,7 @@ devspace logs --namespace=mynamespace
6767
logsCmd.Flags().StringVarP(&cmd.Container, "container", "c", "", "Container name within pod where to execute command")
6868
logsCmd.Flags().StringVar(&cmd.Pod, "pod", "", "Pod to print the logs of")
6969
logsCmd.Flags().StringVarP(&cmd.LabelSelector, "label-selector", "l", "", "Comma separated key=value selector list (e.g. release=test)")
70-
logsCmd.Flags().StringVar(&cmd.ImageSelector, "image-selector", "", "The image to search a pod for (e.g. nginx, nginx:latest, image(app), nginx:tag(app))")
70+
logsCmd.Flags().StringVar(&cmd.ImageSelector, "image-selector", "", "The image to search a pod for (e.g. nginx, nginx:latest, ${runtime.images.app}, nginx:${runtime.images.app.tag})")
7171
logsCmd.Flags().StringVar(&cmd.Image, "image", "", "Image is the config name of an image to select in the devspace config (e.g. 'default'), it is NOT a docker image like myuser/myimage")
7272
logsCmd.Flags().BoolVar(&cmd.Pick, "pick", true, "Select a pod")
7373
logsCmd.Flags().BoolVarP(&cmd.Follow, "follow", "f", false, "Attach to logs afterwards")
@@ -161,7 +161,7 @@ func getImageSelector(client kubectl.Client, configLoader loader.ConfigLoader, c
161161
}
162162
}
163163

164-
resolved, err := util.ResolveImageAsImageSelector(imageSelector, config, dependencies)
164+
resolved, err := runtimevar.NewRuntimeResolver(true).FillRuntimeVariablesAsImageSelector(imageSelector, config, dependencies)
165165
if err != nil {
166166
return nil, err
167167
}

cmd/restart.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ package cmd
33
import (
44
"context"
55
"fmt"
6+
runtimevar "github.com/loft-sh/devspace/pkg/devspace/config/loader/variable/runtime"
7+
"github.com/loft-sh/devspace/pkg/devspace/imageselector"
68

79
"github.com/loft-sh/devspace/pkg/devspace/dependency"
8-
"github.com/loft-sh/devspace/pkg/devspace/deploy/deployer/util"
910
"github.com/loft-sh/devspace/pkg/devspace/hook"
1011
"github.com/loft-sh/devspace/pkg/devspace/kubectl"
1112
"github.com/loft-sh/devspace/pkg/devspace/plugin"
1213
"github.com/loft-sh/devspace/pkg/devspace/services/inject"
1314
"github.com/loft-sh/devspace/pkg/devspace/services/targetselector"
1415
"github.com/loft-sh/devspace/pkg/util/factory"
15-
"github.com/loft-sh/devspace/pkg/util/imageselector"
1616
"github.com/loft-sh/devspace/pkg/util/ptr"
1717

1818
"github.com/loft-sh/devspace/cmd/flags"
@@ -152,7 +152,7 @@ func (cmd *RestartCmd) Run(f factory.Factory) error {
152152
options := targetselector.NewOptionsFromFlags("", "", cmd.Namespace, "", cmd.Pick).ApplyConfigParameter(syncPath.LabelSelector, syncPath.Namespace, syncPath.ContainerName, "")
153153
options.ImageSelector = []imageselector.ImageSelector{}
154154
if syncPath.ImageSelector != "" {
155-
imageSelector, err := util.ResolveImageAsImageSelector(syncPath.ImageSelector, configInterface, dep)
155+
imageSelector, err := runtimevar.NewRuntimeResolver(true).FillRuntimeVariablesAsImageSelector(syncPath.ImageSelector, configInterface, dep)
156156
if err != nil {
157157
return err
158158
}

cmd/set/var.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/loft-sh/devspace/pkg/devspace/config/loader/variable"
88
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
99

10-
"github.com/loft-sh/devspace/pkg/devspace/config/loader"
1110
"github.com/loft-sh/devspace/pkg/util/factory"
1211
"github.com/loft-sh/devspace/pkg/util/log"
1312
"github.com/loft-sh/devspace/pkg/util/message"
@@ -125,14 +124,14 @@ type variableParser struct {
125124
Used map[string]bool
126125
}
127126

128-
func (v *variableParser) Parse(configPath string, originalRawConfig map[interface{}]interface{}, rawConfig map[interface{}]interface{}, vars []*latest.Variable, resolver variable.Resolver, options *loader.ConfigOptions, log log.Logger) (*latest.Config, error) {
127+
func (v *variableParser) Parse(originalRawConfig map[interface{}]interface{}, rawConfig map[interface{}]interface{}, resolver variable.Resolver, log log.Logger) (*latest.Config, error) {
129128
// Find out what vars are really used
130-
varsUsed, err := resolver.FindVariables(rawConfig, vars)
129+
varsUsed, err := resolver.FindVariables(rawConfig)
131130
if err != nil {
132131
return nil, err
133132
}
134133

135-
v.Definitions = vars
134+
v.Definitions = resolver.DefinedVars()
136135
v.Used = varsUsed
137136
return latest.NewRaw(), nil
138137
}

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ go run -mod=vendor ./hack/gen-docs.go
4545

4646
### 2. Create Version
4747
```bash
48-
yarn run docusaurus docs:version 5.17
48+
yarn run docusaurus docs:version 5.18
4949
```

docs/pages/commands/devspace.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ DevSpace accelerates developing, deploying and debugging applications with Docke
3030
--restore-vars If true will restore the variables from kubernetes before loading the config
3131
--save-vars If true will save the variables to kubernetes after loading the config
3232
--silent Run in silent mode and prevents any devspace log output except panics & fatals
33-
-s, --switch-context Switches and uses the last kube context and namespace that was used to deploy the DevSpace project
33+
-s, --switch-context DEPRECATED: Switches and uses the last kube context and namespace that was used to deploy the DevSpace project
3434
--var strings Variables to override during execution (e.g. --var=MYVAR=MYVALUE)
3535
--vars-secret string The secret to restore/save the variables from/to, if --restore-vars or --save-vars is enabled (default "devspace-vars")
3636
```

0 commit comments

Comments
 (0)