Skip to content

Commit

Permalink
Fixes #36763 - Emit failure events from ObservableAction
Browse files Browse the repository at this point in the history
  • Loading branch information
adamruzicka committed Sep 20, 2023
1 parent 1b91c7e commit c5d0b44
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions app/lib/actions/observable_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def event_name_suffix(hook)
end

def event_names
[event_name_base + '_' + event_name_suffix(:success)]
[:success, :failure].map { |suffix| event_name_base + '_' + event_name_suffix(suffix) }
end

def namespaced_event_names
Expand All @@ -51,7 +51,16 @@ def event_name_base
def self.included(base)
base.extend ClassMethods
base.include ::Foreman::Observable
base.execution_plan_hooks.use :emit_event, :on => :success
base.execution_plan_hooks.use :emit_event_success, :on => :success
base.execution_plan_hooks.use :emit_event_failure, :on => :failure
end

def emit_event_success(execution_plan)
emit_event(execution_plan, :success)
end

def emit_event_failure(execution_plan)
emit_event(execution_plan, :failure)
end

def emit_event(execution_plan, hook = :success)
Expand Down

0 comments on commit c5d0b44

Please sign in to comment.