github.com/pf-qiu/concourse/v6@v6.7.3-0.20201207032516-1f455d73275f/fly/commands/validate_pipeline.go (about)

     1  package commands
     2  
     3  import (
     4  	"github.com/pf-qiu/concourse/v6/atc"
     5  	"github.com/pf-qiu/concourse/v6/fly/commands/internal/flaghelpers"
     6  	"github.com/pf-qiu/concourse/v6/fly/commands/internal/templatehelpers"
     7  	"github.com/pf-qiu/concourse/v6/fly/commands/internal/validatepipelinehelpers"
     8  
     9  	// dynamically registered credential managers
    10  	_ "github.com/pf-qiu/concourse/v6/atc/creds/conjur"
    11  	_ "github.com/pf-qiu/concourse/v6/atc/creds/credhub"
    12  	_ "github.com/pf-qiu/concourse/v6/atc/creds/dummy"
    13  	_ "github.com/pf-qiu/concourse/v6/atc/creds/kubernetes"
    14  	_ "github.com/pf-qiu/concourse/v6/atc/creds/secretsmanager"
    15  	_ "github.com/pf-qiu/concourse/v6/atc/creds/ssm"
    16  	_ "github.com/pf-qiu/concourse/v6/atc/creds/vault"
    17  )
    18  
    19  type ValidatePipelineCommand struct {
    20  	Config           atc.PathFlag `short:"c" long:"config" required:"true"  description:"Pipeline configuration file"`
    21  	Strict           bool         `short:"s" long:"strict"                  description:"Fail on warnings"`
    22  	Output           bool         `short:"o" long:"output"                  description:"Output templated pipeline to stdout"`
    23  	EnableAcrossStep bool         `long:"enable-across-step"                description:"Enable the experimental across step to be used in jobs. The API is subject to change."`
    24  
    25  	Var     []flaghelpers.VariablePairFlag     `short:"v"  long:"var"       unquote:"false"  value-name:"[NAME=STRING]"  description:"Specify a string value to set for a variable in the pipeline"`
    26  	YAMLVar []flaghelpers.YAMLVariablePairFlag `short:"y"  long:"yaml-var"  unquote:"false"  value-name:"[NAME=YAML]"    description:"Specify a YAML value to set for a variable in the pipeline"`
    27  
    28  	VarsFrom []atc.PathFlag `short:"l"  long:"load-vars-from"  description:"Variable flag that can be used for filling in template values in configuration from a YAML file"`
    29  }
    30  
    31  func (command *ValidatePipelineCommand) Execute(args []string) error {
    32  	yamlTemplate := templatehelpers.NewYamlTemplateWithParams(command.Config, command.VarsFrom, command.Var, command.YAMLVar, nil)
    33  	return validatepipelinehelpers.Validate(yamlTemplate, command.Strict, command.Output, command.EnableAcrossStep)
    34  }