Skip to content

Commit

Permalink
Updating plan
Browse files Browse the repository at this point in the history
  • Loading branch information
angrycub committed Dec 1, 2020
1 parent 19af3df commit cebed25
Show file tree
Hide file tree
Showing 4 changed files with 286 additions and 78 deletions.
2 changes: 1 addition & 1 deletion command/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (c *DeployCommand) Run(args []string) int {
}

if !config.Deploy.Force {
p := levant.PlanConfig{
p := structs.LevantPlanConfig{
Client: config.Client,
Plan: config.Plan,
Template: config.Template,
Expand Down
31 changes: 25 additions & 6 deletions command/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/hashicorp/levant/levant"
"github.com/hashicorp/levant/levant/structs"
"github.com/hashicorp/levant/logging"
"github.com/hashicorp/levant/output"
"github.com/hashicorp/levant/template"
)

Expand Down Expand Up @@ -48,7 +49,15 @@ General Options:
-force-count
Use the taskgroup count from the Nomad jobfile instead of the count that
is currently set in a running job.
is currently set in a running job.
-output-format
Specify the format of plan to be emitted. Valid values include JSON, DIFF,
and NDJSON. The default is DIFF.
-output-to
Specify the destination for the diff. Valid values include CLI, LOG, STDOUT,
and STDERR. The default is LOG.
-ignore-no-changes
By default if no changes are detected when running a plan Levant will
Expand Down Expand Up @@ -81,11 +90,14 @@ func (c *PlanCommand) Synopsis() string {
func (c *PlanCommand) Run(args []string) int {

var err error
var level, format string
config := &levant.PlanConfig{
var logLevel, logFormat, outFormat, outDest string
config := &structs.LevantPlanConfig{
Client: &structs.ClientConfig{},
Plan: &structs.PlanConfig{},
Template: &structs.TemplateConfig{},
Output: &structs.DiffOutputConfig{
UI: &c.UI,
},
}

flags := c.Meta.FlagSet("plan", FlagSetVars)
Expand All @@ -95,8 +107,10 @@ func (c *PlanCommand) Run(args []string) int {
flags.BoolVar(&config.Client.AllowStale, "allow-stale", false, "")
flags.StringVar(&config.Client.ConsulAddr, "consul-address", "", "")
flags.BoolVar(&config.Plan.IgnoreNoChanges, "ignore-no-changes", false, "")
flags.StringVar(&level, "log-level", "INFO", "")
flags.StringVar(&format, "log-format", "HUMAN", "")
flags.StringVar(&logLevel, "log-level", "INFO", "")
flags.StringVar(&logFormat, "log-format", "HUMAN", "")
flags.StringVar(&outFormat, "output-format", "DIFF", "")
flags.StringVar(&outDest, "output-to", "CLI", "")
flags.Var((*helper.FlagStringSlice)(&config.Template.VariableFiles), "var-file", "")

if err = flags.Parse(args); err != nil {
Expand All @@ -105,7 +119,12 @@ func (c *PlanCommand) Run(args []string) int {

args = flags.Args()

if err = logging.SetupLogger(level, format); err != nil {
if err = logging.SetupLogger(logLevel, logFormat); err != nil {
c.UI.Error(err.Error())
return 1
}

if err = output.ConfigureOutputSettings(config, &outFormat, &outDest); err != nil {
c.UI.Error(err.Error())
return 1
}
Expand Down
Loading

0 comments on commit cebed25

Please sign in to comment.