Simplify/Consolidate the cloud conditionals
This commit is contained in:
parent
ab304d831f
commit
e16c53b561
|
@ -592,31 +592,25 @@ func (m *Meta) backendFromConfig(opts *BackendOpts) (backend.Backend, tfdiags.Di
|
||||||
|
|
||||||
return m.backend_c_r_S(c, cHash, sMgr, true)
|
return m.backend_c_r_S(c, cHash, sMgr, true)
|
||||||
|
|
||||||
// Configuring Terraform Cloud for the first time.
|
// Configuring a backend for the first time.
|
||||||
// NOTE: There may be an implicit local backend with state that is not visible to this block.
|
case c != nil && s.Backend.Empty():
|
||||||
case c != nil && c.Type == "cloud" && s.Backend.Empty():
|
log.Printf("[TRACE] Meta.Backend: moving from default local state only to %q backend", c.Type)
|
||||||
log.Printf("[TRACE] Meta.Backend: moving from default local state only to Terraform Cloud")
|
|
||||||
if !opts.Init {
|
if !opts.Init {
|
||||||
|
if c.Type == "cloud" {
|
||||||
|
// NOTE: There may be an implicit local backend with state that is not visible to this block.
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Terraform Cloud has been configured but needs to be initialized.",
|
"Terraform Cloud has been configured but needs to be initialized.",
|
||||||
strings.TrimSpace(errBackendInitCloud),
|
strings.TrimSpace(errBackendInitCloud),
|
||||||
))
|
))
|
||||||
return nil, diags
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
return m.backend_C_r_s(c, cHash, sMgr)
|
|
||||||
|
|
||||||
// Configuring a backend for the first time.
|
|
||||||
case c != nil && s.Backend.Empty():
|
|
||||||
log.Printf("[TRACE] Meta.Backend: moving from default local state only to %q backend", c.Type)
|
|
||||||
if !opts.Init {
|
|
||||||
initReason := fmt.Sprintf("Initial configuration of the requested backend %q", c.Type)
|
initReason := fmt.Sprintf("Initial configuration of the requested backend %q", c.Type)
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Backend initialization required, please run \"terraform init\"",
|
"Backend initialization required, please run \"terraform init\"",
|
||||||
fmt.Sprintf(strings.TrimSpace(errBackendInit), initReason),
|
fmt.Sprintf(strings.TrimSpace(errBackendInit), initReason),
|
||||||
))
|
))
|
||||||
|
}
|
||||||
return nil, diags
|
return nil, diags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue