@@ -22,6 +22,7 @@ import (
22
22
"io"
23
23
24
24
"github.com/spf13/cobra"
25
+ "github.com/spf13/pflag"
25
26
yaml "gopkg.in/yaml.v2"
26
27
27
28
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/color"
@@ -30,25 +31,37 @@ import (
30
31
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/version"
31
32
)
32
33
34
+ var (
35
+ yamlOnly bool
36
+ )
37
+
33
38
// NewCmdDiagnose describes the CLI command to diagnose skaffold.
34
39
func NewCmdDiagnose () * cobra.Command {
35
40
return NewCmd ("diagnose" ).
36
41
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" ).
37
44
WithCommonFlags ().
45
+ WithFlags (func (f * pflag.FlagSet ) {
46
+ f .BoolVar (& yamlOnly , "yaml-only" , false , "Only prints the effective skaffold.yaml configuration" )
47
+ }).
38
48
NoArgs (doDiagnose )
39
49
}
40
50
41
51
func doDiagnose (ctx context.Context , out io.Writer ) error {
42
52
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
+ }
46
61
47
- if err := r .DiagnoseArtifacts (ctx , out ); err != nil {
48
- return fmt .Errorf ("running diagnostic on artifacts: %w" , err )
62
+ color .Blue .Fprintln (out , "\n Configuration" )
49
63
}
50
64
51
- color .Blue .Fprintln (out , "\n Configuration" )
52
65
buf , err := yaml .Marshal (config )
53
66
if err != nil {
54
67
return fmt .Errorf ("marshalling configuration: %w" , err )
0 commit comments