Skip to content

Commit b85f0b7

Browse files
authored
Merge pull request #2048 from FabianKramm/master
fix: fix xargs
2 parents 73dc241 + a8201e2 commit b85f0b7

9 files changed

Lines changed: 19 additions & 10 deletions

File tree

e2e/tests/imports/imports.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ var _ = DevSpaceDescribe("imports", func() {
7070
framework.ExpectLocalFileContentsWithoutSpaces("import4.txt", "import4")
7171
framework.ExpectLocalFileContentsWithoutSpaces("import5.txt", "import5")
7272
framework.ExpectLocalFileContentsWithoutSpaces("vars.txt", ns+"-"+ns+"-base-import1-import2-import3")
73+
framework.ExpectLocalFileContentsWithoutSpaces("top.txt", "top")
7374

7475
// make sure temp folder is erased
7576
_, err = os.Stat(strings.TrimSpace(string(out)))

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ imports:
1010

1111
vars:
1212
BASE: base
13+
TOP: top
1314

1415
dependencies:
1516
import1:
@@ -21,6 +22,7 @@ pipelines:
2122
run: |-
2223
echo ${devspace.name} > name.txt
2324
echo ${DEVSPACE_TMPDIR} > temp.txt
25+
echo ${TOP} > top.txt
2426
2527
run_dependencies --all > dependency.txt
2628

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ imports:
77
enabled: $(is_equal ${BASE} "base")
88

99
vars:
10+
TOP: import1
1011
IMPORT1:
1112
value: import1
1213

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: v2beta1
22
name: import2
33

44
vars:
5+
TOP: import2
56
IMPORT2: import2
67

78
pipelines:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: v2beta1
22
name: import3
33

44
vars:
5+
TOP: import3
56
IMPORT3: import3
67

78
pipelines:

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ imports:
66
enabled: $(is_equal ${IMPORT4} "import4")
77

88
vars:
9+
TOP: import4
910
IMPORT4:
1011
command: echo import4
1112

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ version: v2beta1
22
name: import5
33

44
vars:
5+
TOP: import5
56
IMPORT5: $(echo import5)
67

78
pipelines:

pkg/devspace/config/loader/imports.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,9 @@ func ResolveImports(ctx context.Context, resolver variable.Resolver, basePath st
104104

105105
for key, value := range sectionMap {
106106
_, ok := mergedMap[section].(map[string]interface{})[key]
107-
if ok {
108-
return nil, fmt.Errorf("cannot import %s: section %s already has an item with key %s. Please make sure that imported %s keys do not collide across the current config and imported configs", configPath, section, key, section)
107+
if !ok {
108+
mergedMap[section].(map[string]interface{})[key] = value
109109
}
110-
111-
mergedMap[section].(map[string]interface{})[key] = value
112110
}
113111
}
114112

pkg/devspace/pipeline/engine/basichandler/commands/xargs.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ func XArgs(ctx context.Context, args []string, handler types.ExecHandler) error
3434
return err
3535
}
3636

37-
addArgs := strings.Split(string(out), options.Delimiter)
37+
addArgs := strings.Split(string(out), "\n")
3838
for _, addArg := range addArgs {
39-
addArg = strings.TrimSpace(addArg)
40-
if addArg == "" {
41-
continue
42-
}
39+
splitted := strings.Split(addArg, options.Delimiter)
40+
for _, a := range splitted {
41+
a = strings.TrimSpace(a)
42+
if a == "" {
43+
continue
44+
}
4345

44-
args = append(args, addArg)
46+
args = append(args, a)
47+
}
4548
}
4649
return handler.ExecHandler(ctx, args)
4750
}

0 commit comments

Comments
 (0)