mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
update flow of schema checking
This commit is contained in:
parent
12e3560d21
commit
d5decc2407
@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hashicorp/terraform/internal/terraform"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@ -393,22 +394,25 @@ func (c *StateMvCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
// Get schemas, if possible, before writing state
|
||||
schemas := &terraform.Schemas{}
|
||||
path, err := os.Getwd()
|
||||
if err != nil && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
schemaErr := err != nil
|
||||
|
||||
if !schemaErr {
|
||||
config, diags := c.loadConfig(path)
|
||||
schemaErr = diags.HasErrors()
|
||||
|
||||
if !schemaErr {
|
||||
schemas, diags = getSchemas(&c.Meta, stateTo, config)
|
||||
schemaErr = diags.HasErrors()
|
||||
}
|
||||
}
|
||||
|
||||
config, diags := c.loadConfig(path)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
if schemaErr && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
|
||||
schemas, diags := getSchemas(&c.Meta, stateTo, config)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
return 1
|
||||
}
|
||||
|
||||
// Write the new state
|
||||
if err := stateToMgr.WriteState(stateTo); err != nil {
|
||||
c.Ui.Error(fmt.Sprintf(errStateRmPersist, err))
|
||||
|
@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hashicorp/terraform/internal/terraform"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
@ -128,18 +129,21 @@ func (c *StatePushCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
// Get schemas, if possible, before writing state
|
||||
schemas := &terraform.Schemas{}
|
||||
path, err := os.Getwd()
|
||||
if err != nil && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
schemaErr := err != nil
|
||||
|
||||
if !schemaErr {
|
||||
config, diags := c.loadConfig(path)
|
||||
schemaErr = diags.HasErrors()
|
||||
|
||||
if !schemaErr {
|
||||
schemas, diags = getSchemas(&c.Meta, srcStateFile.State, config)
|
||||
schemaErr = diags.HasErrors()
|
||||
}
|
||||
}
|
||||
|
||||
config, diags := c.loadConfig(path)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
|
||||
schemas, diags := getSchemas(&c.Meta, srcStateFile.State, config)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
if schemaErr && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hashicorp/terraform/internal/terraform"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@ -169,18 +170,21 @@ func (c *StateReplaceProviderCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
// Get schemas, if possible, before writing state
|
||||
schemas := &terraform.Schemas{}
|
||||
path, err := os.Getwd()
|
||||
if err != nil && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
schemaErr := err != nil
|
||||
|
||||
if !schemaErr {
|
||||
config, diags := c.loadConfig(path)
|
||||
schemaErr = diags.HasErrors()
|
||||
|
||||
if !schemaErr {
|
||||
schemas, diags = getSchemas(&c.Meta, state, config)
|
||||
schemaErr = diags.HasErrors()
|
||||
}
|
||||
}
|
||||
|
||||
config, diags := c.loadConfig(path)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
|
||||
schemas, diags := getSchemas(&c.Meta, state, config)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
if schemaErr && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hashicorp/terraform/internal/terraform"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@ -119,18 +120,21 @@ func (c *StateRmCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
// Get schemas, if possible, before writing state
|
||||
schemas := &terraform.Schemas{}
|
||||
path, err := os.Getwd()
|
||||
if err != nil && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
schemaErr := err != nil
|
||||
|
||||
if !schemaErr {
|
||||
config, diags := c.loadConfig(path)
|
||||
schemaErr = diags.HasErrors()
|
||||
|
||||
if !schemaErr {
|
||||
schemas, diags = getSchemas(&c.Meta, state, config)
|
||||
schemaErr = diags.HasErrors()
|
||||
}
|
||||
}
|
||||
|
||||
config, diags := c.loadConfig(path)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
|
||||
schemas, diags := getSchemas(&c.Meta, state, config)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
if schemaErr && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hashicorp/terraform/internal/terraform"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@ -127,18 +128,21 @@ func (c *TaintCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
// Get schemas, if possible, before writing state
|
||||
schemas := &terraform.Schemas{}
|
||||
path, err := os.Getwd()
|
||||
if err != nil && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
schemaErr := err != nil
|
||||
|
||||
if !schemaErr {
|
||||
config, diags := c.loadConfig(path)
|
||||
schemaErr = diags.HasErrors()
|
||||
|
||||
if !schemaErr {
|
||||
schemas, diags = getSchemas(&c.Meta, state, config)
|
||||
schemaErr = diags.HasErrors()
|
||||
}
|
||||
}
|
||||
|
||||
config, diags := c.loadConfig(path)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
|
||||
schemas, diags := getSchemas(&c.Meta, state, config)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
if schemaErr && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/hashicorp/terraform/internal/terraform"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@ -166,20 +167,24 @@ func (c *UntaintCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
// Get schemas, if possible, before writing state
|
||||
schemas := &terraform.Schemas{}
|
||||
path, err := os.Getwd()
|
||||
if err != nil && isCloudMode(b) {
|
||||
schemaErr := err != nil
|
||||
|
||||
if !schemaErr {
|
||||
config, diags := c.loadConfig(path)
|
||||
schemaErr = diags.HasErrors()
|
||||
|
||||
if !schemaErr {
|
||||
schemas, diags = getSchemas(&c.Meta, state, config)
|
||||
schemaErr = diags.HasErrors()
|
||||
}
|
||||
}
|
||||
|
||||
if schemaErr && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
|
||||
config, diags := c.loadConfig(path)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
|
||||
schemas, diags := getSchemas(&c.Meta, state, config)
|
||||
if diags.HasErrors() && isCloudMode(b) {
|
||||
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
|
||||
}
|
||||
obj.Status = states.ObjectReady
|
||||
ss.SetResourceInstanceCurrent(addr, obj, rs.ProviderConfig)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user