Skip to content

Commit 06400f8

Browse files
Update mock handler to match omicron
1 parent d81c471 commit 06400f8

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

mock-api/msw/handlers.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,23 @@ export const handlers = makeHandlers({
584584

585585
return json(newInstance, { status: 201 })
586586
},
587-
instanceView: ({ path, query }) => lookup.instance({ ...path, ...query }),
587+
instanceView: ({ path, query }) => {
588+
const instance = lookup.instance({ ...path, ...query })
589+
590+
// if empty uses default auto-restart behaviour
591+
// if set, is based off of the policy
592+
// https://github.com/oxidecomputer/omicron/blob/f63ed095e744fb8d2383fda6799eb0b2d6dfbd3c/nexus/db-queries/src/db/datastore/instance.rs#L228C26-L239
593+
if (instance.auto_restart_policy === 'never') {
594+
instance.auto_restart_enabled = false
595+
} else if (
596+
instance.auto_restart_policy === 'best_effort' ||
597+
!instance.auto_restart_policy // included for posterity but this has to be set in the mock data anyway
598+
) {
599+
instance.auto_restart_enabled = true
600+
}
601+
602+
return instance
603+
},
588604
instanceUpdate({ path, query, body }) {
589605
const instance = lookup.instance({ ...path, ...query })
590606

0 commit comments

Comments
 (0)