forked from hashicorp/go-tfe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherrors.go
263 lines (145 loc) · 9.32 KB
/
errors.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
package tfe
import (
"errors"
)
// Generic errors applicable to all resources.
var (
// ErrUnauthorized is returned when receiving a 401.
ErrUnauthorized = errors.New("unauthorized")
// ErrResourceNotFound is returned when receiving a 404.
ErrResourceNotFound = errors.New("resource not found")
// ErrMissingDirectory is returned when the path does not have an existing directory.
ErrMissingDirectory = errors.New("path needs to be an existing directory")
)
// Options/fields that cannot be defined
var (
ErrUnsupportedOperations = errors.New("operations is deprecated and cannot be specified when execution mode is used")
ErrUnsupportedPrivateKey = errors.New("private Key can only be present with Azure DevOps Server service provider")
ErrUnsupportedRunTriggerType = errors.New(`"RunTriggerType" must be "inbound" when requesting "include" query params`)
)
// Library errors that usually indicate a bug in the implementation of go-tfe
var (
ErrItemsMustBeSlice = errors.New(`model field "Items" must be a slice`) // ErrItemsMustBeSlice is returned when an API response attribute called Items is not a slice
ErrInvalidRequestBody = errors.New("go-tfe bug: DELETE/PATCH/POST body must be nil, ptr, or ptr slice") // ErrInvalidRequestBody is returned when a request body for DELETE/PATCH/POST is not a reference type
ErrInvalidStructFormat = errors.New("go-tfe bug: struct can't use both json and jsonapi attributes") // ErrInvalidStructFormat is returned when a mix of json and jsonapi tagged fields are used in the same struct
)
// Resource Errors
var (
ErrWorkspaceLocked = errors.New("workspace already locked") // ErrWorkspaceLocked is returned when trying to lock a
// locked workspace.
ErrWorkspaceNotLocked = errors.New("workspace already unlocked") // ErrWorkspaceNotLocked is returned when trying to unlock
// a unlocked workspace.
ErrWorkspaceLockedByRun = errors.New("unable to unlock workspace locked by run") // ErrWorkspaceLockedByRun is returned when trying to unlock a
// workspace locked by a run
)
// Invalid values for resources/struct fields
var (
ErrInvalidWorkspaceID = errors.New("invalid value for workspace ID")
ErrInvalidWorkspaceValue = errors.New("invalid value for workspace")
ErrInvalidTerraformVersionID = errors.New("invalid value for terraform version ID")
ErrInvalidTerraformVersionType = errors.New("invalid type for terraform version. Please use 'terraform-version'")
ErrInvalidConfigVersionID = errors.New("invalid value for configuration version ID")
ErrInvalidCostEstimateID = errors.New("invalid value for cost estimate ID")
ErrInvalidSMTPAuth = errors.New("invalid smtp auth type")
ErrInvalidAgentPoolID = errors.New("invalid value for agent pool ID")
ErrInvalidAgentTokenID = errors.New("invalid value for agent token ID")
ErrInvalidRunID = errors.New("invalid value for run ID")
ErrInvalidRunTaskCategory = errors.New(`category must be "task"`)
ErrInvalidRunTaskID = errors.New("invalid value for run task ID")
ErrInvalidRunTaskURL = errors.New("invalid url for run task URL")
ErrInvalidWorkspaceRunTaskID = errors.New("invalid value for workspace run task ID")
ErrInvalidWorkspaceRunTaskType = errors.New(`invalid value for type, please use "workspace-tasks"`)
ErrInvalidTaskResultID = errors.New("invalid value for task result ID")
ErrInvalidTaskStageID = errors.New("invalid value for task stage ID")
ErrInvalidApplyID = errors.New("invalid value for apply ID")
ErrInvalidOrg = errors.New("invalid value for organization")
ErrInvalidName = errors.New("invalid value for name")
ErrInvalidNotificationConfigID = errors.New("invalid value for notification configuration ID")
ErrInvalidMembership = errors.New("invalid value for membership")
ErrInvalidMembershipIDs = errors.New("invalid value for organization membership ids")
ErrInvalidOauthClientID = errors.New("invalid value for OAuth client ID")
ErrInvalidOauthTokenID = errors.New("invalid value for OAuth token ID")
ErrInvalidPolicySetID = errors.New("invalid value for policy set ID")
ErrInvalidPolicyCheckID = errors.New("invalid value for policy check ID")
ErrInvalidTag = errors.New("invalid tag id")
ErrInvalidPlanExportID = errors.New("invalid value for plan export ID")
ErrInvalidPlanID = errors.New("invalid value for plan ID")
ErrInvalidParamID = errors.New("invalid value for parameter ID")
ErrInvalidPolicyID = errors.New("invalid value for policy ID")
ErrInvalidProvider = errors.New("invalid value for provider")
ErrInvalidVersion = errors.New("invalid value for version")
ErrInvalidRunTriggerID = errors.New("invalid value for run trigger ID")
ErrInvalidRunTriggerType = errors.New(`invalid value or no value for RunTriggerType. It must be either "inbound" or "outbound"`)
ErrInvalidIncludeValue = errors.New(`invalid value for "include" field`)
ErrInvalidSHHKeyID = errors.New("invalid value for SSH key ID")
ErrInvalidStateVerID = errors.New("invalid value for state version ID")
ErrInvalidAccessTeamID = errors.New("invalid value for team access ID")
ErrInvalidTeamID = errors.New("invalid value for team ID")
ErrInvalidUsernames = errors.New("invalid value for usernames")
ErrInvalidUserID = errors.New("invalid value for user ID")
ErrInvalidUserValue = errors.New("invalid value for user")
ErrInvalidTokenID = errors.New("invalid value for token ID")
ErrInvalidCategory = errors.New("category must be policy-set")
ErrInvalidPolicies = errors.New("must provide at least one policy")
ErrInvalidVariableID = errors.New("invalid value for variable ID")
ErrInvalidNotificationTrigger = errors.New("invalid value for notification trigger")
ErrInvalidVariableSetID = errors.New("invalid variable set ID")
ErrInvalidCommentID = errors.New("invalid value for comment ID")
ErrInvalidCommentBody = errors.New("invalid value for comment body")
)
// Missing values for required field/option
var (
ErrRequiredAccess = errors.New("access is required")
ErrRequiredAgentPoolID = errors.New("'agent' execution mode requires an agent pool ID to be specified")
ErrRequiredAgentMode = errors.New("specifying an agent pool ID requires 'agent' execution mode")
ErrRequiredCategory = errors.New("category is required")
ErrRequiredDestinationType = errors.New("destination type is required")
ErrRequiredDataType = errors.New("data type is required")
ErrRequiredKey = errors.New("key is required")
ErrRequiredName = errors.New("name is required")
ErrRequiredEnabled = errors.New("enabled is required")
ErrRequiredEnforce = errors.New("enforce is required")
ErrRequiredEnforcementPath = errors.New("enforcement path is required")
ErrRequiredEnforcementMode = errors.New("enforcement mode is required")
ErrRequiredEmail = errors.New("email is required")
ErrRequiredM5 = errors.New("MD5 is required")
ErrRequiredURL = errors.New("url is required")
ErrRequiredAPIURL = errors.New("API URL is required")
ErrRequiredHTTPURL = errors.New("HTTP URL is required")
ErrRequiredServiceProvider = errors.New("service provider is required")
ErrRequiredProvider = errors.New("provider is required")
ErrRequiredOauthToken = errors.New("OAuth token is required")
ErrRequiredOauthTokenID = errors.New("oauth token ID is required")
ErrRequiredTestNumber = errors.New("TestNumber is required")
ErrMissingTagIdentifier = errors.New("must specify at least one tag by ID or name")
ErrAgentTokenDescription = errors.New("agent token description can't be blank")
ErrRequiredTagID = errors.New("you must specify at least one tag id to remove")
ErrRequiredTagWorkspaceID = errors.New("you must specify at least one workspace to add tag to")
ErrRequiredWorkspace = errors.New("workspace is required")
ErrRequiredWorkspaceID = errors.New("workspace ID is required")
ErrWorkspacesRequired = errors.New("workspaces is required")
ErrWorkspaceMinLimit = errors.New("must provide at least one workspace")
ErrRequiredPlan = errors.New("plan is required")
ErrRequiredPolicies = errors.New("policies is required")
ErrRequiredVersion = errors.New("version is required")
ErrRequiredVCSRepo = errors.New("vcs repo is required")
ErrRequiredIdentifier = errors.New("identifier is required")
ErrRequiredDisplayIdentifier = errors.New("display identifier is required")
ErrRequiredSha = errors.New("sha is required")
ErrRequiredSourceable = errors.New("sourceable is required")
ErrRequiredValue = errors.New("value is required")
ErrRequiredOrg = errors.New("organization is required")
ErrRequiredTeam = errors.New("team is required")
ErrRequiredStateVerListOps = errors.New("StateVersionListOptions is required")
ErrRequiredTeamAccessListOps = errors.New("TeamAccessListOptions is required")
ErrRequiredRunTriggerListOps = errors.New("RunTriggerListOptions is required")
ErrRequiredTFVerCreateOps = errors.New("version, URL and sha is required for AdminTerraformVersionCreateOptions")
ErrRequiredSerial = errors.New("serial is required")
ErrRequiredState = errors.New("state is required")
ErrRequiredSHHKeyID = errors.New("SSH key ID is required")
ErrRequiredOnlyOneField = errors.New("only one of usernames or organization membership ids can be provided")
ErrRequiredUsernameOrMembershipIds = errors.New("usernames or organization membership ids are required")
ErrRequiredGlobalFlag = errors.New("global flag is required")
ErrRequiredWorkspacesList = errors.New("no workspaces list provided")
ErrCommentBody = errors.New("comment body is required")
)