Skip to content

Commit 0ba1640

Browse files
authored
Merge pull request #2143 from FabianKramm/print-feat
feat: allow profiles & hooks in imports
2 parents 7880d00 + 38b0cb8 commit 0ba1640

5 files changed

Lines changed: 32 additions & 2 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

pkg/devspace/deploy/deployer/kubectl/kubectl.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package kubectl
22

33
import (
4+
"bytes"
45
"context"
56
"fmt"
67
"io"
@@ -179,9 +180,11 @@ func (d *DeployConfig) Deploy(ctx devspacecontext.Context, _ bool) (bool, error)
179180
if shouldRedeploy || forceDeploy {
180181
args := d.getCmdArgs("apply", "--force")
181182
args = append(args, d.DeploymentConfig.Kubectl.ApplyArgs...)
182-
err = command.Command(ctx.Context(), ctx.WorkingDir(), writer, writer, strings.NewReader(replacedManifest), d.CmdPath, args...)
183+
184+
stdErrBuffer := &bytes.Buffer{}
185+
err = command.Command(ctx.Context(), ctx.WorkingDir(), writer, io.MultiWriter(writer, stdErrBuffer), strings.NewReader(replacedManifest), d.CmdPath, args...)
183186
if err != nil {
184-
return false, errors.Errorf("%v\nPlease make sure the command `kubectl apply` does work locally with manifest `%s`", err, manifest)
187+
return false, errors.Errorf("%v %v\nPlease make sure the command `kubectl apply` does work locally with manifest `%s`", stdErrBuffer.String(), err, manifest)
185188
}
186189

187190
wasDeployed = true

0 commit comments

Comments
 (0)