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.
This commit is contained in:
Martin Atkins 2018-05-08 11:33:04 -07:00
parent b0b1486c46
commit f107a4bc33
1 changed files with 5 additions and 0 deletions

View File

@ -84,6 +84,11 @@ func (pc ProviderConfig) Absolute(module ModuleInstance) AbsProviderConfig {
} }
func (pc ProviderConfig) String() string { func (pc ProviderConfig) String() string {
if pc.Type == "" {
// Should never happen; always indicates a bug
return "provider.<invalid>"
}
if pc.Alias != "" { if pc.Alias != "" {
return fmt.Sprintf("provider.%s.%s", pc.Type, pc.Alias) return fmt.Sprintf("provider.%s.%s", pc.Type, pc.Alias)
} }