refactor: fmt

This commit is contained in:
Orion Kindel 2023-06-14 21:21:05 -05:00
parent c28429de2f
commit 09ee1d3507
Signed by untrusted user who does not match committer: orion
GPG Key ID: 6D4165AE4C928719
2 changed files with 37 additions and 29 deletions

View File

@ -5,41 +5,46 @@ const Either = require('fp-ts/Either')
const Cmd = require('../cmd.js')
const LinuxUser = require('./linux-user.js')
const dockerCompose = cfg => yaml.stringify({
services: {
db: {
image: 'postgres:15.3',
// restart: always will start the container on system startup / reboot if
// docker.service enabled (see ./linux-user.js)
restart: 'always',
volumes: [`${cfg.postgres.dataDir}:/var/lib/postgres/data`],
ports: [`${cfg.network.interfaceIp}:${cfg.network.port}:5432`],
environment: {
POSTGRES_USER: cfg.postgres.username,
POSTGRES_PASSWORD: cfg.postgres.password,
const dockerCompose = cfg =>
yaml.stringify({
services: {
db: {
image: 'postgres:15.3',
// restart: always will start the container on system startup / reboot if
// docker.service enabled (see ./linux-user.js)
restart: 'always',
volumes: [`${cfg.postgres.dataDir}:/var/lib/postgres/data`],
ports: [`${cfg.network.interfaceIp}:${cfg.network.port}:5432`],
environment: {
POSTGRES_USER: cfg.postgres.username,
POSTGRES_PASSWORD: cfg.postgres.password,
},
},
}
},
})
},
})
const steps = cfg => [
LinuxUser.step(cfg),
{
up: {
label: `${cfg.linuxUser.username}: create db on ${cfg.network.interfaceIp}:${cfg.network.port}`,
work: (a) => pipe(
Cmd.doas(cfg.linuxUser.username, [
'set -x',
'cat << "EOCOMPOSE" > ~/docker-compose.yaml',
dockerCompose(cfg),
'EOCOMPOSE',
'docker compose up -d',
].join('\n')),
Either.map(() => a),
),
work: a =>
pipe(
Cmd.doas(
cfg.linuxUser.username,
[
'set -x',
'cat << "EOCOMPOSE" > ~/docker-compose.yaml',
dockerCompose(cfg),
'EOCOMPOSE',
'docker compose up -d',
].join('\n'),
),
Either.map(() => a),
),
},
// down handled by LinuxUser killing user processes
}
},
]
module.exports = { steps }

View File

@ -94,9 +94,12 @@ const statePersisted = cfg =>
),
)
const userDeleted = cfg => pipe(
Cmd.run(`until userdel ${cfg.linuxUser.username}; do pkill -eU ${cfg.linuxUser.username} || true; done;`),
Either.flatMap(() => Cmd.run(`rm -r ${cfg.linuxUser.homeDir} || true`)),
const userDeleted = cfg =>
pipe(
Cmd.run(
`until userdel ${cfg.linuxUser.username}; do pkill -eU ${cfg.linuxUser.username} || true; done;`,
),
Either.flatMap(() => Cmd.run(`rm -r ${cfg.linuxUser.homeDir} || true`)),
)
const step = cfg => ({