refactor getSchemas

This commit is contained in:
Megan Bang
2022-08-29 11:10:03 -05:00
parent 344379f5c7
commit 00cc1ea26d
10 changed files with 87 additions and 173 deletions

View File

@@ -3,7 +3,6 @@ package command
import (
"fmt"
"github.com/hashicorp/terraform/internal/terraform"
"os"
"strings"
"github.com/hashicorp/terraform/internal/addrs"
@@ -167,24 +166,14 @@ func (c *UntaintCommand) Run(args []string) int {
}
// Get schemas, if possible, before writing state
schemas := &terraform.Schemas{}
path, err := os.Getwd()
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()
var schemas *terraform.Schemas
if isCloudMode(b) {
schemas, diags = c.GetSchemas(state)
if diags.HasErrors() {
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
}
}
if schemaErr && isCloudMode(b) {
c.Ui.Warn(fmt.Sprintf(failedToLoadSchemasMessage, err))
}
obj.Status = states.ObjectReady
ss.SetResourceInstanceCurrent(addr, obj, rs.ProviderConfig)