mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-20 11:48:24 -06:00
command/*: only Plan on the Apply
This commit is contained in:
parent
ad3c0593a3
commit
6c8c09c784
@ -64,7 +64,7 @@ func (c *ApplyCommand) Run(args []string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build the context based on the arguments given
|
// Build the context based on the arguments given
|
||||||
ctx, err := c.Context(configPath, planStatePath)
|
ctx, err := c.Context(configPath, planStatePath, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(err.Error())
|
c.Ui.Error(err.Error())
|
||||||
return 1
|
return 1
|
||||||
|
@ -40,7 +40,7 @@ func (c *GraphCommand) Run(args []string) int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, err := c.Context(path, "")
|
ctx, err := c.Context(path, "", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Error loading Terraform: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error loading Terraform: %s", err))
|
||||||
return 1
|
return 1
|
||||||
|
@ -30,7 +30,7 @@ func (m *Meta) Colorize() *colorstring.Colorize {
|
|||||||
|
|
||||||
// Context returns a Terraform Context taking into account the context
|
// Context returns a Terraform Context taking into account the context
|
||||||
// options used to initialize this meta configuration.
|
// options used to initialize this meta configuration.
|
||||||
func (m *Meta) Context(path, statePath string) (*terraform.Context, error) {
|
func (m *Meta) Context(path, statePath string, doPlan bool) (*terraform.Context, error) {
|
||||||
opts := m.contextOpts()
|
opts := m.contextOpts()
|
||||||
|
|
||||||
// First try to just read the plan directly from the path given.
|
// First try to just read the plan directly from the path given.
|
||||||
@ -84,8 +84,10 @@ func (m *Meta) Context(path, statePath string) (*terraform.Context, error) {
|
|||||||
opts.State = state
|
opts.State = state
|
||||||
ctx := terraform.NewContext(opts)
|
ctx := terraform.NewContext(opts)
|
||||||
|
|
||||||
if _, err := ctx.Plan(nil); err != nil {
|
if doPlan {
|
||||||
return nil, fmt.Errorf("Error running plan: %s", err)
|
if _, err := ctx.Plan(nil); err != nil {
|
||||||
|
return nil, fmt.Errorf("Error running plan: %s", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx, nil
|
return ctx, nil
|
||||||
|
@ -59,7 +59,7 @@ func (c *PlanCommand) Run(args []string) int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, err := c.Context(path, statePath)
|
ctx, err := c.Context(path, statePath, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(err.Error())
|
c.Ui.Error(err.Error())
|
||||||
return 1
|
return 1
|
||||||
|
@ -78,7 +78,7 @@ func (c *RefreshCommand) Run(args []string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build the context based on the arguments given
|
// Build the context based on the arguments given
|
||||||
ctx, err := c.Context(configPath, statePath)
|
ctx, err := c.Context(configPath, statePath, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(err.Error())
|
c.Ui.Error(err.Error())
|
||||||
return 1
|
return 1
|
||||||
|
Loading…
Reference in New Issue
Block a user