Skip to content

Commit

Permalink
Merge pull request #400 from mrsked/revert-386-ssh-log-levels
Browse files Browse the repository at this point in the history
Revert "Configurable SSH log levels"
  • Loading branch information
djmb authored Jul 25, 2023
2 parents 61b7dc9 + 2daaf44 commit a71e167
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 43 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,6 @@ ssh:
proxy_command: aws ssm start-session --target %h --document-name AWS-StartSSHSession --parameters 'portNumber=%p' --region=us-east-1 ## ssh via aws ssm
```

### Configuring the SSH log level

```yaml
ssh:
log_level: debug
```

Valid levels are `debug`, `info`, `warn`, `error` and `fatal` (default).

### Using env variables

You can inject env variables into the app containers using `env`:
Expand Down
13 changes: 2 additions & 11 deletions lib/mrsk/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,7 @@ def ssh_proxy
end

def ssh_options
{ user: ssh_user, proxy: ssh_proxy, auth_methods: [ "publickey" ], logger: ssh_logger }.compact
end

def ssh_logger
@ssh_logger ||= ::Logger.new(STDERR).tap { |logger| logger.level = ssh_log_level }
end

def ssh_log_level
(raw_config.ssh && raw_config.ssh["log_level"]) || ::Logger::FATAL
{ user: ssh_user, proxy: ssh_proxy, auth_methods: [ "publickey" ] }.compact
end


Expand Down Expand Up @@ -193,8 +185,7 @@ def to_h
service_with_version: service_with_version,
env_args: env_args,
volume_args: volume_args,
ssh_options: ssh_options.except(:logger),
ssh_log_level: ssh_log_level,
ssh_options: ssh_options,
builder: builder.to_h,
accessories: raw_config.accessories,
logging: logging_args,
Expand Down
27 changes: 4 additions & 23 deletions test/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,17 @@ class ConfigurationTest < ActiveSupport::TestCase
assert_equal "root", @config.ssh_options[:user]

config = Mrsk::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "user" => "app" }) })
assert_equal "app", config.ssh_options[:user]
assert_equal 4, config.ssh_options[:logger].level

config = Mrsk::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "log_level" => "debug" }) })
assert_equal 0, config.ssh_options[:logger].level
assert_equal "app", @config.ssh_options[:user]
end

test "ssh options with proxy host" do
config = Mrsk::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "proxy" => "1.2.3.4" }) })
assert_equal "[email protected]", config.ssh_options[:proxy].jump_proxies
assert_equal "[email protected]", @config.ssh_options[:proxy].jump_proxies
end

test "ssh options with proxy host and user" do
config = Mrsk::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "proxy" => "[email protected]" }) })
assert_equal "[email protected]", config.ssh_options[:proxy].jump_proxies
assert_equal "[email protected]", @config.ssh_options[:proxy].jump_proxies
end

test "volume_args" do
Expand Down Expand Up @@ -270,22 +266,7 @@ class ConfigurationTest < ActiveSupport::TestCase
end

test "to_h" do
assert_equal({
:roles=>["web"],
:hosts=>["1.1.1.1", "1.1.1.2"],
:primary_host=>"1.1.1.1",
:version=>"missing",
:repository=>"dhh/app",
:absolute_image=>"dhh/app:missing",
:service_with_version=>"app-missing",
:env_args=>["-e", "REDIS_URL=\"redis://x/y\""],
:ssh_options=>{:user=>"root", :auth_methods=>["publickey"]},
:ssh_log_level=>4,
:volume_args=>["--volume", "/local/path:/container/path"],
:builder=>{},
:logging=>["--log-opt", "max-size=\"10m\""],
:healthcheck=>{"path"=>"/up", "port"=>3000, "max_attempts" => 7 }
}, @config.to_h)
assert_equal({ :roles=>["web"], :hosts=>["1.1.1.1", "1.1.1.2"], :primary_host=>"1.1.1.1", :version=>"missing", :repository=>"dhh/app", :absolute_image=>"dhh/app:missing", :service_with_version=>"app-missing", :env_args=>["-e", "REDIS_URL=\"redis://x/y\""], :ssh_options=>{:user=>"root", :auth_methods=>["publickey"]}, :volume_args=>["--volume", "/local/path:/container/path"], :builder=>{}, :logging=>["--log-opt", "max-size=\"10m\""], :healthcheck=>{"path"=>"/up", "port"=>3000, "max_attempts" => 7 }}, @config.to_h)
end

test "min version is lower" do
Expand Down

0 comments on commit a71e167

Please sign in to comment.