mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
Merge pull request #32610 from hashicorp/TF-4115-backport-generic-hostname-configuration-in-cli-to-backend-remote
Backport support for generic hostname to backend/remote
This commit is contained in:
commit
6ad7c8ba9b
@ -41,7 +41,7 @@ ENHANCEMENTS:
|
||||
* backend/oss: More robustly handle endpoint retrieval error ([#32295](https://github.com/hashicorp/terraform/issues/32295))
|
||||
* local-exec provisioner: Added `quiet` argument. If `quiet` is set to `true`, Terraform will not print the entire command to stdout during plan. [GH-32116]
|
||||
* backend/http: Add support for mTLS authentication. [GH-31699]
|
||||
* cloud: Add support for using the [generic hostname](https://developer.hashicorp.com/terraform/cloud-docs/registry/using#generic-hostname-terraform-enterprise) localterraform.com in module and provider sources as a substitute for the currently configured cloud backend hostname.
|
||||
* cloud: Add support for using the [generic hostname](https://developer.hashicorp.com/terraform/cloud-docs/registry/using#generic-hostname-terraform-enterprise) localterraform.com in module and provider sources as a substitute for the currently configured cloud backend hostname. This enhancement was also applied to the remote backend.
|
||||
|
||||
EXPERIMENTS:
|
||||
|
||||
|
@ -36,6 +36,7 @@ const (
|
||||
defaultParallelism = 10
|
||||
stateServiceID = "state.v2"
|
||||
tfeServiceID = "tfe.v2.1"
|
||||
genericHostname = "localterraform.com"
|
||||
)
|
||||
|
||||
// Remote is an implementation of EnhancedBackend that performs all
|
||||
@ -194,6 +195,23 @@ func (b *Remote) PrepareConfig(obj cty.Value) (cty.Value, tfdiags.Diagnostics) {
|
||||
return obj, diags
|
||||
}
|
||||
|
||||
// configureGenericHostname aliases the remote backend hostname configuration
|
||||
// as a generic "localterraform.com" hostname. This was originally added as a
|
||||
// Terraform Enterprise feature and is useful for re-using whatever the
|
||||
// Cloud/Enterprise backend host is in nested module sources in order
|
||||
// to prevent code churn when re-using config between multiple
|
||||
// Terraform Enterprise environments.
|
||||
func (b *Remote) configureGenericHostname() {
|
||||
// This won't be an error for the given constant value
|
||||
genericHost, _ := svchost.ForComparison(genericHostname)
|
||||
|
||||
// This won't be an error because, by this time, the hostname has been parsed and
|
||||
// service discovery requests made against it.
|
||||
targetHost, _ := svchost.ForComparison(b.hostname)
|
||||
|
||||
b.services.Alias(genericHost, targetHost)
|
||||
}
|
||||
|
||||
// Configure implements backend.Enhanced.
|
||||
func (b *Remote) Configure(obj cty.Value) tfdiags.Diagnostics {
|
||||
var diags tfdiags.Diagnostics
|
||||
@ -296,6 +314,8 @@ func (b *Remote) Configure(obj cty.Value) tfdiags.Diagnostics {
|
||||
return diags
|
||||
}
|
||||
|
||||
b.configureGenericHostname()
|
||||
|
||||
cfg := &tfe.Config{
|
||||
Address: service.String(),
|
||||
BasePath: service.Path,
|
||||
|
@ -194,7 +194,7 @@ func (b *Cloud) PrepareConfig(obj cty.Value) (cty.Value, tfdiags.Diagnostics) {
|
||||
return obj, diags
|
||||
}
|
||||
|
||||
// configureGenericHost aliases the cloud backend hostname configuration
|
||||
// configureGenericHostname aliases the cloud backend hostname configuration
|
||||
// as a generic "localterraform.com" hostname. This was originally added as a
|
||||
// Terraform Enterprise feature and is useful for re-using whatever the
|
||||
// Cloud/Enterprise backend host is in nested module sources in order
|
||||
|
Loading…
Reference in New Issue
Block a user