Skip to content

Commit 5c2efb8

Browse files
committed
feat: revert utils changes
1 parent 3381ee2 commit 5c2efb8

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

packages/clients/src/api/baremetal/v1/api.utils.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ export class BaremetalV1UtilsAPI extends API {
2121
) =>
2222
tryAtIntervals(
2323
async () => {
24-
const value = await this.getServer(request).then(
25-
server => server.install,
26-
)
24+
const value = await this.getServer(request).then(server => {
25+
if (!server.install) {
26+
throw new Error(
27+
`Server creation has not begun for server ${request.serverId}`,
28+
)
29+
}
30+
31+
return server.install
32+
})
2733

2834
return {
2935
done: !SERVER_INSTALL_TRANSIENT_STATUSES.includes(value.status),

packages/clients/src/api/instance/v1/api.utils.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ export class InstanceV1UtilsAPI extends API {
7272
) =>
7373
tryAtIntervals(
7474
async () => {
75-
const value = await this.getImage(request).then(res => res.image)
75+
const value = await this.getImage(request).then(
76+
res => res.image as Image,
77+
)
7678

7779
return {
7880
done: !IMAGE_TRANSIENT_STATUSES.includes(value.state),
@@ -100,7 +102,7 @@ export class InstanceV1UtilsAPI extends API {
100102
tryAtIntervals(
101103
async () => {
102104
const value = await this.getPrivateNIC(request).then(
103-
res => res.privateNic,
105+
res => res.privateNic as PrivateNIC,
104106
)
105107

106108
return {
@@ -128,7 +130,9 @@ export class InstanceV1UtilsAPI extends API {
128130
) =>
129131
tryAtIntervals(
130132
async () => {
131-
const value = await this.getServer(request).then(res => res.server)
133+
const value = await this.getServer(request).then(
134+
res => res.server as Server,
135+
)
132136

133137
return {
134138
done: !SERVER_TRANSIENT_STATUSES.includes(value.state),
@@ -155,7 +159,9 @@ export class InstanceV1UtilsAPI extends API {
155159
) =>
156160
tryAtIntervals(
157161
async () => {
158-
const value = await this.getSnapshot(request).then(res => res.snapshot)
162+
const value = await this.getSnapshot(request).then(
163+
res => res.snapshot as Snapshot,
164+
)
159165

160166
return {
161167
done: !SNAPSHOT_TRANSIENT_STATUSES.includes(value.state),
@@ -182,7 +188,9 @@ export class InstanceV1UtilsAPI extends API {
182188
) =>
183189
tryAtIntervals(
184190
async () => {
185-
const value = await this.getVolume(request).then(res => res.volume)
191+
const value = await this.getVolume(request).then(
192+
res => res.volume as Volume,
193+
)
186194

187195
return {
188196
done: !VOLUME_TRANSIENT_STATUSES.includes(value.state),
@@ -397,7 +405,7 @@ export class InstanceV1UtilsAPI extends API {
397405
const volumes = await this.getServer({
398406
serverId: request.serverId,
399407
zone: request.zone,
400-
}).then(res => validateNotUndefined(res.server.volumes))
408+
}).then(res => validateNotUndefined(res.server?.volumes))
401409

402410
const newVolumes: Record<string, { id: string; name: string }> = {}
403411
for (const [key, server] of Object.entries(volumes)) {
@@ -445,7 +453,7 @@ export class InstanceV1UtilsAPI extends API {
445453
volumeId: request.volumeId,
446454
zone: request.zone,
447455
})
448-
.then(res => validateNotUndefined(res.volume.server.id))
456+
.then(res => validateNotUndefined(res.volume?.server?.id))
449457
.then(serverId =>
450458
this.getServer({
451459
serverId,

packages/clients/src/api/instance/v1/marshalling.utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ const marshalVolume = (
5454
name: request.name,
5555
organization: request.organization,
5656
project: request.project,
57-
server: marshalServerSummary(request.server, defaults),
57+
server: request.server
58+
? marshalServerSummary(request.server, defaults)
59+
: undefined,
5860
size: request.size,
5961
state: request.state,
6062
tags: request.tags,

0 commit comments

Comments
 (0)