Skip to content

Commit a7ad766

Browse files
committed
(PUP-11540) Update task_info_service to return private/description
Updates the task_info_service implementation to return all task metadata for each task when tasks_for_environment is called. This requires reading metadata json files for each task. Testing was done to ensure the additional file reads for metadata json files would not impact performance of puppetserver. In tests with an environment with > 3000 tasks, the difference in total time to process all task data was only any increase of 0.5 - 1 second..
1 parent 363f22b commit a7ad766

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

lib/puppet/info_service/task_information_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def self.tasks_per_environment(environment_name)
66
env = Puppet.lookup(:environments).get!(environment_name)
77
env.modules.map do |mod|
88
mod.tasks.map do |task|
9-
{:module => {:name => task.module.name}, :name => task.name}
9+
{:module => {:name => task.module.name}, :name => task.name, :metadata => task.metadata}
1010
end
1111
end.flatten
1212
end

spec/unit/info_service_spec.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
context 'task information service' do
1313
let(:mod_name) { 'test1' }
14+
let(:metadata) {
15+
{ "private" => true,
16+
"description" => "a task that does a thing" } }
1417
let(:task_name) { "#{mod_name}::thingtask" }
1518
let(:modpath) { tmpdir('modpath') }
1619
let(:env_name) { 'testing' }
@@ -20,8 +23,13 @@
2023
context 'tasks_per_environment method' do
2124
it "returns task data for the tasks in an environment" do
2225
Puppet.override(:environments => env_loader) do
23-
PuppetSpec::Modules.create(mod_name, modpath, {:environment => env, :tasks => [['thingtask']]})
24-
expect(Puppet::InfoService.tasks_per_environment(env_name)).to eq([{:name => task_name, :module => {:name => mod_name}}])
26+
PuppetSpec::Modules.create(mod_name, modpath, {:environment => env,
27+
:tasks => [['thingtask',
28+
{:name => 'thingtask.json',
29+
:content => metadata.to_json}]]})
30+
expect(Puppet::InfoService.tasks_per_environment(env_name)).to eq([{:name => task_name,
31+
:module => {:name => mod_name},
32+
:metadata => metadata} ])
2533
end
2634
end
2735

@@ -207,7 +215,7 @@
207215
end
208216
end
209217
end
210-
218+
211219
context 'plan information service' do
212220
let(:mod_name) { 'test1' }
213221
let(:plan_name) { "#{mod_name}::thingplan" }

0 commit comments

Comments
 (0)