Skip to content

Commit

Permalink
print parsed config file
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Nov 3, 2023
1 parent cb9c6fb commit 681b198
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/equinor/radix-operator/pkg/apis/utils"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
)

// logoutCmd represents the logout command
Expand All @@ -38,6 +39,11 @@ var validateCmd = &cobra.Command{
return err
}

printfile, err := cmd.Flags().GetBool("print")
if err != nil {
return err
}

if _, err := os.Stat(radixconfig); errors.Is(err, os.ErrNotExist) {
return errors.New(fmt.Sprintf("Config file note found: %s", radixconfig))
}
Expand All @@ -48,6 +54,10 @@ var validateCmd = &cobra.Command{
return errors.New("Radix Config is invalid")
}

if printfile {
_ = yaml.NewEncoder(os.Stdout).Encode(ra.Spec)
}

err = radixvalidators.IsRadixApplicationValid(ra)
if err == nil {
fmt.Println("Radixconfig is valid")
Expand All @@ -63,5 +73,6 @@ var validateCmd = &cobra.Command{
func init() {
rootCmd.AddCommand(validateCmd)
validateCmd.Flags().StringP("radixconfig", "c", "radixconfig.yaml", "Path to radixconfig.yaml")
validateCmd.Flags().BoolP("print", "p", false, "Print parsed config file")
setVerbosePersistentFlag(validateCmd)
}

0 comments on commit 681b198

Please sign in to comment.