Sha256: 354c5464962a60a64984cd268bb066d4d78af54f44d2f627028bc22fbaa7a866
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
# # Copyright 2014 Red Hat, Inc. # # This software is licensed to you under the GNU General Public # License as published by the Free Software Foundation; either version # 2 of the License (GPLv2) or (at your option) any later version. # There is NO WARRANTY for this software, express or implied, # including the implied warranties of MERCHANTABILITY, # NON-INFRINGEMENT, or FITNESS FOR A PARTICULAR PURPOSE. You should # have received a copy of GPLv2 along with this software; if not, see # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. module Actions module Middleware # Helpers for remote actions # wraps the plan/run/finalize methods to include the info about the user # that triggered the action. class RemoteAction < Dynflow::Middleware def plan(*args) fail "No current user is set. Please set User.current to perform a remote action" if User.current.nil? pass(*args).tap do action.input[:remote_user] = User.current.remote_id action.input[:remote_cp_user] = User.current.login end end def run(*args) as_remote_user { pass(*args) } end def finalize as_remote_user { pass } end private def as_cp_user(&block) fail 'missing :remote_user' unless cp_user User.cp_config('cp-user' => cp_user, &block) end def as_pulp_user(&block) fail 'missing :remote_user' unless remote_user User.pulp_config(remote_user, &block) end def remote_user action.input[:remote_user] end def cp_user action.input[:remote_cp_user] end def as_remote_user as_cp_user do as_pulp_user do yield end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
katello-2.2.2 | app/lib/actions/middleware/remote_action.rb |