dsh 0.2.0-rc.2: in-container update (experimental channel), path-agnostic compose, upstream patches adapted to 0.1.x/0.2.x
This commit is contained in:
commit
e6dcef9bf5
302 files changed
+75178
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { readFile } from 'node:fs/promises'
|
||||
import { durableReplace } from './atomic.mjs'
|
||||
import { canonicalJson } from './canonical-json.mjs'
|
||||
|
||||
export async function readDeploymentStatus(path) {
|
||||
try {
|
||||
const value = JSON.parse(await readFile(path, 'utf8'))
|
||||
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
||||
? value
|
||||
: { platformLayout: 1, imageBaseline: null, current: null, imageBehindCurrent: false, recoveryMode: 'status-invalid' }
|
||||
} catch (error) {
|
||||
if (error?.code === 'ENOENT') {
|
||||
return { platformLayout: 1, imageBaseline: null, current: null, imageBehindCurrent: false, recoveryMode: 'status-unavailable' }
|
||||
}
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export async function writeDeploymentStatus(path, value) {
|
||||
await durableReplace(path, canonicalJson(value))
|
||||
return value
|
||||
}
|
||||
Reference in new issue
Block a user