Skip to content

Commit a90cfd6

Browse files
committed
refactor: better dependency handling & new runtime var e2e test
1 parent 391406c commit a90cfd6

Some content is hidden

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

54 files changed

+502
-264
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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/logs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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")

docs/pages/configuration/dependencies/basics.mdx

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ dev:
117117
# Will open a terminal to the pod with the
118118
# image from dep1
119119
terminal:
120-
imageName: dep1.image1
120+
imageSelector: ${runtime.dependencies.dep1.images.image1}
121121
```
122122

123123
With `dep1/devspace.yaml`:
@@ -134,24 +134,9 @@ deployments:
134134
- image: myusername/devspace
135135
```
136136

137-
### Referencing Nested Dependencies
138-
139-
You can also reference nested dependencies (dependencies of dependencies) via:
140-
```yaml
141-
dependencies:
142-
- name: dep1
143-
source:
144-
path: dep1
145-
dev:
146-
# Will open a terminal to the pod with the
147-
# image from dep2 that is a dependency of dep1
148-
terminal:
149-
imageName: dep1.dep2.image1
150-
```
151-
152137
### Referencing Dependencies in Deployment Values / Manifests
153138

154-
It is also possible to reference a dependency's image with the helpers `image()` or `tag()` in a deployment:
139+
It is also possible to reference a dependency's image with [runtime variables](../variables/runtime-variables.mdx) in a deployment:
155140
```yaml
156141
dependencies:
157142
- name: dep1
@@ -163,7 +148,7 @@ deployments:
163148
componentChart: true
164149
values:
165150
containers:
166-
- image: image(dep1.image1):tag(dep1.image1) # -> replaced with 'myusername/devspace:xxxx'
151+
- image: ${runtime.dependencies.dep1.image1.image}:${runtime.dependencies.dep1.image1.tag} # -> replaced with 'myusername/devspace:xxxx'
167152
```
168153

169154
With a dependency `dep1/devspace.yaml` that looks like:

docs/pages/configuration/dependencies/local-folder.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ deployments:
2828
componentChart: true
2929
values:
3030
containers:
31-
- image: image(component-1.image1):tag(component-1.image1)
31+
- image: ${runtime.dependencies.component-1.image1}
3232
```
3333
3434
## `source`

docs/pages/configuration/deployments/helm-charts.mdx

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,12 @@ deployments:
5151
# If registry.url/repo/image was found under images as well, will be
5252
# rewritten to registry.url/repo/image:generated_tag
5353
imageWithTag: registry.url/repo/image
54-
# If registry.url/repo/image was found under images as well, will be
54+
# If registry.url/repo/image was found under images.app as well, will be
5555
# rewritten to registry.url/repo/image
56-
imageWithoutTag: image(registry.url/repo/image)
57-
# If registry.url/repo/image was found under images as well, will be
56+
imageWithoutTag: ${runtime.images.app.image}
57+
# If registry.url/repo/image was found under images.app as well, will be
5858
# rewritten to generated_tag
59-
onlyTag: tag(registry.url/repo/image)
60-
ingress:
61-
enabled: true
59+
onlyTag: ${runtime.images.app.tag}
6260
```
6361
6462
</TabItem>
@@ -74,14 +72,12 @@ deployments:
7472
# If registry.url/repo/image was found under images as well, will be
7573
# rewritten to registry.url/repo/image:generated_tag
7674
imageWithTag: registry.url/repo/image
77-
# If registry.url/repo/image was found under images as well, will be
75+
# If registry.url/repo/image was found under images.app as well, will be
7876
# rewritten to registry.url/repo/image
79-
imageWithoutTag: image(registry.url/repo/image)
80-
# If registry.url/repo/image was found under images as well, will be
77+
imageWithoutTag: ${runtime.images.app.image}
78+
# If registry.url/repo/image was found under images.app as well, will be
8179
# rewritten to generated_tag
82-
onlyTag: tag(registry.url/repo/image)
83-
ingress:
84-
enabled: true
80+
onlyTag: ${runtime.images.app.tag}
8581
```
8682
8783
</TabItem>
@@ -285,8 +281,6 @@ By default, DevSpace searches all your values (specified via `values` or `values
285281

286282
DevSpace will replace the following things:
287283
- **registry.url/repo/name** that corresponds to a `images.*.image`, will be rewritten to `registry.url/repo/name:generated_tag`
288-
- **image(image-key)** that corresponds to a `images.*` key, will be rewritten to `registry.url/repo/name`. You can also use dependency images here with `image(dep1.dep-image)`
289-
- **tag(image-key)** that corresponds to a `images.*` key, will be rewritten to `generated_tag`. You can also use dependency images here with `tag(dep1.dep-image)`
290284

291285
:::info In-Memory Tag Replacement
292286
Tag replacement takes place **in-memory** and is **not** writing anything to the filesystem, i.e. it will **never** change any of your configuration files.
@@ -570,3 +564,8 @@ deployments:
570564
chart:
571565
name: bitnami/mysql
572566
```
567+
568+
## `disabled`
569+
570+
If true, the deployment will not be deployed, rendered or purged. Can be useful in combination with config expressions or command variables.
571+

docs/pages/configuration/deployments/kubernetes-manifests.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,7 @@ deployments:
143143
- backend/
144144
- backend-extra/
145145
```
146+
147+
## `disabled`
148+
149+
If true, the deployment will not be deployed, rendered or purged. Can be useful in combination with config expressions or command variables.

docs/pages/configuration/deployments/kustomizations.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,7 @@ deployments:
143143
- backend/
144144
- backend-extra/
145145
```
146+
147+
## `disabled`
148+
149+
If true, the deployment will not be deployed, rendered or purged. Can be useful in combination with config expressions or command variables.

0 commit comments

Comments
 (0)