github.com/hellofresh/janus@v0.0.0-20230925145208-ce8de8183c67/cmd/check.go (about)

     1  package cmd
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/hellofresh/janus/pkg/config"
     7  	"github.com/spf13/cobra"
     8  )
     9  
    10  // NewCheckCmd creates a new check command
    11  func NewCheckCmd(ctx context.Context) *cobra.Command {
    12  	return &cobra.Command{
    13  		Use:   "check [config-file]",
    14  		Short: "Check the validity of a given Janus configuration file. (default /etc/janus/janus.toml)",
    15  		Args:  cobra.MinimumNArgs(1),
    16  		RunE:  RunCheck,
    17  	}
    18  }
    19  
    20  // RunCheck is the run command to check Janus configurations
    21  func RunCheck(cmd *cobra.Command, args []string) error {
    22  	_, err := config.Load(args[0])
    23  	if err != nil {
    24  		return err
    25  	}
    26  
    27  	cmd.Println("The configuration file is valid")
    28  	return nil
    29  }