Skip to content

Commit f98dd2b

Browse files
committed
feat: allow profiles & hooks in imports
1 parent f8abe6b commit f98dd2b

4 files changed

Lines changed: 27 additions & 0 deletions

File tree

e2e/tests/imports/imports.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ var _ = DevSpaceDescribe("imports", func() {
4848
GlobalFlags: &flags.GlobalFlags{
4949
NoWarn: true,
5050
Namespace: ns,
51+
Profiles: []string{"my-profile"},
5152
},
5253
Pipeline: "deploy",
5354
}
@@ -69,6 +70,7 @@ var _ = DevSpaceDescribe("imports", func() {
6970
framework.ExpectLocalFileContentsWithoutSpaces("import3.txt", "import3")
7071
framework.ExpectLocalFileContentsWithoutSpaces("import4.txt", "import4")
7172
framework.ExpectLocalFileContentsWithoutSpaces("import5.txt", "import5")
73+
framework.ExpectLocalFileContentsWithoutSpaces("profile_import.txt", "PROFILE_TEST")
7274
framework.ExpectLocalFileContentsWithoutSpaces("vars.txt", ns+"-"+ns+"-base-import1-import2-import3")
7375
framework.ExpectLocalFileContentsWithoutSpaces("top.txt", "top")
7476

e2e/tests/imports/testdata/local/devspace.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: base
33

44
imports:
55
- path: import1.yaml
6+
- path: profile_import.yaml
67
- enabled: $(is_equal ${BASE} "base")
78
path: import2.yaml
89
- enabled: $(is_equal ${IMPORT1} "import1")
@@ -33,4 +34,5 @@ pipelines:
3334
run_pipelines import4 > import4.txt
3435
run_pipelines import5 > import5.txt
3536
37+
echo ${PROFILE_TEST} > profile_import.txt
3638
echo ${DEVSPACE_NAMESPACE}-${devspace.namespace}-${BASE}-${IMPORT1}-${IMPORT2}-${IMPORT3} > vars.txt
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: v2beta1
2+
name: profile-import
3+
4+
profiles:
5+
- name: my-profile
6+
merge:
7+
vars:
8+
PROFILE_TEST: "PROFILE_TEST"

pkg/devspace/config/loader/imports.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ var ImportSections = []string{
2525
"functions",
2626
"pullSecrets",
2727
"dependencies",
28+
"profiles",
29+
"hooks",
2830
}
2931

3032
func ResolveImports(ctx context.Context, resolver variable.Resolver, basePath string, rawData map[string]interface{}, log log.Logger) (map[string]interface{}, error) {
@@ -94,6 +96,19 @@ func ResolveImports(ctx context.Context, resolver variable.Resolver, basePath st
9496
for _, section := range ImportSections {
9597
sectionMap, ok := importData[section].(map[string]interface{})
9698
if !ok {
99+
// no map, is it a slice?
100+
sectionSlice, ok := importData[section].([]interface{})
101+
if !ok {
102+
continue
103+
}
104+
105+
// make sure the section exists
106+
if mergedMap[section] == nil {
107+
mergedMap[section] = []interface{}{}
108+
}
109+
for _, value := range sectionSlice {
110+
mergedMap[section] = append(mergedMap[section].([]interface{}), value)
111+
}
97112
continue
98113
}
99114

0 commit comments

Comments
 (0)