feat(print-env): add output format validation
Signed-off-by: Dominik Schmidt <dev@dominik-schmidt.de>
This commit is contained in:
parent
adf0b94dda
commit
eb104ce5c8
|
|
@ -1,5 +1,7 @@
|
|||
package config
|
||||
|
||||
import "fmt"
|
||||
|
||||
// PrintEnvOptions is the options for the print-env command
|
||||
type PrintEnvOptions struct {
|
||||
// Output is the output format (yaml or json)
|
||||
|
|
@ -31,3 +33,11 @@ func NewPrintEnvImpl(g *GlobalImpl, p *PrintEnvOptions) *PrintEnvImpl {
|
|||
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)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue