From f107a4bc33ce9c07023e901cdab621921768225c Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 8 May 2018 11:33:04 -0700 Subject: [PATCH] addrs: Generate special string for invalid ProviderConfig The zero value of ProviderConfig is not a valid provider config address, so we'll generate a special string for that in order to make that clear in case one sneaks in somewhere. This can happen, for example, in the core flow of resolving provider inheritance during the ProviderTransformer if a caller attempts to access the resolved provider before that transformer has run. --- addrs/provider_config.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addrs/provider_config.go b/addrs/provider_config.go index 2b03a35ef..5fcab4132 100644 --- a/addrs/provider_config.go +++ b/addrs/provider_config.go @@ -84,6 +84,11 @@ func (pc ProviderConfig) Absolute(module ModuleInstance) AbsProviderConfig { } func (pc ProviderConfig) String() string { + if pc.Type == "" { + // Should never happen; always indicates a bug + return "provider." + } + if pc.Alias != "" { return fmt.Sprintf("provider.%s.%s", pc.Type, pc.Alias) }