diff --git a/cmd/print_env.go b/cmd/print_env.go index 7e1f0941..d6c3c2d0 100644 --- a/cmd/print_env.go +++ b/cmd/print_env.go @@ -31,7 +31,7 @@ func NewPrintEnvCmd(globalCfg *config.GlobalImpl) *cobra.Command { } f := cmd.Flags() - f.StringVar(&printEnvOptions.Output, "output", "yaml", "output format: yaml or json") + f.StringVar(&printEnvOptions.OutputFormat, "output", "yaml", "output format: yaml or json") return cmd } diff --git a/pkg/config/print_env.go b/pkg/config/print_env.go index b4d6d3a0..c8c372ef 100644 --- a/pkg/config/print_env.go +++ b/pkg/config/print_env.go @@ -4,17 +4,22 @@ import "fmt" // PrintEnvOptions is the options for the print-env command type PrintEnvOptions struct { - // Output is the output format (yaml or json) - Output string + // OutputFormat is the output format (yaml or json) + OutputFormat string } // NewPrintEnvOptions creates a new PrintEnvOptions func NewPrintEnvOptions() *PrintEnvOptions { return &PrintEnvOptions{ - Output: "yaml", // default to yaml + OutputFormat: "yaml", // default to yaml } } +// Output returns the output format +func (p *PrintEnvOptions) Output() string { + return p.OutputFormat +} + // PrintEnvImpl is impl for PrintEnvOptions type PrintEnvImpl struct { *GlobalImpl @@ -29,15 +34,10 @@ func NewPrintEnvImpl(g *GlobalImpl, p *PrintEnvOptions) *PrintEnvImpl { } } -// Output returns the output format -func (c *PrintEnvImpl) Output() string { - return c.PrintEnvOptions.Output -} - // ValidateConfig validates the print-env configuration func (c *PrintEnvImpl) ValidateConfig() error { - if c.PrintEnvOptions.Output != "yaml" && c.PrintEnvOptions.Output != "json" { - return fmt.Errorf("invalid output format %q: must be 'yaml' or 'json'", c.PrintEnvOptions.Output) + if c.OutputFormat != "yaml" && c.OutputFormat != "json" { + return fmt.Errorf("invalid output format %q: must be 'yaml' or 'json'", c.OutputFormat) } return nil }