command: make state unexported on Meta
This commit is contained in:
parent
80ce9ad513
commit
b172f45b94
|
@ -78,11 +78,11 @@ func (c *ApplyCommand) Run(args []string) int {
|
|||
}
|
||||
|
||||
// Create a backup of the state before updating
|
||||
if backupPath != "-" && c.State != nil {
|
||||
if backupPath != "-" && c.state != nil {
|
||||
log.Printf("[INFO] Writing backup state to: %s", backupPath)
|
||||
f, err := os.Create(backupPath)
|
||||
if err == nil {
|
||||
err = terraform.WriteState(c.State, f)
|
||||
err = terraform.WriteState(c.state, f)
|
||||
f.Close()
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
@ -16,7 +16,10 @@ type Meta struct {
|
|||
Color bool
|
||||
ContextOpts *terraform.ContextOpts
|
||||
Ui cli.Ui
|
||||
State *terraform.State
|
||||
|
||||
// State read when calling `Context`. This is available after calling
|
||||
// `Context`.
|
||||
state *terraform.State
|
||||
|
||||
// This can be set by the command itself to provide extra hooks.
|
||||
extraHooks []terraform.Hook
|
||||
|
@ -79,7 +82,7 @@ func (m *Meta) Context(path, statePath string) (*terraform.Context, bool, error)
|
|||
}
|
||||
|
||||
// Store the loaded state
|
||||
m.State = state
|
||||
m.state = state
|
||||
|
||||
config, err := config.LoadDir(path)
|
||||
if err != nil {
|
||||
|
@ -93,7 +96,6 @@ func (m *Meta) Context(path, statePath string) (*terraform.Context, bool, error)
|
|||
opts.State = state
|
||||
ctx := terraform.NewContext(opts)
|
||||
return ctx, false, nil
|
||||
|
||||
}
|
||||
|
||||
// contextOpts returns the options to use to initialize a Terraform
|
||||
|
|
|
@ -76,11 +76,11 @@ func (c *PlanCommand) Run(args []string) int {
|
|||
|
||||
if refresh {
|
||||
// Create a backup of the state before updating
|
||||
if backupPath != "-" && c.State != nil {
|
||||
if backupPath != "-" && c.state != nil {
|
||||
log.Printf("[INFO] Writing backup state to: %s", backupPath)
|
||||
f, err := os.Create(backupPath)
|
||||
if err == nil {
|
||||
err = terraform.WriteState(c.State, f)
|
||||
err = terraform.WriteState(c.state, f)
|
||||
f.Close()
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
@ -94,11 +94,11 @@ func (c *RefreshCommand) Run(args []string) int {
|
|||
}
|
||||
|
||||
// Create a backup of the state before updating
|
||||
if backupPath != "-" && c.State != nil {
|
||||
if backupPath != "-" && c.state != nil {
|
||||
log.Printf("[INFO] Writing backup state to: %s", backupPath)
|
||||
f, err := os.Create(backupPath)
|
||||
if err == nil {
|
||||
err = terraform.WriteState(c.State, f)
|
||||
err = terraform.WriteState(c.state, f)
|
||||
f.Close()
|
||||
}
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue