Merge pull request #20944 from pselle/registry-link

Only display status link if public registry used
This commit is contained in:
Pam Selle 2019-04-08 10:25:10 -04:00 committed by GitHub
commit c514867367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 3 deletions

View File

@ -504,7 +504,7 @@ func (c *InitCommand) getProviders(earlyConfig *earlyconfig.Config, state *state
}
switch {
case err == discovery.ErrorServiceUnreachable:
case err == discovery.ErrorServiceUnreachable, err == discovery.ErrorPublicRegistryUnreachable:
c.Ui.Error(errDiscoveryServiceUnreachable)
case err == discovery.ErrorNoSuchProvider:
c.Ui.Error(fmt.Sprintf(errProviderNotFound, provider, DefaultPluginVendorDir))
@ -884,8 +884,6 @@ const errDiscoveryServiceUnreachable = `
[reset][bold][red]Registry service unreachable.[reset][red]
This may indicate a network issue, or an issue with the requested Terraform Registry.
Check https://status.hashicorp.com/ for registry status updates.
`
const errProviderNotFound = `

View File

@ -55,6 +55,10 @@ const ErrorSignatureVerification = Error("unable to verify signature")
// to the registry service
const ErrorServiceUnreachable = Error("registry service is unreachable")
// ErrorPublicRegistryUnreachable indicates that the network was unable to connect
// to the public registry in particular, so we can show a link to the statuspage
const ErrorPublicRegistryUnreachable = Error("registry service is unreachable, check https://status.hashicorp.com/ for status updates")
func (err Error) Error() string {
return string(err)
}

View File

@ -127,6 +127,10 @@ func (i *ProviderInstaller) Get(provider string, req Constraints) (PluginMeta, t
if err != nil {
log.Printf("[DEBUG] %s", err)
if registry.IsServiceUnreachable(err) {
registryHost, err := i.hostname()
if err == nil && registryHost == regsrc.PublicRegistryHost.Raw {
return PluginMeta{}, diags, ErrorPublicRegistryUnreachable
}
return PluginMeta{}, diags, ErrorServiceUnreachable
}
if registry.IsServiceNotProvided(err) {