github.com/helmwave/helmwave@v0.36.4-0.20240509190856-b35563eba4c6/pkg/action/validate.go (about)

     1  package action
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/helmwave/helmwave/pkg/plan"
     7  	"github.com/urfave/cli/v2"
     8  )
     9  
    10  var _ Action = (*Validate)(nil)
    11  
    12  // Validate is a struct for running 'validate' command.
    13  type Validate struct {
    14  	plandir string
    15  }
    16  
    17  // Run is the main function for 'validate' command.
    18  func (l *Validate) Run(ctx context.Context) error {
    19  	p, err := plan.NewAndImport(ctx, l.plandir)
    20  	if err != nil {
    21  		return err
    22  	}
    23  
    24  	return p.ValidateValuesImport()
    25  }
    26  
    27  // Cmd returns 'validate' *cli.Command.
    28  func (l *Validate) Cmd() *cli.Command {
    29  	return &cli.Command{
    30  		Name:     "validate",
    31  		Category: Step1,
    32  		Usage:    "🛂 validate your plan",
    33  		Flags:    l.flags(),
    34  		Action:   toCtx(l.Run),
    35  	}
    36  }
    37  
    38  // flags return flag set of CLI urfave.
    39  func (l *Validate) flags() []cli.Flag {
    40  	return []cli.Flag{
    41  		flagPlandir(&l.plandir),
    42  	}
    43  }