diff --git a/.github/workflows/pr.yaml b/.github/workflows/tests.yaml similarity index 90% rename from .github/workflows/pr.yaml rename to .github/workflows/tests.yaml index a3cd06b..1d7edf9 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/tests.yaml @@ -1,11 +1,11 @@ -name: PR checks +name: Tests on: pull_request: branches: [main] push: branches: [main] jobs: - check_pr: + functional_tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/src/server.ts b/src/server.ts index d33b0e8..7b3cca3 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,13 +1,15 @@ +import os from 'os' import path from 'path' import { Host } from './ansible/types.js' import * as blocks from './blocks/index.js' import { Server, ServerConfig } from './types.js' export function server(config: ServerConfig): Server { + const user = os.userInfo().username let connection = config.connection if (!connection) { - if (config.name === 'localhost') connection = { type: 'local', user: process.env.USER } - else connection = { type: 'ssh', address: config.name } + if (config.name === 'localhost') connection = { type: 'local', user } + else connection = { type: 'ssh', address: config.name, user } } const hosty_dir = config.hosty_dir || '/srv/hosty' const backups_dir = path.join(hosty_dir, 'backups') diff --git a/src/types.ts b/src/types.ts index d3fc893..cde7b4f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -4,7 +4,7 @@ import { ChildProcess, SpawnOptions } from 'child_process' export type LocalConnection = { type: 'local' - user?: string + user: string password?: string } @@ -12,7 +12,7 @@ export type SshConnection = { type: 'ssh' address: string port?: number - user?: string + user: string password?: string private_key_path?: string } @@ -20,7 +20,7 @@ export type SshConnection = { export type DockerConnection = { type: 'docker' container: string - user?: string + user: string password?: string }