Class: Kitsune::Kit::Tui::Actions
- Inherits:
-
Object
- Object
- Kitsune::Kit::Tui::Actions
- Defined in:
- lib/kitsune/kit/tui/actions.rb
Instance Method Summary collapse
- #apply ⇒ Object
- #cancel ⇒ Object
- #doctor ⇒ Object
-
#initialize(application:, cancellation: Cancellation.new) ⇒ Actions
constructor
A new instance of Actions.
- #plan ⇒ Object
- #resume ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(application:, cancellation: Cancellation.new) ⇒ Actions
Returns a new instance of Actions.
7 8 9 10 11 |
# File 'lib/kitsune/kit/tui/actions.rb', line 7 def initialize(application:, cancellation: Cancellation.new) @application = application @cancellation = cancellation @last_plan = nil end |
Instance Method Details
#apply ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/kitsune/kit/tui/actions.rb', line 38 def apply @last_plan ||= plan.value raise Errors::UnsafeOperationError, "the plan contains destructive changes" if @last_plan.destructive? return Result.success([], metadata: { unchanged: true }) unless @last_plan.changed? Workflows::ApplyPlan.new( config: app.config, operations: app.operations, state_store: app.state_store, event_bus: app.event_bus, cancellation: @cancellation ).call(plan: @last_plan) ensure @last_plan = nil reset_cancellation end |
#cancel ⇒ Object
61 |
# File 'lib/kitsune/kit/tui/actions.rb', line 61 def cancel = @cancellation.cancel! |
#doctor ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kitsune/kit/tui/actions.rb', line 27 def doctor Workflows::Doctor.new( config: app.config, provider: app.provider, state_store: app.state_store, transport_factory: app.transport_factory, operations: app.operations, event_bus: app.event_bus ).call end |
#plan ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/kitsune/kit/tui/actions.rb', line 19 def plan workflow = Workflows::BuildPlan.new(config: app.config, operations: app.operations, event_bus: app.event_bus) workflow.call.tap do |result| @last_plan = result.value end end |
#resume ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/kitsune/kit/tui/actions.rb', line 52 def resume Workflows::ApplyPlan.new( config: app.config, operations: app.operations, state_store: app.state_store, event_bus: app.event_bus, cancellation: @cancellation ).call(resume_from: true) ensure reset_cancellation end |
#status ⇒ Object
13 14 15 16 17 |
# File 'lib/kitsune/kit/tui/actions.rb', line 13 def status Workflows::InspectEnvironment.new( config: app.config, provider: app.provider, state_store: app.state_store, event_bus: app.event_bus ).call end |