Sha256: 283e026fac33cc86618f6c6ba341998b2f5bb28ef7457dff38d49675a0837f42

Contents?: true

Size: 1.1 KB

Versions: 20

Compression:

Stored size: 1.1 KB

Contents

module Actions
  module RemoteExecution
    module EventHelpers
      module ClassEventHelpers
        def event_states
          []
        end

        def event_names
          event_states.map do |state|
            event_name_base + '_' + event_name_suffix(state).to_s
          end
        end

        def feature_job_event_names(label)
          event_states.map do |state|
            ::Foreman::Observable.event_name_for("#{event_name_base}_#{label}_#{event_name_suffix(state)}")
          end
        end
      end

      def self.included(base)
        base.extend ClassEventHelpers
      end

      def emit_event(execution_plan, hook)
        return unless root_action?

        payload = event_payload(execution_plan)
        base = self.class.event_name_base
        suffix = self.class.event_name_suffix(hook)
        if input["job_features"]&.any?
          input['job_features'].each do |feature|
            name = "#{base}_#{feature}_#{suffix}"
            trigger_hook name, payload: payload
          end
        end
        trigger_hook("#{base}_#{suffix}", payload: payload)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
foreman_remote_execution-14.1.2 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-14.1.1 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-14.1.0 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-14.0.2 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-14.0.1 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-13.2.6 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-14.0.0 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-13.2.5 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-13.2.4 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-13.2.3 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-13.2.2 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-12.0.7 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-13.2.1 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-13.2.0 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-13.0.0 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-12.0.5 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-12.0.4 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-12.0.1 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-12.0.2 app/lib/actions/remote_execution/event_helpers.rb
foreman_remote_execution-12.0.0 app/lib/actions/remote_execution/event_helpers.rb