Skip to content

Commit

Permalink
Fixes #36569 - List only supported Job Templates on upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
nofaralfasi committed Jul 19, 2023
1 parent 5b44890 commit 99eb6f2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Expand Up @@ -4,6 +4,17 @@ module Parameters
module JobTemplateExtensions
extend ActiveSupport::Concern

UNSUPPORTED_JOB_TEMPLATES = [
'Capsule Upgrade Playbook'
].freeze

def index
return super if Foreman::Plugin.find('foreman_theme_satellite').present?

@templates = super
@templates = @templates.where.not(name: JobTemplateExtensions::UNSUPPORTED_JOB_TEMPLATES)
end

class_methods do
def job_template_params_filter
super.tap do |filter|
Expand Down
Expand Up @@ -6,12 +6,24 @@ module V2
# Extends the job_templates api controller to support creating/updating with ansible callback plugin
module JobTemplatesControllerExtensions
extend Apipie::DSL::Concern
extend ActiveSupport::Concern

UNSUPPORTED_JOB_TEMPLATES = [
'Capsule Upgrade Playbook'
].freeze

update_api(:create, :update) do
param :job_template, Hash do
param :ansible_callback_enabled, :bool, :desc => N_('Enable the callback plugin for this template')
end
end

def index
return super if Foreman::Plugin.find('foreman_theme_satellite').present?

@job_templates = super
@job_templates = @job_templates.where.not(name: JobTemplatesControllerExtensions::UNSUPPORTED_JOB_TEMPLATES)
end
end
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/foreman_ansible/engine.rb
Expand Up @@ -66,6 +66,7 @@ class Engine < ::Rails::Engine
::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsControllerExtensions
::Api::V2::HostgroupsController.include ForemanAnsible::Api::V2::HostgroupsParamGroupExtensions
::ConfigReportImporter.include ForemanAnsible::AnsibleReportImporter
::Api::V2::JobTemplatesController.prepend ForemanAnsible::Api::V2::JobTemplatesControllerExtensions
::Api::V2::JobTemplatesController.include ForemanAnsible::Api::V2::JobTemplatesControllerExtensions
::Api::V2::JobTemplatesController.include Foreman::Controller::Parameters::JobTemplateExtensions
::JobTemplatesController.include Foreman::Controller::Parameters::JobTemplateExtensions
Expand Down

0 comments on commit 99eb6f2

Please sign in to comment.