Skip to content

Commit

Permalink
Make the user required in the connection
Browse files Browse the repository at this point in the history
  • Loading branch information
webNeat committed Sep 8, 2024
1 parent b8f6044 commit fa0bd12
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pr.yaml → .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 4 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -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')
Expand Down
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ import { ChildProcess, SpawnOptions } from 'child_process'

export type LocalConnection = {
type: 'local'
user?: string
user: string
password?: string
}

export type SshConnection = {
type: 'ssh'
address: string
port?: number
user?: string
user: string
password?: string
private_key_path?: string
}

export type DockerConnection = {
type: 'docker'
container: string
user?: string
user: string
password?: string
}

Expand Down

0 comments on commit fa0bd12

Please sign in to comment.