Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion devspace-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2068,7 +2068,7 @@
},
"name": {
"type": "string",
"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."
"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."
},
"imports": {
"items": {
Expand Down
1 change: 1 addition & 0 deletions docs/pages/configuration/_partials/v2beta1/name.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Name specifies the name of the DevSpace project and uniquely identifies a project.
DevSpace will not allow multiple active projects with the same name in the same Kubernetes namespace.
If not provided, DevSpace will use the name of the current working directory.

</summary>


Expand Down
19 changes: 19 additions & 0 deletions docs/pages/configuration/imports/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,25 @@ functions:
echo "This is a function_x from project-a"
```

## Import Sections
The following DevSpace config sections are allowed to be imported:
```
/require/*
/vars/*
/dev/*
/deployments/*
/images/*
/localRegistry/*
/pipelines/*
/commands/*
/functions/*
/pullSecrets/*
/dependencies/*
/profiles/*
/hooks/*
```

All other config sections will be ignored during import.

## Config Reference
The `imports` section in your `devspace.yaml` file is an array and each entry (import) supports the following fields:
Expand Down
2 changes: 1 addition & 1 deletion docs/schemas/config-openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2076,7 +2076,7 @@
},
"name": {
"type": "string",
"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."
"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."
},
"imports": {
"items": {
Expand Down
30 changes: 29 additions & 1 deletion e2e/tests/imports/imports.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package imports

import (
"github.com/onsi/ginkgo/v2"
"bytes"
"os"
"strings"

"github.com/loft-sh/devspace/pkg/devspace/config/versions/latest"
"github.com/onsi/ginkgo/v2"
"gopkg.in/yaml.v3"

"github.com/loft-sh/devspace/cmd"
"github.com/loft-sh/devspace/cmd/flags"
"github.com/loft-sh/devspace/e2e/framework"
Expand Down Expand Up @@ -134,4 +138,28 @@ var _ = DevSpaceDescribe("imports", func() {
_, err = os.Stat(strings.TrimSpace(string(out)))
framework.ExpectError(err)
})

ginkgo.It("should import correctly with localRegistry", func() {
tempDir, err := framework.CopyToTempDir("tests/imports/testdata/localregistry")
framework.ExpectNoError(err)
defer framework.CleanupTempDir(initialDir, tempDir)

configBuffer := &bytes.Buffer{}
printCmd := &cmd.PrintCmd{
GlobalFlags: &flags.GlobalFlags{},
Out: configBuffer,
SkipInfo: true,
}

err = printCmd.Run(f)
framework.ExpectNoError(err)

latestConfig := &latest.Config{}
err = yaml.Unmarshal(configBuffer.Bytes(), latestConfig)
framework.ExpectNoError(err)

// validate config
framework.ExpectEqual(*latestConfig.LocalRegistry.Enabled, false)
framework.ExpectEqual(latestConfig.LocalRegistry.Name, "defaults-registry")
})
})
4 changes: 4 additions & 0 deletions e2e/tests/imports/testdata/localregistry/defaults.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: v2beta1
localRegistry:
enabled: false
name: defaults-registry
3 changes: 3 additions & 0 deletions e2e/tests/imports/testdata/localregistry/devspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
version: v2beta1
imports:
- path: defaults.yaml
6 changes: 4 additions & 2 deletions pkg/devspace/config/loader/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ package loader
import (
"context"
"fmt"
"os"
"path/filepath"

"github.com/loft-sh/devspace/pkg/devspace/config/loader/variable"
"github.com/loft-sh/devspace/pkg/devspace/config/versions"
"github.com/loft-sh/devspace/pkg/devspace/config/versions/util"
dependencyutil "github.com/loft-sh/devspace/pkg/devspace/dependency/util"
"github.com/loft-sh/devspace/pkg/util/log"
"github.com/loft-sh/devspace/pkg/util/yamlutil"
"github.com/pkg/errors"
"os"
"path/filepath"
)

var ImportSections = []string{
Expand All @@ -27,6 +28,7 @@ var ImportSections = []string{
"dependencies",
"profiles",
"hooks",
"localRegistry",
}

func ResolveImports(ctx context.Context, resolver variable.Resolver, basePath string, rawData map[string]interface{}, log log.Logger) (map[string]interface{}, error) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/devspace/config/versions/latest/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ type Config struct {

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

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