From 3ed93cd8c1541b396a53f353fb5d50916faba0c5 Mon Sep 17 00:00:00 2001 From: "Eric D. Helms" Date: Thu, 19 Sep 2024 15:24:01 -0400 Subject: [PATCH] Allow specifying extra gemfiles for a plugin --- manifests/config.pp | 1 + manifests/plugin.pp | 4 ++++ spec/classes/katello_devel_spec.rb | 7 +++++++ templates/plugin.local.rb.erb | 6 +++--- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index 2f5f3c6..1a56434 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -48,6 +48,7 @@ settings_template => 'katello_devel/katello.yaml.erb', scm_revision => $katello_scm_revision, manage_repo => $katello_manage_repo, + extra_gemfiles => ['gemfile.d/test.rb'], } katello_devel::plugin { 'theforeman/foreman_remote_execution': diff --git a/manifests/plugin.pp b/manifests/plugin.pp index 4b70ac8..20db605 100644 --- a/manifests/plugin.pp +++ b/manifests/plugin.pp @@ -9,10 +9,14 @@ # # @param manage_repo # Set to false if the plugin source repository is managed externally. +# +# @param extra_gemfiles +# Additional gemfiles a plugin needs added define katello_devel::plugin ( Optional[String] $settings_template = undef, Optional[String] $scm_revision = undef, Boolean $manage_repo = true, + Array[String] $extra_gemfiles = [], ) { $split_array = split($name, '/') $github_organization = $split_array[0] diff --git a/spec/classes/katello_devel_spec.rb b/spec/classes/katello_devel_spec.rb index 1604ce0..28c5d91 100644 --- a/spec/classes/katello_devel_spec.rb +++ b/spec/classes/katello_devel_spec.rb @@ -93,6 +93,13 @@ ' :katello_applicability: true', ]) end + + it do + verify_exact_contents(catalogue, '/home/vagrant/foreman/bundler.d/katello.local.rb', [ + "gemspec :path => '../katello', :development_group => 'katello_dev', :name => 'katello'", + "eval_gemfile('/home/vagrant/katello/gemfile.d/test.rb')" + ]) + end end describe 'with modulestream_nodejs' do diff --git a/templates/plugin.local.rb.erb b/templates/plugin.local.rb.erb index e1f8d24..d2618fc 100644 --- a/templates/plugin.local.rb.erb +++ b/templates/plugin.local.rb.erb @@ -1,4 +1,4 @@ gemspec :path => '../<%= scope['plugin'] %>', :development_group => '<%= scope['plugin'] %>_dev', :name => '<%= scope['plugin'] %>' -Dir['../<%= scope['plugin'] %>/gemfile.d/*.rb'].each do |file| - eval_gemfile(file) -end +<%- for gemfile in scope['extra_gemfiles'] %> +eval_gemfile('<%= scope['katello_devel::deployment_dir'] %>/<%= scope['plugin'] %>/<%= gemfile %>') +<%- end %>