Skip to content

Commit

Permalink
refactor(config): optimize configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
windvalley committed Jan 16, 2024
1 parent 10d5caa commit 13bcf3b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 55 deletions.
31 changes: 17 additions & 14 deletions configs/gossh.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
auth:
# Default login user.
# The login user.
# Default: $USER
user:

# Default password of the login user.
# The password of the login user.
# Default: ""
password:

Expand All @@ -15,11 +15,11 @@ auth:
# Default: ""
file:

# Default identity files of pubkey authentication.
# Default: ["$HOME/.ssh/id_rsa", "$HOME/.ssh/id_dsa"]
identity-files: []
# The identity files of pubkey authentication.
# Default: [~/.ssh/id_rsa]
identity-files: [~/.ssh/id_rsa]

# Default passphrase of the identity files.
# The passphrase of the identity files.
# Default: ""
passphrase:

Expand All @@ -29,6 +29,8 @@ auth:

hosts:
# Default inventory file that holds the target hosts.
# The file content format can be referred to at:
# https://github.com/windvalley/gossh/blob/main/docs/inventory.md
# Default: ""
inventory:

Expand Down Expand Up @@ -58,8 +60,9 @@ run:
# Linux Command Blacklist for gossh subcommands 'command' and 'script'.
# Commands listed in this blacklist will be prohibited from executing on remote hosts for security reasons.
# You can add flag '-n, --no-safe-check' to disable this feature.
# Default: ["rm", "reboot", "halt", "shutdown", "init", "mkfs", "mkfs.*", "umount", "dd"]
command-blacklist: []
# Default: [rm, reboot, halt, shutdown, init, mkfs, mkfs.*, umount, dd]
command-blacklist:
[rm, reboot, halt, shutdown, init, mkfs, mkfs.*, umount, dd]

output:
# File to which messages are output.
Expand Down Expand Up @@ -105,18 +108,18 @@ proxy:
# Default: 22
port: 22

# Login user for proxy.
# Default: value of 'auth.user'
# Proxy server user.
# Default: the same as 'auth.user'
user:

# Password for proxy.
# Default: value of 'auth.password'
# Default: the same as 'auth.password'
password:

# Identity files for proxy.
# Default: value of 'auth.identity-files'
identity-files: []
# Default: the same as 'auth.identity-files'
identity-files:

# Passphrase of the identity files for proxy.
# Default: value of 'auth.passphrase'
# Default: the same as 'auth.passphrase'
passphrase:
65 changes: 38 additions & 27 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,40 @@ Demo file can be found in git repo by location: `configs/gossh.yaml`, or use com

```yaml
auth:
# Default login user.
# The login user.
# Default: $USER
user: ""
user:

# Default password of the login user.
# The password of the login user.
# Default: ""
password: ""
password:

# Ask for password of the login user.
# Default: false
ask-pass: false

# File that holds the default password of login user.
# Default: ""
file: ""
file:

# Default identity files of pubkey authentication.
# Default:
# - $HOME/.ssh/id_rsa
# - $HOME/.ssh/id_dsa
identity-files: []
# The identity files of pubkey authentication.
# Default: [~/.ssh/id_rsa]
identity-files: [~/.ssh/id_rsa]

# Default passphrase of the identity files.
# The passphrase of the identity files.
# Default: ""
passphrase: ""
passphrase:

# File that holds the vault password for encryption and decryption.
# Default: ""
vault-pass-file: ""
vault-pass-file:

hosts:
# Default inventory file that holds the target hosts.
# The file content format can be referred to at:
# https://github.com/windvalley/gossh/blob/main/docs/inventory.md
# Default: ""
inventory: ""
inventory:

# Default port of target hosts.
# Default: 22
Expand All @@ -66,26 +66,37 @@ run:
# as this value when executing command/script.
# Available vaules: zh_CN.UTF-8, en_US.UTF-8, etc.
# Default: "" (null means do not export)
lang: ""
lang:

# Number of concurrent connections.
# Default: 1
concurrency: 1

# Linux Command Blacklist for gossh subcommands 'command' and 'script'.
# Commands listed in this blacklist will be prohibited from executing on remote hosts for security reasons.
# You can add flag '-n, --no-safe-check' to disable this feature.
# Default: [rm, reboot, halt, shutdown, init, mkfs, mkfs.*, umount, dd]
command-blacklist:
[rm, reboot, halt, shutdown, init, mkfs, mkfs.*, umount, dd]

output:
# File to which messages are output.
# Default: ""
file: ""
file:

# Output messages in json format.
# Default: false
json: false

# Condense output and disable color.
# Default: false
condense: false

# Show debug messages.
# Default: false
verbose: false

# Do not output messages to screen (except error messages).
# Do not output messages to screen.
# Default: false
quite: false

Expand All @@ -106,27 +117,27 @@ timeout:
proxy:
# Proxy server address. It will enable proxy if it is not null.
# Default: ""
server: ""
server:

# Proxy server port.
# Default: 22
port: 22

# Login user for proxy.
# Default: value of 'auth.user'
user: ""
# Proxy server user.
# Default: the same as 'auth.user'
user:

# Password for proxy.
# Default: value of 'auth.password'
password: ""
# Default: the same as 'auth.password'
password:

# Identity files for proxy.
# Default: value of 'auth.identity-files'
identity-files: []
# Default: the same as 'auth.identity-files'
identity-files:

# Passphrase of the identity files for proxy.
# Default: value of 'auth.passphrase'
passphrase: ""
# Default: the same as 'auth.passphrase'
passphrase:
```
## Examples
Expand Down
28 changes: 14 additions & 14 deletions internal/cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import (
)

const configTemplate = `auth:
# Default login user.
# The login user.
# Default: $USER
user: {{ .Auth.User }}
# Default password of the login user.
# The password of the login user.
# Default: ""
password: {{ .Auth.Password }}
Expand All @@ -50,11 +50,11 @@ const configTemplate = `auth:
# Default: ""
file: {{ .Auth.PassFile }}
# Default identity files of pubkey authentication.
# Default: ["$HOME/.ssh/id_rsa", "$HOME/.ssh/id_dsa"]
identity-files: []
# The identity files of pubkey authentication.
# Default: [~/.ssh/id_rsa]
identity-files: [~/.ssh/id_rsa]
# Default passphrase of the identity files.
# The passphrase of the identity files.
# Default: ""
passphrase: {{ .Auth.Passphrase }}
Expand Down Expand Up @@ -95,8 +95,8 @@ run:
# Linux Command Blacklist for gossh subcommands 'command' and 'script'.
# Commands listed in this blacklist will be prohibited from executing on remote hosts for security reasons.
# You can add flag '-n, --no-safe-check' to disable this feature.
# Default: ["rm", "reboot", "halt", "shutdown", "init", "mkfs", "mkfs.*", "umount", "dd"]
command-blacklist: []
# Default: [rm, reboot, halt, shutdown, init, mkfs, mkfs.*, umount, dd]
command-blacklist: [rm, reboot, halt, shutdown, init, mkfs, mkfs.*, umount, dd]
output:
# File to which messages are output.
Expand Down Expand Up @@ -142,20 +142,20 @@ proxy:
# Default: 22
port: {{ .Proxy.Port }}
# Login user for proxy.
# Default: value of 'auth.user'
# Proxy server user.
# Default: the same as 'auth.user'
user: {{ .Proxy.User }}
# Password for proxy.
# Default: value of 'auth.password'
# Default: the same as 'auth.password'
password: {{ .Proxy.Password }}
# Identity files for proxy.
# Default: value of 'auth.identity-files'
identity-files: []
# Default: the same as 'auth.identity-files'
identity-files:
# Passphrase of the identity files for proxy.
# Default: value of 'auth.passphrase'
# Default: the same as 'auth.passphrase'
passphrase: {{ .Proxy.Passphrase }}`

// configCmd represents the config command
Expand Down

0 comments on commit 13bcf3b

Please sign in to comment.