Start accepting input variable files as CLI arguments
This commit is contained in:
parent
8f5bc0d8cd
commit
7fcda0f01f
|
@ -79,6 +79,12 @@ Plan Options:
|
|||
-policy-override
|
||||
Sets the flag to force override any soft mandatory Sentinel policies.
|
||||
|
||||
-var 'key=value'
|
||||
Variable for template, can be used multiple times.
|
||||
|
||||
-var-file=path
|
||||
Path to HCL2 file containing user variables.
|
||||
|
||||
-verbose
|
||||
Increase diff verbosity.
|
||||
`
|
||||
|
@ -97,6 +103,7 @@ func (c *JobPlanCommand) AutocompleteFlags() complete.Flags {
|
|||
"-verbose": complete.PredictNothing,
|
||||
"-hcl1": complete.PredictNothing,
|
||||
"-var": complete.PredictAnything,
|
||||
"-var-file": complete.PredictFiles("*.var"),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -107,7 +114,7 @@ func (c *JobPlanCommand) AutocompleteArgs() complete.Predictor {
|
|||
func (c *JobPlanCommand) Name() string { return "job plan" }
|
||||
func (c *JobPlanCommand) Run(args []string) int {
|
||||
var diff, policyOverride, verbose bool
|
||||
var varArgs cflags.AppendSliceValue
|
||||
var varArgs, varFiles cflags.AppendSliceValue
|
||||
|
||||
flags := c.Meta.FlagSet(c.Name(), FlagSetClient)
|
||||
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||
|
@ -116,6 +123,7 @@ func (c *JobPlanCommand) Run(args []string) int {
|
|||
flags.BoolVar(&verbose, "verbose", false, "")
|
||||
flags.BoolVar(&c.JobGetter.hcl1, "hcl1", false, "")
|
||||
flags.Var(&varArgs, "var", "")
|
||||
flags.Var(&varFiles, "var-file", "")
|
||||
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 255
|
||||
|
@ -131,7 +139,7 @@ func (c *JobPlanCommand) Run(args []string) int {
|
|||
|
||||
path := args[0]
|
||||
// Get Job struct from Jobfile
|
||||
job, err := c.JobGetter.ApiJobWithArgs(args[0], parseVars(varArgs))
|
||||
job, err := c.JobGetter.ApiJobWithArgs(args[0], varArgs, varFiles)
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error getting job struct: %s", err))
|
||||
return 255
|
||||
|
|
|
@ -109,6 +109,12 @@ Run Options:
|
|||
If set, the passed Vault namespace is stored in the job before sending to the
|
||||
Nomad servers.
|
||||
|
||||
-var 'key=value'
|
||||
Variable for template, can be used multiple times.
|
||||
|
||||
-var-file=path
|
||||
Path to HCL2 file containing user variables.
|
||||
|
||||
-verbose
|
||||
Display full information.
|
||||
`
|
||||
|
@ -133,6 +139,7 @@ func (c *JobRunCommand) AutocompleteFlags() complete.Flags {
|
|||
"-preserve-counts": complete.PredictNothing,
|
||||
"-hcl1": complete.PredictNothing,
|
||||
"-var": complete.PredictAnything,
|
||||
"-var-file": complete.PredictFiles("*.var"),
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -145,7 +152,7 @@ func (c *JobRunCommand) Name() string { return "job run" }
|
|||
func (c *JobRunCommand) Run(args []string) int {
|
||||
var detach, verbose, output, override, preserveCounts bool
|
||||
var checkIndexStr, consulToken, vaultToken, vaultNamespace string
|
||||
var varArgs cflags.AppendSliceValue
|
||||
var varArgs, varFiles cflags.AppendSliceValue
|
||||
|
||||
flags := c.Meta.FlagSet(c.Name(), FlagSetClient)
|
||||
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||
|
@ -160,6 +167,7 @@ func (c *JobRunCommand) Run(args []string) int {
|
|||
flags.StringVar(&vaultToken, "vault-token", "", "")
|
||||
flags.StringVar(&vaultNamespace, "vault-namespace", "", "")
|
||||
flags.Var(&varArgs, "var", "")
|
||||
flags.Var(&varFiles, "var-file", "")
|
||||
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
|
@ -180,7 +188,7 @@ func (c *JobRunCommand) Run(args []string) int {
|
|||
}
|
||||
|
||||
// Get Job struct from Jobfile
|
||||
job, err := c.JobGetter.ApiJobWithArgs(args[0], parseVars(varArgs))
|
||||
job, err := c.JobGetter.ApiJobWithArgs(args[0], varArgs, varFiles)
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error getting job struct: %s", err))
|
||||
return 1
|
||||
|
|
|
@ -33,6 +33,13 @@ Validate Options:
|
|||
|
||||
-hcl1
|
||||
Parses the job file as HCLv1.
|
||||
|
||||
-var 'key=value'
|
||||
Variable for template, can be used multiple times.
|
||||
|
||||
-var-file=path
|
||||
Path to HCL2 file containing user variables.
|
||||
|
||||
`
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -43,8 +50,9 @@ func (c *JobValidateCommand) Synopsis() string {
|
|||
|
||||
func (c *JobValidateCommand) AutocompleteFlags() complete.Flags {
|
||||
return complete.Flags{
|
||||
"-hcl1": complete.PredictNothing,
|
||||
"-var": complete.PredictAnything,
|
||||
"-hcl1": complete.PredictNothing,
|
||||
"-var": complete.PredictAnything,
|
||||
"-var-file": complete.PredictFiles("*.var"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,12 +63,13 @@ func (c *JobValidateCommand) AutocompleteArgs() complete.Predictor {
|
|||
func (c *JobValidateCommand) Name() string { return "job validate" }
|
||||
|
||||
func (c *JobValidateCommand) Run(args []string) int {
|
||||
var varArgs cflags.AppendSliceValue
|
||||
var varArgs, varFiles cflags.AppendSliceValue
|
||||
|
||||
flags := c.Meta.FlagSet(c.Name(), FlagSetNone)
|
||||
flags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||
flags.BoolVar(&c.JobGetter.hcl1, "hcl1", false, "")
|
||||
flags.Var(&varArgs, "var", "")
|
||||
flags.Var(&varFiles, "var-file", "")
|
||||
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
|
@ -75,7 +84,7 @@ func (c *JobValidateCommand) Run(args []string) int {
|
|||
}
|
||||
|
||||
// Get Job struct from Jobfile
|
||||
job, err := c.JobGetter.ApiJobWithArgs(args[0], parseVars(varArgs))
|
||||
job, err := c.JobGetter.ApiJobWithArgs(args[0], varArgs, varFiles)
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error getting job struct: %s", err))
|
||||
return 1
|
||||
|
|
Loading…
Reference in New Issue