-
Notifications
You must be signed in to change notification settings - Fork 20
/
instancetype_get.go
47 lines (44 loc) · 1.13 KB
/
instancetype_get.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
package ovirtclient //nolint:dupl
import (
"fmt"
)
func (o *oVirtClient) GetInstanceType(id InstanceTypeID, retries ...RetryStrategy) (result InstanceType, err error) {
retries = defaultRetries(retries, defaultReadTimeouts(o))
err = retry(
fmt.Sprintf("getting instance type %s", id),
o.logger,
retries,
func() error {
response, err := o.conn.SystemService().InstanceTypesService().InstanceTypeService(string(id)).Get().Send()
if err != nil {
return err
}
sdkObject, ok := response.InstanceType()
if !ok {
return newError(
ENotFound,
"no instance type returned when getting instance type ID %s",
id,
)
}
result, err = convertSDKInstanceType(sdkObject, o)
if err != nil {
return wrap(
err,
EBug,
"failed to convert instance type %s",
id,
)
}
return nil
})
return result, err
}
func (m *mockClient) GetInstanceType(id InstanceTypeID, _ ...RetryStrategy) (InstanceType, error) {
m.lock.Lock()
defer m.lock.Unlock()
if item, ok := m.instanceTypes[id]; ok {
return item, nil
}
return nil, newError(ENotFound, "instance type with ID %s not found", id)
}