You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
oapiErr, ok:=err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
203
+
if!ok {
204
+
returnfalse, volume, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError: %w", err)
205
+
}
206
+
ifoapiErr.StatusCode!=http.StatusNotFound {
207
+
returnfalse, volume, err
208
+
}
209
+
returntrue, nil, nil
210
+
})
211
+
handler.SetTimeout(10*time.Minute)
212
+
returnhandler
213
+
}
214
+
215
+
// CreateServerWaitHandler will wait for server creation
oapiErr, ok:=err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
294
+
if!ok {
295
+
returnfalse, server, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError: %w", err)
296
+
}
297
+
ifoapiErr.StatusCode!=http.StatusNotFound {
298
+
returnfalse, server, err
299
+
}
300
+
returntrue, nil, nil
301
+
})
302
+
handler.SetTimeout(20*time.Minute)
303
+
returnhandler
304
+
}
305
+
306
+
// ProjectRequestWaitHandler will wait for a request to succeed.
307
+
//
308
+
// It receives a request ID that can be obtained from the "X-Request-Id" header in the HTTP response of any operation in the IaaS API.
309
+
// To get this response header, use the "runtime.WithCaptureHTTPResponse" method from the "core" packaghe to get the raw HTTP response of an SDK operation.
310
+
// Then, the value of the request ID can be obtained by accessing the header key which is defined in the constant "XRequestIDHeader" of this package.
returnfalse, request, fmt.Errorf("request failed for request with id %s, the response is not valid: the id, the request action or the status are missing", requestId)
334
+
}
335
+
336
+
if*request.RequestId!=requestId {
337
+
returnfalse, request, fmt.Errorf("request failed for request with id %s: the response id doesn't match the request id", requestId)
338
+
}
339
+
340
+
switch*request.RequestAction {
341
+
caseRequestCreateAction:
342
+
if*request.Status==RequestCreatedStatus {
343
+
returntrue, request, nil
344
+
}
345
+
caseRequestUpdateAction:
346
+
if*request.Status==RequestUpdatedStatus {
347
+
returntrue, request, nil
348
+
}
349
+
caseRequestDeleteAction:
350
+
if*request.Status==RequestDeletedStatus {
351
+
returntrue, request, nil
352
+
}
353
+
default:
354
+
returnfalse, request, fmt.Errorf("request failed for request with id %s, the request action %s is not supported", requestId, *request.RequestAction)
355
+
}
356
+
357
+
if*request.Status==RequestFailedStatus {
358
+
returntrue, request, fmt.Errorf("request failed for request with id %s", requestId)
359
+
}
360
+
361
+
returnfalse, request, nil
362
+
})
363
+
handler.SetTimeout(20*time.Minute)
364
+
returnhandler
365
+
}
366
+
367
+
// AddVolumeToServerWaitHandler will wait for a volume to be attached to a server
returnfalse, volumeAttachment, fmt.Errorf("attachment failed for server with id %s and volume with id %s, the response is not valid: the volume id is missing", serverId, volumeId)
375
+
}
376
+
if*volumeAttachment.VolumeId==volumeId {
377
+
returntrue, volumeAttachment, nil
378
+
}
379
+
}
380
+
returnfalse, nil, nil
381
+
}
382
+
oapiErr, ok:=err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
383
+
if!ok {
384
+
returnfalse, volumeAttachment, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError: %w", err)
385
+
}
386
+
ifoapiErr.StatusCode!=http.StatusNotFound {
387
+
returnfalse, volumeAttachment, err
388
+
}
389
+
returnfalse, nil, nil
390
+
})
391
+
handler.SetTimeout(10*time.Minute)
392
+
returnhandler
393
+
}
394
+
395
+
// RemoveVolumeFromServerWaitHandler will wait for a volume to be attached to a server
returnfalse, volumeAttachment, fmt.Errorf("remove volume failed for server with id %s and volume with id %s, the response is not valid: the volume id is missing", serverId, volumeId)
403
+
}
404
+
}
405
+
returnfalse, nil, nil
406
+
}
407
+
oapiErr, ok:=err.(*oapierror.GenericOpenAPIError) //nolint:errorlint //complaining that error.As should be used to catch wrapped errors, but this error should not be wrapped
408
+
if!ok {
409
+
returnfalse, volumeAttachment, fmt.Errorf("could not convert error to oapierror.GenericOpenAPIError: %w", err)
0 commit comments