Skip to content

Commit c080cf4

Browse files
committed
Switch to ruby_task_helper
It was determined that original pattern did not provide any additional value over more established ones.
1 parent 51b0dc3 commit c080cf4

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

metadata.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
{
4040
"name": "puppetlabs/inifile",
4141
"version_requirement": ">= 5.2.0 < 6.0.0"
42+
},
43+
{
44+
"name": "puppetlabs/ruby_task_helper",
45+
"version_requirement": ">= 0.6.1 < 1.0.0"
4246
}
4347
],
4448
"operatingsystem_support": [

tasks/get_psql_version.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"description": "Run on a PE PSQL node to return the major version of the PSQL server currently installed",
33
"parameters": { },
4+
"files": ["ruby_task_helper/files/task_helper.rb"],
45
"input_method": "stdin"
56
}

tasks/get_psql_version.rb

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
#!/opt/puppetlabs/puppet/bin/ruby
22
# frozen_string_literal: true
33

4+
require_relative '../../ruby_task_helper/files/task_helper.rb'
45
require '/opt/puppetlabs/puppet/cache/lib/pe_install/pe_postgresql_info.rb'
56

6-
# GetPEAdmConfig task class
7-
class GetPSQLInfo
8-
def initialize(params); end
9-
10-
def execute!
7+
# Task which fetches the installed PSQL server major version
8+
class GetPSQLInfo < TaskHelper
9+
def task
1110
psql_info = PEPostgresqlInfo.new
12-
data = { 'version' => psql_info.installed_server_version }
13-
puts data.to_json
11+
{ 'version' => psql_info.installed_server_version }
1412
end
1513
end
1614

17-
# Run the task unless an environment flag has been set, signaling not to. The
18-
# environment flag is used to disable auto-execution and enable Ruby unit
19-
# testing of this task.
20-
unless ENV['RSPEC_UNIT_TEST_MODE']
21-
Puppet.initialize_settings
22-
task = GetPSQLInfo.new(JSON.parse(STDIN.read))
23-
task.execute!
24-
end
15+
GetPSQLInfo.run if $PROGRAM_NAME == __FILE__

0 commit comments

Comments
 (0)