Module: TrustedSandbox
- Defined in:
- lib/trusted_sandbox.rb,
lib/trusted_sandbox/cli.rb,
lib/trusted_sandbox/config.rb,
lib/trusted_sandbox/errors.rb,
lib/trusted_sandbox/version.rb,
lib/trusted_sandbox/defaults.rb,
lib/trusted_sandbox/response.rb,
lib/trusted_sandbox/uid_pool.rb,
lib/trusted_sandbox/host_runner.rb,
lib/trusted_sandbox/general_purpose.rb,
lib/trusted_sandbox/request_serializer.rb
Defined Under Namespace
Classes: Cli, Config, ContainerError, Defaults, ExecutionTimeoutError, GeneralPurpose, HostRunner, InternalError, InvocationError, PoolTimeoutError, RequestSerializer, Response, UidPool, UserCodeError
Constant Summary
collapse
- VERSION =
'0.1.6'
Class Method Summary
collapse
Class Method Details
.config {|@config| ... } ⇒ Object
25
26
27
28
29
|
# File 'lib/trusted_sandbox.rb', line 25
def self.config
@config ||= Defaults.send(:new).override config_overrides_from_file
yield @config if block_given?
@config.finished_configuring
end
|
.config_overrides_from_file(env = nil) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/trusted_sandbox.rb', line 31
def self.config_overrides_from_file(env = nil)
yaml_path = %w(trusted_sandbox.yml config/trusted_sandbox.yml).find {|x| File.exist?(x)}
return {} unless yaml_path
env ||= ENV['TRUSTED_SANDBOX_ENV'] || ENV['RAILS_ENV'] || 'development'
YAML.load_file(yaml_path)[env] || {}
end
|
.new_runner(config_override = {}) ⇒ Object
67
68
69
|
# File 'lib/trusted_sandbox.rb', line 67
def self.new_runner(config_override = {})
HostRunner.new(config, uid_pool, config_override)
end
|
.run(klass, *args) ⇒ Object
51
52
53
|
# File 'lib/trusted_sandbox.rb', line 51
def self.run(klass, *args)
new_runner.run(klass, *args)
end
|
.run!(klass, *args) ⇒ Object
55
56
57
|
# File 'lib/trusted_sandbox.rb', line 55
def self.run!(klass, *args)
new_runner.run!(klass, *args)
end
|
.run_code(code, args = {}) ⇒ Object
59
60
61
|
# File 'lib/trusted_sandbox.rb', line 59
def self.run_code(code, args={})
new_runner.run_code(code, args)
end
|
.run_code!(code, args = {}) ⇒ Object
63
64
65
|
# File 'lib/trusted_sandbox.rb', line 63
def self.run_code!(code, args={})
new_runner.run_code!(code, args)
end
|
.test_connection ⇒ Object
15
16
17
18
|
# File 'lib/trusted_sandbox.rb', line 15
def self.test_connection
Docker.version
true
end
|
.uid_pool ⇒ Object
39
40
41
42
|
# File 'lib/trusted_sandbox.rb', line 39
def self.uid_pool
@uid_pool ||= UidPool.new config.host_uid_pool_lock_path, config.pool_min_uid, config.pool_max_uid,
timeout: config.pool_timeout, retries: config.pool_retries, delay: config.pool_delay
end
|
.with_options(config_override = {}) {|new_runner(config_override)| ... } ⇒ Object
45
46
47
|
# File 'lib/trusted_sandbox.rb', line 45
def self.with_options(config_override={})
yield new_runner(config_override)
end
|