puppet_litmus 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/exe/matrix_from_metadata_v2 +71 -22
- data/lib/puppet_litmus/inventory_manipulation.rb +4 -30
- data/lib/puppet_litmus/puppet_helpers.rb +217 -302
- data/lib/puppet_litmus/rake_helper.rb +84 -183
- data/lib/puppet_litmus/rake_tasks.rb +3 -8
- data/lib/puppet_litmus/version.rb +1 -1
- data/spec/exe/matrix_from_metadata_v2_spec.rb +6 -6
- data/spec/lib/puppet_litmus/puppet_helpers_spec.rb +0 -20
- data/spec/lib/puppet_litmus/rake_tasks_spec.rb +1 -1
- metadata +2 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4433a55c5c24b484d53d1584036b0bc8371f784dd762ce92eaff928ae984cb66
|
4
|
+
data.tar.gz: '08c533a7048dce835a3af639dad0c5f481533fd50be36739c0a0be416e450634'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c52c6c1b0fa3908ecc2dda5bbc4502e0acc4e03c3eb41704f20a729acfa04f13abd3c8c1ede9f38ba69ea6476d0e32eb3870e36db1862c94dd0195dd79e3dc9b
|
7
|
+
data.tar.gz: 44c24366269ac536d2089a3051099c2deeb1312f2b2e73ef64d99a2b9d2348abd0a173a4f65150ba19ffc56e1f7d3264dc1ca81796b278908c93222603b07804
|
data/exe/matrix_from_metadata_v2
CHANGED
@@ -94,29 +94,79 @@ else
|
|
94
94
|
exclude_list = []
|
95
95
|
end
|
96
96
|
|
97
|
+
# Force the use of the provision_service provisioner, if the --provision-service argument is present
|
98
|
+
if ARGV.include?('--provision-service')
|
99
|
+
provision_service_occurrences = ARGV.count { |arg| arg == '--provision-service' }
|
100
|
+
raise 'the --provision-service argument should be present just one time in the command' unless provision_service_occurrences <= 1
|
101
|
+
|
102
|
+
# NOTE: that the below are the only available images for the provision service
|
103
|
+
updated_platforms = {
|
104
|
+
'AlmaLinux-8' => 'almalinux-cloud/almalinux-8',
|
105
|
+
'CentOS-7' => 'centos-7',
|
106
|
+
'CentOS-8' => 'centos-stream-8',
|
107
|
+
'Rocky-8' => 'rocky-linux-cloud/rocky-linux-8',
|
108
|
+
'Debian-10' => 'debian-10',
|
109
|
+
'Debian-11' => 'debian-11',
|
110
|
+
'Ubuntu-20.04' => 'ubuntu-2004-lts',
|
111
|
+
'Ubuntu-22.04' => 'ubuntu-2204-lts'
|
112
|
+
}
|
113
|
+
|
114
|
+
updated_list = IMAGE_TABLE.dup.clone
|
115
|
+
updated_list.merge!(updated_platforms)
|
116
|
+
|
117
|
+
IMAGE_TABLE = updated_list.freeze
|
118
|
+
DOCKER_PLATFORMS = {}.freeze
|
119
|
+
end
|
120
|
+
|
97
121
|
metadata_path = ENV['TEST_MATRIX_FROM_METADATA'] || 'metadata.json'
|
98
122
|
metadata = JSON.parse(File.read(metadata_path))
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
}
|
123
|
+
|
124
|
+
# Allow the user to pass a file containing a custom matrix
|
125
|
+
if ARGV.include?('--custom-matrix')
|
126
|
+
custom_matrix_occurrences = ARGV.count { |arg| arg == '--custom-matrix' }
|
127
|
+
raise '--custom-matrix argument should be present just one time in the command' unless custom_matrix_occurrences <= 1
|
128
|
+
|
129
|
+
file_path = ARGV[ARGV.find_index('--custom-matrix') + 1]
|
130
|
+
raise 'no file path specified' if file_path.nil?
|
131
|
+
|
132
|
+
begin
|
133
|
+
custom_matrix = JSON.parse(File.read(file_path))
|
134
|
+
rescue StandardError => e
|
135
|
+
case e
|
136
|
+
when JSON::ParserError
|
137
|
+
raise 'the matrix must be an array of valid JSON objects'
|
138
|
+
when Errno::ENOENT
|
139
|
+
raise "File not found: #{e.message}"
|
117
140
|
else
|
118
|
-
|
119
|
-
|
141
|
+
raise "An unknown exception occurred: #{e.message}"
|
142
|
+
end
|
143
|
+
end
|
144
|
+
custom_matrix.each do |platform|
|
145
|
+
matrix[:platforms] << platform
|
146
|
+
end
|
147
|
+
else
|
148
|
+
# Set platforms based on declared operating system support
|
149
|
+
metadata['operatingsystem_support'].sort_by { |a| a['operatingsystem'] }.each do |sup|
|
150
|
+
os = sup['operatingsystem']
|
151
|
+
sup['operatingsystemrelease'].sort_by(&:to_i).each do |ver|
|
152
|
+
image_key = "#{os}-#{ver}"
|
153
|
+
|
154
|
+
if IMAGE_TABLE.key?(image_key) && !exclude_list.include?(image_key.downcase)
|
155
|
+
matrix[:platforms] << {
|
156
|
+
label: image_key,
|
157
|
+
provider: 'provision_service',
|
158
|
+
image: IMAGE_TABLE[image_key]
|
159
|
+
}
|
160
|
+
elsif DOCKER_PLATFORMS.key?(image_key) && !exclude_list.include?(image_key.downcase)
|
161
|
+
matrix[:platforms] << {
|
162
|
+
label: image_key,
|
163
|
+
provider: 'docker',
|
164
|
+
image: DOCKER_PLATFORMS[image_key]
|
165
|
+
}
|
166
|
+
else
|
167
|
+
puts "::warning::#{image_key} was excluded from testing" if exclude_list.include?(image_key.downcase)
|
168
|
+
puts "::warning::Cannot find image for #{image_key}" unless exclude_list.include?(image_key.downcase)
|
169
|
+
end
|
120
170
|
end
|
121
171
|
end
|
122
172
|
end
|
@@ -155,9 +205,8 @@ end
|
|
155
205
|
|
156
206
|
# Set to defaults (all collections) if no matches are found
|
157
207
|
matrix[:collection] = COLLECTION_TABLE.map { |collection| "puppet#{collection[:puppet_maj_version]}-nightly" } if matrix[:collection].empty?
|
158
|
-
|
159
208
|
# Just to make sure there aren't any duplicates
|
160
|
-
matrix[:platforms] = matrix[:platforms].uniq.sort_by { |a| a[:label] }
|
209
|
+
matrix[:platforms] = matrix[:platforms].uniq.sort_by { |a| a[:label] } unless ARGV.include?('--custom-matrix')
|
161
210
|
matrix[:collection] = matrix[:collection].uniq.sort
|
162
211
|
|
163
212
|
set_output('matrix', JSON.generate(matrix))
|
@@ -323,35 +323,9 @@ module PuppetLitmus::InventoryManipulation
|
|
323
323
|
# @param inventory_hash [Hash] hash of the inventory.yaml file
|
324
324
|
# @param node_name [String] node of nodes to limit the search for the node_name in
|
325
325
|
def add_platform_field(inventory_hash, node_name)
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
{}
|
331
|
-
end
|
332
|
-
Honeycomb.current_span.add_field('litmus.platform', facts&.dig('platform'))
|
333
|
-
end
|
334
|
-
|
335
|
-
# Add platform custom information field to the current span for each node being targeted.
|
336
|
-
# If more than one node is being targeted, each node will be given a separate custom field.
|
337
|
-
#
|
338
|
-
# @param span [Honeycomb::Span] The current span
|
339
|
-
# @param target_node_names [Array[String]] Nodes being targeted
|
340
|
-
# @param inventory_hash [Hash] Hash of the inventory.yaml file
|
341
|
-
def add_node_fields_to_span(span, target_node_names, inventory_hash)
|
342
|
-
node_counter = 1
|
343
|
-
Array(target_node_names).each do |target_name|
|
344
|
-
name_field = 'litmus.node_name'
|
345
|
-
platform_field = 'litmus.platform'
|
346
|
-
|
347
|
-
name_field = "#{name_field}_#{node_counter}"
|
348
|
-
platform_field = "#{platform_field}_#{node_counter}"
|
349
|
-
span.add_field(name_field, target_name)
|
350
|
-
if target_in_inventory?(inventory_hash, target_name)
|
351
|
-
facts = facts_from_node(inventory_hash, target_name)
|
352
|
-
span.add_field(platform_field, facts&.dig('platform')) unless facts.nil?
|
353
|
-
end
|
354
|
-
node_counter += 1
|
355
|
-
end
|
326
|
+
facts_from_node(inventory_hash, node_name)
|
327
|
+
rescue StandardError => e
|
328
|
+
warn e
|
329
|
+
{}
|
356
330
|
end
|
357
331
|
end
|