Skip to content

Commit 56adaf4

Browse files
committed
Print the effective skaffold.yaml configuration
Signed-off-by: David Gageot <[email protected]>
1 parent 794f26a commit 56adaf4

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

cmd/skaffold/app/cmd/diagnose.go

+19-6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"io"
2323

2424
"github.com/spf13/cobra"
25+
"github.com/spf13/pflag"
2526
yaml "gopkg.in/yaml.v2"
2627

2728
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
@@ -30,25 +31,37 @@ import (
3031
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/version"
3132
)
3233

34+
var (
35+
yamlOnly bool
36+
)
37+
3338
// NewCmdDiagnose describes the CLI command to diagnose skaffold.
3439
func NewCmdDiagnose() *cobra.Command {
3540
return NewCmd("diagnose").
3641
WithDescription("Run a diagnostic on Skaffold").
42+
WithExample("Search for configuration issues and print the effective configuration", "diagnose").
43+
WithExample("Print the effective skaffold.yaml configuration for given profile", "diagnose --yaml-only --profile PROFILE").
3744
WithCommonFlags().
45+
WithFlags(func(f *pflag.FlagSet) {
46+
f.BoolVar(&yamlOnly, "yaml-only", false, "Only prints the effective skaffold.yaml configuration")
47+
}).
3848
NoArgs(doDiagnose)
3949
}
4050

4151
func doDiagnose(ctx context.Context, out io.Writer) error {
4252
return withRunner(ctx, func(r runner.Runner, config *latest.SkaffoldConfig) error {
43-
fmt.Fprintln(out, "Skaffold version:", version.Get().GitCommit)
44-
fmt.Fprintln(out, "Configuration version:", config.APIVersion)
45-
fmt.Fprintln(out, "Number of artifacts:", len(config.Build.Artifacts))
53+
if !yamlOnly {
54+
fmt.Fprintln(out, "Skaffold version:", version.Get().GitCommit)
55+
fmt.Fprintln(out, "Configuration version:", config.APIVersion)
56+
fmt.Fprintln(out, "Number of artifacts:", len(config.Build.Artifacts))
57+
58+
if err := r.DiagnoseArtifacts(ctx, out); err != nil {
59+
return fmt.Errorf("running diagnostic on artifacts: %w", err)
60+
}
4661

47-
if err := r.DiagnoseArtifacts(ctx, out); err != nil {
48-
return fmt.Errorf("running diagnostic on artifacts: %w", err)
62+
color.Blue.Fprintln(out, "\nConfiguration")
4963
}
5064

51-
color.Blue.Fprintln(out, "\nConfiguration")
5265
buf, err := yaml.Marshal(config)
5366
if err != nil {
5467
return fmt.Errorf("marshalling configuration: %w", err)

docs/content/en/docs/references/cli/_index.md

+9
Original file line numberDiff line numberDiff line change
@@ -580,11 +580,19 @@ Run a diagnostic on Skaffold
580580
```
581581
582582
583+
Examples:
584+
# Search for configuration issues and print the effective configuration
585+
skaffold diagnose
586+
587+
# Print the effective skaffold.yaml configuration for given profile
588+
skaffold diagnose --yaml-only --profile PROFILE
589+
583590
Options:
584591
-c, --config='': File for global configurations (defaults to $HOME/.skaffold/config)
585592
-f, --filename='skaffold.yaml': Path or URL to the Skaffold config file
586593
-p, --profile=[]: Activate profiles by name (prefixed with `-` to disable a profile)
587594
--profile-auto-activation=true: Set to false to disable profile auto activation
595+
--yaml-only=false: Only prints the effective skaffold.yaml configuration
588596
589597
Usage:
590598
skaffold diagnose [options]
@@ -599,6 +607,7 @@ Env vars:
599607
* `SKAFFOLD_FILENAME` (same as `--filename`)
600608
* `SKAFFOLD_PROFILE` (same as `--profile`)
601609
* `SKAFFOLD_PROFILE_AUTO_ACTIVATION` (same as `--profile-auto-activation`)
610+
* `SKAFFOLD_YAML_ONLY` (same as `--yaml-only`)
602611

603612
### skaffold fix
604613

0 commit comments

Comments
 (0)