diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/registry/errors.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/registry/errors.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/registry/errors.go b/vendor/github.com/hashicorp/terraform/registry/errors.go index b8dcd31..5a6a31b 100644 --- a/vendor/github.com/hashicorp/terraform/registry/errors.go +++ b/vendor/github.com/hashicorp/terraform/registry/errors.go | |||
@@ -4,6 +4,7 @@ import ( | |||
4 | "fmt" | 4 | "fmt" |
5 | 5 | ||
6 | "github.com/hashicorp/terraform/registry/regsrc" | 6 | "github.com/hashicorp/terraform/registry/regsrc" |
7 | "github.com/hashicorp/terraform/svchost/disco" | ||
7 | ) | 8 | ) |
8 | 9 | ||
9 | type errModuleNotFound struct { | 10 | type errModuleNotFound struct { |
@@ -21,3 +22,42 @@ func IsModuleNotFound(err error) bool { | |||
21 | _, ok := err.(*errModuleNotFound) | 22 | _, ok := err.(*errModuleNotFound) |
22 | return ok | 23 | return ok |
23 | } | 24 | } |
25 | |||
26 | type errProviderNotFound struct { | ||
27 | addr *regsrc.TerraformProvider | ||
28 | } | ||
29 | |||
30 | func (e *errProviderNotFound) Error() string { | ||
31 | return fmt.Sprintf("provider %s not found", e.addr) | ||
32 | } | ||
33 | |||
34 | // IsProviderNotFound returns true only if the given error is a "provider not found" | ||
35 | // error. This allows callers to recognize this particular error condition | ||
36 | // as distinct from operational errors such as poor network connectivity. | ||
37 | func IsProviderNotFound(err error) bool { | ||
38 | _, ok := err.(*errProviderNotFound) | ||
39 | return ok | ||
40 | } | ||
41 | |||
42 | // IsServiceNotProvided returns true only if the given error is a "service not provided" | ||
43 | // error. This allows callers to recognize this particular error condition | ||
44 | // as distinct from operational errors such as poor network connectivity. | ||
45 | func IsServiceNotProvided(err error) bool { | ||
46 | _, ok := err.(*disco.ErrServiceNotProvided) | ||
47 | return ok | ||
48 | } | ||
49 | |||
50 | // ServiceUnreachableError Registry service is unreachable | ||
51 | type ServiceUnreachableError struct { | ||
52 | err error | ||
53 | } | ||
54 | |||
55 | func (e *ServiceUnreachableError) Error() string { | ||
56 | return e.err.Error() | ||
57 | } | ||
58 | |||
59 | // IsServiceUnreachable returns true if the registry/discovery service was unreachable | ||
60 | func IsServiceUnreachable(err error) bool { | ||
61 | _, ok := err.(*ServiceUnreachableError) | ||
62 | return ok | ||
63 | } | ||