]>
Commit | Line | Data |
---|---|---|
15c0b25d AP |
1 | package registry |
2 | ||
3 | import ( | |
4 | "fmt" | |
5 | ||
6 | "github.com/hashicorp/terraform/registry/regsrc" | |
107c1cdb | 7 | "github.com/hashicorp/terraform/svchost/disco" |
15c0b25d AP |
8 | ) |
9 | ||
10 | type errModuleNotFound struct { | |
11 | addr *regsrc.Module | |
12 | } | |
13 | ||
14 | func (e *errModuleNotFound) Error() string { | |
15 | return fmt.Sprintf("module %s not found", e.addr) | |
16 | } | |
17 | ||
18 | // IsModuleNotFound returns true only if the given error is a "module not found" | |
19 | // error. This allows callers to recognize this particular error condition | |
20 | // as distinct from operational errors such as poor network connectivity. | |
21 | func IsModuleNotFound(err error) bool { | |
22 | _, ok := err.(*errModuleNotFound) | |
23 | return ok | |
24 | } | |
107c1cdb ND |
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 | } |