ReviewOS

also looking at this

stacks/ts-cloud

fix(operations): the inventory read a location Hetzner no longer sends

#193
Merged glennmichael123 wants to merge fix/inventory-provider-payload-type into main
2 files +69 -2
packages/ts-cloud/src/operations/inventory.test.tsmodified+20-0
Changes to packages/ts-cloud/src/operations/inventory.test.ts
@@ -63,6 +63,26 @@ describe('shaping a provider server', () => {
6363 .toMatchObject({ ipv4: '1.2.3.4', type: 'medium', location: 'nbg1' })
6464 })
6565
66 it('reads the location off the shape the API actually returns today', () => {
67 // The regression this guards. Hetzner retired `datacenter` and nests the
68 // place under `location`, which this read as a bare string - so every live
69 // box reported no location at all. `resize.ts` and `role-swap.ts` already
70 // carry the same fallback; this is the third reader to need it.
71 expect(toInventoryServer({
72 id: 3,
73 name: 'stacks-production-app',
74 status: 'running',
75 datacenter: null,
76 location: { id: 1, name: 'fsn1', city: 'Falkenstein' },
77 labels: {},
78 })).toMatchObject({ location: 'fsn1' })
79 })
80
81 it('still prefers the legacy datacenter when a recorded fixture carries one', () => {
82 expect(toInventoryServer({ id: 4, name: 'box', status: 'running', datacenter: { name: 'fsn1-dc14' }, labels: {} }))
83 .toMatchObject({ location: 'fsn1-dc14' })
84 })
85
6686 it('keeps an unlabelled box rather than dropping it', () => {
6787 // A box provisioned by hand, or by a ts-cloud old enough not to label, is
6888 // exactly the kind a consolidation needs to see.