command: f.Close instead of defer
This commit is contained in:
parent
21370b8e23
commit
80ce9ad513
|
@ -82,8 +82,8 @@ func (c *ApplyCommand) Run(args []string) int {
|
||||||
log.Printf("[INFO] Writing backup state to: %s", backupPath)
|
log.Printf("[INFO] Writing backup state to: %s", backupPath)
|
||||||
f, err := os.Create(backupPath)
|
f, err := os.Create(backupPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
defer f.Close()
|
|
||||||
err = terraform.WriteState(c.State, f)
|
err = terraform.WriteState(c.State, f)
|
||||||
|
f.Close()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Error writing backup state file: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error writing backup state file: %s", err))
|
||||||
|
|
|
@ -80,8 +80,8 @@ func (c *PlanCommand) Run(args []string) int {
|
||||||
log.Printf("[INFO] Writing backup state to: %s", backupPath)
|
log.Printf("[INFO] Writing backup state to: %s", backupPath)
|
||||||
f, err := os.Create(backupPath)
|
f, err := os.Create(backupPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
defer f.Close()
|
|
||||||
err = terraform.WriteState(c.State, f)
|
err = terraform.WriteState(c.State, f)
|
||||||
|
f.Close()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Error writing backup state file: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error writing backup state file: %s", err))
|
||||||
|
|
|
@ -98,8 +98,8 @@ func (c *RefreshCommand) Run(args []string) int {
|
||||||
log.Printf("[INFO] Writing backup state to: %s", backupPath)
|
log.Printf("[INFO] Writing backup state to: %s", backupPath)
|
||||||
f, err := os.Create(backupPath)
|
f, err := os.Create(backupPath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
defer f.Close()
|
|
||||||
err = terraform.WriteState(c.State, f)
|
err = terraform.WriteState(c.State, f)
|
||||||
|
f.Close()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Error writing backup state file: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error writing backup state file: %s", err))
|
||||||
|
|
Loading…
Reference in New Issue