2018-02-14 01:36:36 +01:00
|
|
|
package registry
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2019-10-11 11:34:26 +02:00
|
|
|
"github.com/hashicorp/terraform-svchost/disco"
|
2018-02-14 01:36:36 +01:00
|
|
|
"github.com/hashicorp/terraform/registry/regsrc"
|
|
|
|
)
|
|
|
|
|
|
|
|
type errModuleNotFound struct {
|
|
|
|
addr *regsrc.Module
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *errModuleNotFound) Error() string {
|
|
|
|
return fmt.Sprintf("module %s not found", e.addr)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsModuleNotFound returns true only if the given error is a "module not found"
|
|
|
|
// error. This allows callers to recognize this particular error condition
|
|
|
|
// as distinct from operational errors such as poor network connectivity.
|
|
|
|
func IsModuleNotFound(err error) bool {
|
|
|
|
_, ok := err.(*errModuleNotFound)
|
|
|
|
return ok
|
|
|
|
}
|
2018-07-27 20:59:03 +02:00
|
|
|
|
|
|
|
type errProviderNotFound struct {
|
|
|
|
addr *regsrc.TerraformProvider
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *errProviderNotFound) Error() string {
|
|
|
|
return fmt.Sprintf("provider %s not found", e.addr)
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsProviderNotFound returns true only if the given error is a "provider not found"
|
|
|
|
// error. This allows callers to recognize this particular error condition
|
|
|
|
// as distinct from operational errors such as poor network connectivity.
|
|
|
|
func IsProviderNotFound(err error) bool {
|
|
|
|
_, ok := err.(*errProviderNotFound)
|
|
|
|
return ok
|
|
|
|
}
|
2018-08-09 00:04:51 +02:00
|
|
|
|
|
|
|
// IsServiceNotProvided returns true only if the given error is a "service not provided"
|
|
|
|
// error. This allows callers to recognize this particular error condition
|
|
|
|
// as distinct from operational errors such as poor network connectivity.
|
|
|
|
func IsServiceNotProvided(err error) bool {
|
2018-12-10 11:06:05 +01:00
|
|
|
_, ok := err.(*disco.ErrServiceNotProvided)
|
2018-08-09 00:04:51 +02:00
|
|
|
return ok
|
|
|
|
}
|
2019-03-27 19:20:15 +01:00
|
|
|
|
|
|
|
// ServiceUnreachableError Registry service is unreachable
|
|
|
|
type ServiceUnreachableError struct {
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *ServiceUnreachableError) Error() string {
|
|
|
|
return e.err.Error()
|
|
|
|
}
|
|
|
|
|
|
|
|
// IsServiceUnreachable returns true if the registry/discovery service was unreachable
|
|
|
|
func IsServiceUnreachable(err error) bool {
|
|
|
|
_, ok := err.(*ServiceUnreachableError)
|
|
|
|
return ok
|
|
|
|
}
|