mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-25 16:31:10 -06:00
add warning to diags and show at the end of each command
This commit is contained in:
parent
5eaa4c45c0
commit
4d749e2813
@ -251,9 +251,10 @@ func (c *ImportCommand) Run(args []string) int {
|
||||
// Get schemas, if possible, before writing state
|
||||
var schemas *terraform.Schemas
|
||||
if isCloudMode(b) {
|
||||
schemas, diags = c.MaybeGetSchemas(newState, nil)
|
||||
if diags.HasErrors() {
|
||||
c.Ui.Warn(failedToLoadSchemasMessage)
|
||||
var schemaDiags tfdiags.Diagnostics
|
||||
schemas, schemaDiags = c.MaybeGetSchemas(newState, nil)
|
||||
if schemaDiags.HasErrors() {
|
||||
diags = diags.Append(schemaDiags)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -792,14 +792,14 @@ func (c *Meta) MaybeGetSchemas(state *states.State, config *configs.Config) (*te
|
||||
|
||||
path, err := os.Getwd()
|
||||
if err != nil {
|
||||
diags.Append(err)
|
||||
diags.Append(tfdiags.SimpleWarning(failedToLoadSchemasMessage))
|
||||
return nil, diags
|
||||
}
|
||||
|
||||
if config == nil {
|
||||
config, diags = c.loadConfig(path)
|
||||
if diags.HasErrors() {
|
||||
diags.Append(diags)
|
||||
diags.Append(tfdiags.SimpleWarning(failedToLoadSchemasMessage))
|
||||
return nil, diags
|
||||
}
|
||||
}
|
||||
|
@ -396,9 +396,10 @@ func (c *StateMvCommand) Run(args []string) int {
|
||||
// Get schemas, if possible, before writing state
|
||||
var schemas *terraform.Schemas
|
||||
if isCloudMode(b) {
|
||||
schemas, diags = c.MaybeGetSchemas(stateTo, nil)
|
||||
if diags.HasErrors() {
|
||||
c.Ui.Warn(failedToLoadSchemasMessage)
|
||||
var schemaDiags tfdiags.Diagnostics
|
||||
schemas, schemaDiags = c.MaybeGetSchemas(stateTo, nil)
|
||||
if schemaDiags.HasErrors() {
|
||||
diags = diags.Append(schemaDiags)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -131,12 +131,9 @@ func (c *StatePushCommand) Run(args []string) int {
|
||||
|
||||
// Get schemas, if possible, before writing state
|
||||
var schemas *terraform.Schemas
|
||||
if isCloudMode(b) {
|
||||
var diags tfdiags.Diagnostics
|
||||
if isCloudMode(b) {
|
||||
schemas, diags = c.MaybeGetSchemas(srcStateFile.State, nil)
|
||||
if diags.HasErrors() {
|
||||
c.Ui.Warn(failedToLoadSchemasMessage)
|
||||
}
|
||||
}
|
||||
|
||||
if err := stateMgr.WriteState(srcStateFile.State); err != nil {
|
||||
@ -148,6 +145,7 @@ func (c *StatePushCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
c.showDiagnostics(diags)
|
||||
return 0
|
||||
}
|
||||
|
||||
|
@ -171,9 +171,10 @@ func (c *StateReplaceProviderCommand) Run(args []string) int {
|
||||
// Get schemas, if possible, before writing state
|
||||
var schemas *terraform.Schemas
|
||||
if isCloudMode(b) {
|
||||
schemas, diags = c.MaybeGetSchemas(state, nil)
|
||||
if diags.HasErrors() {
|
||||
c.Ui.Warn(failedToLoadSchemasMessage)
|
||||
var schemaDiags tfdiags.Diagnostics
|
||||
schemas, schemaDiags = c.MaybeGetSchemas(state, nil)
|
||||
if schemaDiags.HasErrors() {
|
||||
diags = diags.Append(schemaDiags)
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,6 +188,7 @@ func (c *StateReplaceProviderCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
c.showDiagnostics(diags)
|
||||
c.Ui.Output(fmt.Sprintf("\nSuccessfully replaced provider for %d resources.", len(willReplace)))
|
||||
return 0
|
||||
}
|
||||
|
@ -121,9 +121,10 @@ func (c *StateRmCommand) Run(args []string) int {
|
||||
// Get schemas, if possible, before writing state
|
||||
var schemas *terraform.Schemas
|
||||
if isCloudMode(b) {
|
||||
schemas, diags = c.MaybeGetSchemas(state, nil)
|
||||
if diags.HasErrors() {
|
||||
c.Ui.Warn(failedToLoadSchemasMessage)
|
||||
var schemaDiags tfdiags.Diagnostics
|
||||
schemas, schemaDiags = c.MaybeGetSchemas(state, nil)
|
||||
if schemaDiags.HasErrors() {
|
||||
diags = diags.Append(schemaDiags)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,9 +129,10 @@ func (c *TaintCommand) Run(args []string) int {
|
||||
// Get schemas, if possible, before writing state
|
||||
var schemas *terraform.Schemas
|
||||
if isCloudMode(b) {
|
||||
schemas, diags = c.MaybeGetSchemas(state, nil)
|
||||
if diags.HasErrors() {
|
||||
c.Ui.Warn(failedToLoadSchemasMessage)
|
||||
var schemaDiags tfdiags.Diagnostics
|
||||
schemas, schemaDiags = c.MaybeGetSchemas(state, nil)
|
||||
if schemaDiags.HasErrors() {
|
||||
diags = diags.Append(schemaDiags)
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,6 +187,7 @@ func (c *TaintCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
c.showDiagnostics(diags)
|
||||
c.Ui.Output(fmt.Sprintf("Resource instance %s has been marked as tainted.", addr))
|
||||
return 0
|
||||
}
|
||||
|
@ -168,9 +168,10 @@ func (c *UntaintCommand) Run(args []string) int {
|
||||
// Get schemas, if possible, before writing state
|
||||
var schemas *terraform.Schemas
|
||||
if isCloudMode(b) {
|
||||
schemas, diags = c.MaybeGetSchemas(state, nil)
|
||||
if diags.HasErrors() {
|
||||
c.Ui.Warn(failedToLoadSchemasMessage)
|
||||
var schemaDiags tfdiags.Diagnostics
|
||||
schemas, schemaDiags = c.MaybeGetSchemas(state, nil)
|
||||
if schemaDiags.HasErrors() {
|
||||
diags = diags.Append(schemaDiags)
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,6 +187,7 @@ func (c *UntaintCommand) Run(args []string) int {
|
||||
return 1
|
||||
}
|
||||
|
||||
c.showDiagnostics(diags)
|
||||
c.Ui.Output(fmt.Sprintf("Resource instance %s has been successfully untainted.", addr))
|
||||
return 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user