mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Always use token in backend config when provided
This commit is contained in:
parent
39bbcf2f9c
commit
23dffee568
@ -256,24 +256,25 @@ func (b *Remote) Configure(obj cty.Value) tfdiags.Diagnostics {
|
|||||||
return diags
|
return diags
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the token for this host as configured in the credentials
|
// Get the token from the config.
|
||||||
// section of the CLI Config File.
|
var token string
|
||||||
token, err := b.token()
|
if val := obj.GetAttr("token"); !val.IsNull() {
|
||||||
if err != nil {
|
token = val.AsString()
|
||||||
diags = diags.Append(tfdiags.AttributeValue(
|
|
||||||
tfdiags.Error,
|
|
||||||
strings.ToUpper(err.Error()[:1])+err.Error()[1:],
|
|
||||||
"", // no description is needed here, the error is clear
|
|
||||||
cty.Path{cty.GetAttrStep{Name: "hostname"}},
|
|
||||||
))
|
|
||||||
return diags
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the token from the config if no token was configured for this
|
// Retrieve the token for this host as configured in the credentials
|
||||||
// host in credentials section of the CLI Config File.
|
// section of the CLI Config File if no token was configured for this
|
||||||
|
// host in the config.
|
||||||
if token == "" {
|
if token == "" {
|
||||||
if val := obj.GetAttr("token"); !val.IsNull() {
|
token, err = b.token()
|
||||||
token = val.AsString()
|
if err != nil {
|
||||||
|
diags = diags.Append(tfdiags.AttributeValue(
|
||||||
|
tfdiags.Error,
|
||||||
|
strings.ToUpper(err.Error()[:1])+err.Error()[1:],
|
||||||
|
"", // no description is needed here, the error is clear
|
||||||
|
cty.Path{cty.GetAttrStep{Name: "hostname"}},
|
||||||
|
))
|
||||||
|
return diags
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user