Skip to content

Commit fa0bd12

Browse files
committed
Make the user required in the connection
1 parent b8f6044 commit fa0bd12

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

.github/workflows/pr.yaml renamed to .github/workflows/tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: PR checks
1+
name: Tests
22
on:
33
pull_request:
44
branches: [main]
55
push:
66
branches: [main]
77
jobs:
8-
check_pr:
8+
functional_tests:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v2

src/server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
import os from 'os'
12
import path from 'path'
23
import { Host } from './ansible/types.js'
34
import * as blocks from './blocks/index.js'
45
import { Server, ServerConfig } from './types.js'
56

67
export function server(config: ServerConfig): Server {
8+
const user = os.userInfo().username
79
let connection = config.connection
810
if (!connection) {
9-
if (config.name === 'localhost') connection = { type: 'local', user: process.env.USER }
10-
else connection = { type: 'ssh', address: config.name }
11+
if (config.name === 'localhost') connection = { type: 'local', user }
12+
else connection = { type: 'ssh', address: config.name, user }
1113
}
1214
const hosty_dir = config.hosty_dir || '/srv/hosty'
1315
const backups_dir = path.join(hosty_dir, 'backups')

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,23 @@ import { ChildProcess, SpawnOptions } from 'child_process'
44

55
export type LocalConnection = {
66
type: 'local'
7-
user?: string
7+
user: string
88
password?: string
99
}
1010

1111
export type SshConnection = {
1212
type: 'ssh'
1313
address: string
1414
port?: number
15-
user?: string
15+
user: string
1616
password?: string
1717
private_key_path?: string
1818
}
1919

2020
export type DockerConnection = {
2121
type: 'docker'
2222
container: string
23-
user?: string
23+
user: string
2424
password?: string
2525
}
2626

0 commit comments

Comments
 (0)