Class: Actions::Katello::ContentView::Promote

Inherits:
EntryAction
  • Object
show all
Extended by:
ApipieDSL::Class
Includes:
JailConcern::ContentView, JailConcern::Organization, ObservableAction
Defined in:
app/lib/actions/katello/content_view/promote.rb

Defined Under Namespace

Classes: Jail

Instance Method Summary collapse

Methods included from JailConcern::ContentView

#content_view_id, #content_view_label, #content_view_name, included

Methods included from JailConcern::Organization

included, #organization_id, #organization_label, #organization_name

Instance Method Details

#environmentsObject



35
36
37
# File 'app/lib/actions/katello/content_view/promote.rb', line 35

def environments
  input['environments']
end

#notify_on_failure(_plan) ⇒ Object



27
28
29
30
31
32
33
# File 'app/lib/actions/katello/content_view/promote.rb', line 27

def notify_on_failure(_plan)
  notification = MailNotification[:content_view_promote_failure]
  view = ::Katello::ContentView.find(input.fetch(:content_view, {})[:id])
  notification.users.with_enabled_email.each do |user|
    notification.deliver(user: user, content_view: view, task: task)
  end
end

#plan(version, environments, is_force = false, description = nil, incremental_update = false) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/lib/actions/katello/content_view/promote.rb', line 9

def plan(version, environments, is_force = false, description = nil, incremental_update = false)
  action_subject(version.content_view)
  version.check_ready_to_promote!(environments)
  ::Katello::Util::CandlepinRepositoryChecker.check_repositories_for_promote!(version)

  fail ::Katello::HttpErrors::BadRequest, _("Cannot promote environment out of sequence. Use force to bypass restriction.") if !is_force && !version.promotable?(environments)

  # Pass the environments as input in order to make them accessible to UI alerts
  plan_self(environments: environments.map(&:name))
  environments.each do |environment|
    sequence do
      plan_action(Katello::ContentViewVersion::BeforePromoteHook, :id => version.id)
      plan_action(ContentView::PromoteToEnvironment, version, environment, description, incremental_update)
      plan_action(Katello::ContentViewVersion::AfterPromoteHook, :id => version.id)
    end
  end
end