Skip to content

Commit 49d2fec

Browse files
authored
Merge pull request #2666 from lizardruss/local-registry-imports
fix: add localRegistry to imported sections
2 parents 1c20875 + 72d01e0 commit 49d2fec

File tree

9 files changed

+64
-6
lines changed

9 files changed

+64
-6
lines changed

devspace-schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2068,7 +2068,7 @@
20682068
},
20692069
"name": {
20702070
"type": "string",
2071-
"description": "Name specifies the name of the DevSpace project and uniquely identifies a project.\nDevSpace will not allow multiple active projects with the same name in the same Kubernetes namespace."
2071+
"description": "Name specifies the name of the DevSpace project and uniquely identifies a project.\nDevSpace will not allow multiple active projects with the same name in the same Kubernetes namespace.\nIf not provided, DevSpace will use the name of the current working directory."
20722072
},
20732073
"imports": {
20742074
"items": {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Name specifies the name of the DevSpace project and uniquely identifies a project.
88
DevSpace will not allow multiple active projects with the same name in the same Kubernetes namespace.
99
If not provided, DevSpace will use the name of the current working directory.
10+
1011
</summary>
1112

1213

docs/pages/configuration/imports/README.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,25 @@ functions:
8383
echo "This is a function_x from project-a"
8484
```
8585

86+
## Import Sections
87+
The following DevSpace config sections are allowed to be imported:
88+
```
89+
/require/*
90+
/vars/*
91+
/dev/*
92+
/deployments/*
93+
/images/*
94+
/localRegistry/*
95+
/pipelines/*
96+
/commands/*
97+
/functions/*
98+
/pullSecrets/*
99+
/dependencies/*
100+
/profiles/*
101+
/hooks/*
102+
```
103+
104+
All other config sections will be ignored during import.
86105

87106
## Config Reference
88107
The `imports` section in your `devspace.yaml` file is an array and each entry (import) supports the following fields:

docs/schemas/config-openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2076,7 +2076,7 @@
20762076
},
20772077
"name": {
20782078
"type": "string",
2079-
"description": "Name specifies the name of the DevSpace project and uniquely identifies a project.\nDevSpace will not allow multiple active projects with the same name in the same Kubernetes namespace."
2079+
"description": "Name specifies the name of the DevSpace project and uniquely identifies a project.\nDevSpace will not allow multiple active projects with the same name in the same Kubernetes namespace.\nIf not provided, DevSpace will use the name of the current working directory."
20802080
},
20812081
"imports": {
20822082
"items": {

e2e/tests/imports/imports.go

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
package imports
22

33
import (
4-
"github.com/onsi/ginkgo/v2"
4+
"bytes"
55
"os"
66
"strings"
77

8+
"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
9+
"github.com/onsi/ginkgo/v2"
10+
"gopkg.in/yaml.v3"
11+
812
"github.com/loft-sh/devspace/cmd"
913
"github.com/loft-sh/devspace/cmd/flags"
1014
"github.com/loft-sh/devspace/e2e/framework"
@@ -134,4 +138,28 @@ var _ = DevSpaceDescribe("imports", func() {
134138
_, err = os.Stat(strings.TrimSpace(string(out)))
135139
framework.ExpectError(err)
136140
})
141+
142+
ginkgo.It("should import correctly with localRegistry", func() {
143+
tempDir, err := framework.CopyToTempDir("tests/imports/testdata/localregistry")
144+
framework.ExpectNoError(err)
145+
defer framework.CleanupTempDir(initialDir, tempDir)
146+
147+
configBuffer := &bytes.Buffer{}
148+
printCmd := &cmd.PrintCmd{
149+
GlobalFlags: &flags.GlobalFlags{},
150+
Out: configBuffer,
151+
SkipInfo: true,
152+
}
153+
154+
err = printCmd.Run(f)
155+
framework.ExpectNoError(err)
156+
157+
latestConfig := &latest.Config{}
158+
err = yaml.Unmarshal(configBuffer.Bytes(), latestConfig)
159+
framework.ExpectNoError(err)
160+
161+
// validate config
162+
framework.ExpectEqual(*latestConfig.LocalRegistry.Enabled, false)
163+
framework.ExpectEqual(latestConfig.LocalRegistry.Name, "defaults-registry")
164+
})
137165
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
version: v2beta1
2+
localRegistry:
3+
enabled: false
4+
name: defaults-registry
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version: v2beta1
2+
imports:
3+
- path: defaults.yaml

pkg/devspace/config/loader/imports.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ package loader
33
import (
44
"context"
55
"fmt"
6+
"os"
7+
"path/filepath"
8+
69
"github.com/loft-sh/devspace/pkg/devspace/config/loader/variable"
710
"github.com/loft-sh/devspace/pkg/devspace/config/versions"
811
"github.com/loft-sh/devspace/pkg/devspace/config/versions/util"
912
dependencyutil "github.com/loft-sh/devspace/pkg/devspace/dependency/util"
1013
"github.com/loft-sh/devspace/pkg/util/log"
1114
"github.com/loft-sh/devspace/pkg/util/yamlutil"
1215
"github.com/pkg/errors"
13-
"os"
14-
"path/filepath"
1516
)
1617

1718
var ImportSections = []string{
@@ -27,6 +28,7 @@ var ImportSections = []string{
2728
"dependencies",
2829
"profiles",
2930
"hooks",
31+
"localRegistry",
3032
}
3133

3234
func ResolveImports(ctx context.Context, resolver variable.Resolver, basePath string, rawData map[string]interface{}, log log.Logger) (map[string]interface{}, error) {

pkg/devspace/config/versions/latest/schema.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ type Config struct {
4949

5050
// Name specifies the name of the DevSpace project and uniquely identifies a project.
5151
// DevSpace will not allow multiple active projects with the same name in the same Kubernetes namespace.
52-
Name string `yaml:"name" json:"name" jsonschema:"required"`
52+
// If not provided, DevSpace will use the name of the current working directory.
53+
Name string `yaml:"name" json:"name"`
5354

5455
// Imports merges specified config files into this one. This is very useful to split up your DevSpace configuration
5556
// into multiple files and reuse those through git, a remote url or common local path.

0 commit comments

Comments
 (0)