Class: Tomo::Runtime
- Inherits:
-
Object
show all
- Defined in:
- lib/tomo/runtime.rb,
lib/tomo/runtime/context.rb,
lib/tomo/runtime/current.rb,
lib/tomo/runtime/explanation.rb,
lib/tomo/runtime/task_runner.rb,
lib/tomo/runtime/execution_plan.rb,
lib/tomo/runtime/no_tasks_error.rb,
lib/tomo/runtime/privileged_task.rb,
lib/tomo/runtime/inline_thread_pool.rb,
lib/tomo/runtime/task_aborted_error.rb,
lib/tomo/runtime/unknown_task_error.rb,
lib/tomo/runtime/host_execution_step.rb,
lib/tomo/runtime/settings_interpolation.rb,
lib/tomo/runtime/settings_required_error.rb,
lib/tomo/runtime/template_not_found_error.rb,
lib/tomo/runtime/concurrent_ruby_load_error.rb,
lib/tomo/runtime/concurrent_ruby_thread_pool.rb
Defined Under Namespace
Modules: Current, PrivilegedTask
Classes: ConcurrentRubyLoadError, ConcurrentRubyThreadPool, Context, ExecutionPlan, Explanation, HostExecutionStep, InlineThreadPool, NoTasksError, SettingsInterpolation, SettingsRequiredError, TaskAbortedError, TaskRunner, TemplateNotFoundError, UnknownTaskError
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(deploy_tasks:, setup_tasks:, hosts:, task_filter:, settings:, plugins_registry:) ⇒ Runtime
Returns a new instance of Runtime.
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/tomo/runtime.rb', line 32
def initialize(deploy_tasks:, setup_tasks:, hosts:, task_filter:, settings:, plugins_registry:)
@deploy_tasks = deploy_tasks.freeze
@setup_tasks = setup_tasks.freeze
@hosts = hosts.freeze
@task_filter = task_filter.freeze
@settings = settings
@plugins_registry = plugins_registry
@tasks = plugins_registry.task_names
freeze
end
|
Instance Attribute Details
#tasks ⇒ Object
Returns the value of attribute tasks.
30
31
32
|
# File 'lib/tomo/runtime.rb', line 30
def tasks
@tasks
end
|
Class Method Details
.local_user ⇒ Object
24
25
26
27
28
|
# File 'lib/tomo/runtime.rb', line 24
def self.local_user
ENV["USER"] || ENV["USERNAME"] || `whoami`.chomp
rescue StandardError
nil
end
|
Instance Method Details
#deploy! ⇒ Object
43
44
45
46
47
|
# File 'lib/tomo/runtime.rb', line 43
def deploy!
NoTasksError.raise_with(task_type: "deploy") if deploy_tasks.empty?
execution_plan_for(deploy_tasks, release: :new).execute
end
|
#execution_plan_for(tasks, release: :current, args: []) ⇒ Object
60
61
62
63
64
65
66
67
|
# File 'lib/tomo/runtime.rb', line 60
def execution_plan_for(tasks, release: :current, args: [])
ExecutionPlan.new(
tasks:,
hosts:,
task_filter:,
task_runner: new_task_runner(release, args)
)
end
|
#run!(task, *args, privileged: false) ⇒ Object
55
56
57
58
|
# File 'lib/tomo/runtime.rb', line 55
def run!(task, *args, privileged: false)
task = String.new(task).extend(PrivilegedTask) if privileged
execution_plan_for([task], release: :current, args:).execute
end
|
#setup! ⇒ Object
49
50
51
52
53
|
# File 'lib/tomo/runtime.rb', line 49
def setup!
NoTasksError.raise_with(task_type: "setup") if setup_tasks.empty?
execution_plan_for(setup_tasks, release: :tmp).execute
end
|