Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skaffold diagnose outputs incorrect yaml for multiconfig projects #5531

Merged
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
4 changes: 4 additions & 0 deletions cmd/skaffold/app/cmd/diagnose.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ func doDiagnose(ctx context.Context, out io.Writer) error {
color.Blue.Fprintln(out, "\nConfiguration")
}
}
// remove the dependency config references since they have already been imported and will be marshalled together.
for i := range configs {
configs[i].Dependencies = nil
}
buf, err := yaml.MarshalWithSeparator(configs)
if err != nil {
return fmt.Errorf("marshalling configuration: %w", err)
Expand Down
11 changes: 11 additions & 0 deletions integration/diagnose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"testing"

"github.com/GoogleContainerTools/skaffold/integration/skaffold"
"github.com/GoogleContainerTools/skaffold/testutil"
)

func TestDiagnose(t *testing.T) {
Expand Down Expand Up @@ -63,3 +64,13 @@ func folders(root string) ([]string, error) {

return folders, err
}

func TestMultiConfigDiagnose(t *testing.T) {
MarkIntegrationTest(t, CanRunWithoutGcp)
testutil.Run(t, "test multiconfig diagnose", func(t *testutil.T) {
out := skaffold.Diagnose("--yaml-only").InDir("testdata/diagnose/multi-config").RunOrFailOutput(t.T)
expected, err := ioutil.ReadFile("testdata/diagnose/multi-config/skaffold_merged.yaml")
t.CheckNoError(err)
t.CheckDeepEqual(expected, out)
})
}
13 changes: 13 additions & 0 deletions integration/testdata/diagnose/multi-config/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: skaffold/v2beta13
kind: Config
requires:
- path: ./skaffold2.yaml
- path: ./skaffold3.yaml
build:
artifacts:
- image: app1
context: /foo
deploy:
kubectl:
manifests:
- /k8s/*
12 changes: 12 additions & 0 deletions integration/testdata/diagnose/multi-config/skaffold2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: skaffold/v2beta13
kind: Config
metadata:
name: cfg2
build:
artifacts:
- image: app2
context: /foo
deploy:
kubectl:
manifests:
- /k8s/*
12 changes: 12 additions & 0 deletions integration/testdata/diagnose/multi-config/skaffold3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: skaffold/v2beta13
kind: Config
metadata:
name: cfg3
build:
artifacts:
- image: app3
context: /foo
deploy:
kubectl:
manifests:
- /k8s/*
60 changes: 60 additions & 0 deletions integration/testdata/diagnose/multi-config/skaffold_merged.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: skaffold/v2beta13
kind: Config
metadata:
name: cfg2
build:
artifacts:
- image: app2
context: /foo
docker:
dockerfile: Dockerfile
tagPolicy:
gitCommit: {}
local:
concurrency: 1
deploy:
kubectl:
manifests:
- /k8s/*
logs:
prefix: container
---
apiVersion: skaffold/v2beta13
kind: Config
metadata:
name: cfg3
build:
artifacts:
- image: app3
context: /foo
docker:
dockerfile: Dockerfile
tagPolicy:
gitCommit: {}
local:
concurrency: 1
deploy:
kubectl:
manifests:
- /k8s/*
logs:
prefix: container
---
apiVersion: skaffold/v2beta13
kind: Config
build:
artifacts:
- image: app1
context: /foo
docker:
dockerfile: Dockerfile
tagPolicy:
gitCommit: {}
local:
concurrency: 1
deploy:
kubectl:
manifests:
- /k8s/*
logs:
prefix: container