This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
/
error.go
91 lines (74 loc) · 2.53 KB
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package cloudconfigblob
import (
"strings"
"github.com/giantswarm/microerror"
)
// executionFailedError is an error type for situations where Resource
// execution cannot continue and must always fall back to operatorkit.
//
// This error should never be matched against and therefore there is no matcher
// implement. For further information see:
//
// https://github.com/giantswarm/fmt/blob/master/go/errors.md#matching-errors
//
var executionFailedError = µerror.Error{
Kind: "executionFailedError",
}
var invalidConfigError = µerror.Error{
Kind: "invalidConfigError",
}
// IsInvalidConfig asserts invalidConfigError.
func IsInvalidConfig(err error) bool {
return microerror.Cause(err) == invalidConfigError
}
// IsNotFound asserts storage account not found error from upstream's API message.
func IsNotFound(err error) bool {
if err == nil {
return false
}
return strings.Contains(microerror.Cause(err).Error(), "ResourceNotFound") ||
strings.Contains(microerror.Cause(err).Error(), "ResourceGroupNotFound") ||
strings.Contains(microerror.Cause(err).Error(), "StorageAccountNotFound")
}
// IsStorageAccountNotProvisioned asserts storage account not provisioned error from upstream's API message.
func IsStorageAccountNotProvisioned(err error) bool {
if err == nil {
return false
}
return strings.Contains(microerror.Cause(err).Error(), "StorageAccountIsNotProvisioned")
}
var timeoutError = µerror.Error{
Kind: "timeoutError",
}
// IsTimeout asserts timeoutError.
func IsTimeout(err error) bool {
return microerror.Cause(err) == timeoutError
}
var tooManyCredentialsError = µerror.Error{
Kind: "tooManyCredentialsError",
}
// IsTooManyCredentialsError asserts tooManyCredentialsError.
func IsTooManyCredentialsError(err error) bool {
return microerror.Cause(err) == tooManyCredentialsError
}
var missingOrganizationLabel = µerror.Error{
Kind: "missingOrganizationLabel",
}
// IsMissingOrganizationLabel asserts missingOrganizationLabel.
func IsMissingOrganizationLabel(err error) bool {
return microerror.Cause(err) == missingOrganizationLabel
}
var bootstrapCRNotReady = µerror.Error{
Kind: "bootstrapCRNotReady",
}
// IsMissingCloudConfigSecret asserts bootstrapCRNotReady.
func IsBootstrapCRNotReady(err error) bool {
return microerror.Cause(err) == bootstrapCRNotReady
}
var ownerReferenceNotSet = µerror.Error{
Kind: "ownerReferenceNotSet",
}
// IsOwnerReferenceNotSet asserts ownerReferenceNotSet.
func IsOwnerReferenceNotSet(err error) bool {
return microerror.Cause(err) == ownerReferenceNotSet
}