File tree Expand file tree Collapse file tree 5 files changed +30
-1
lines changed Expand file tree Collapse file tree 5 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,7 @@ def configure_sshkit_with(config)
168
168
end
169
169
SSHKit . config . command_map [ :docker ] = "docker" # No need to use /usr/bin/env, just clogs up the logs
170
170
SSHKit . config . output_verbosity = verbosity
171
+ SSHKit . config . default_env = config . sshkit . default_env
171
172
end
172
173
173
174
def specifics
Original file line number Diff line number Diff line change @@ -21,3 +21,10 @@ sshkit:
21
21
# Kamal sets a long idle timeout of 900 seconds on connections to try to avoid
22
22
# re-connection storms after an idle period, such as building an image or waiting for CI.
23
23
pool_idle_timeout : 300
24
+
25
+ # Default Env
26
+ #
27
+ # SSHKit sessions do not inherit the host PATH value. If you need to set custom env vars on
28
+ # a SSHKit session, like PATH or DOCKER_DEFAULT_PLATFORM you can map them here.
29
+ default_env :
30
+ path : /usr/local/bin:$PATH"
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ class Kamal::Configuration::Sshkit
5
5
6
6
def initialize ( config :)
7
7
@sshkit_config = config . raw_config . sshkit || { }
8
- validate! sshkit_config
8
+ validate! sshkit_config , with : Kamal :: Configuration :: Validator :: Sshkit
9
9
end
10
10
11
11
def max_concurrent_starts
@@ -16,6 +16,10 @@ def pool_idle_timeout
16
16
sshkit_config . fetch ( "pool_idle_timeout" , 900 )
17
17
end
18
18
19
+ def default_env
20
+ sshkit_config . fetch ( "default_env" , { } ) . transform_keys ( &:to_sym )
21
+ end
22
+
19
23
def to_h
20
24
sshkit_config
21
25
end
Original file line number Diff line number Diff line change
1
+ class Kamal ::Configuration ::Validator ::Sshkit < Kamal ::Configuration ::Validator
2
+ def validate!
3
+ validate_against_example! \
4
+ config . except ( "default_env" ) ,
5
+ example . except ( "default_env" )
6
+
7
+ if config [ "default_env" ]
8
+ validate_hash_of! ( config [ "default_env" ] , String )
9
+ end
10
+ end
11
+ end
Original file line number Diff line number Diff line change @@ -25,4 +25,10 @@ class ConfigurationSshkitTest < ActiveSupport::TestCase
25
25
@config = Kamal ::Configuration . new ( @deploy . tap { |c | c . merge! ( sshkit : { "pool_idle_timeout" => 600 } ) } )
26
26
assert_equal 600 , @config . sshkit . pool_idle_timeout
27
27
end
28
+
29
+ test "sshkit default env" do
30
+ assert_equal ( { } , @config . sshkit . default_env )
31
+ @config = Kamal ::Configuration . new ( @deploy . tap { |c | c . merge! ( sshkit : { "default_env" => { "path" => "/usr/local/bin:$PATH" } } ) } )
32
+ assert_equal ( { path : "/usr/local/bin:$PATH" } , @config . sshkit . default_env )
33
+ end
28
34
end
You can’t perform that action at this time.
0 commit comments