puppet_metadata 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e9d1c84b47834137907ffd323ba3c70c3813acc98b7b3baeaf2351a48b0d268
4
- data.tar.gz: 7886a9e107fd780278bc3c94e083ae24bdfc0547d0347d6b144a9a5c61612484
3
+ metadata.gz: 1ee295ef02bb87ed87b68f0ebe2fea5813fff4e5316a5ffab59dee9bea6bb36f
4
+ data.tar.gz: 150eb04c272910087f6687f96e6673fd9dd616697b2f6779c87d06935ec83ddb
5
5
  SHA512:
6
- metadata.gz: 13ba21af9df52daa794b49571de0b8019a8f3da764f7945aa422c21f3c3041c03a00f89e3f2e48a60f3d6cd8ef4b60607f7ad3aa0d0d7fe18b433c9ab2b9635f
7
- data.tar.gz: 33742d5addb4d89e784a44d1c3252cf6119a73405c450351d74f6e6da617c9b0f321dc3ff4687fec07459d4a06d432bf8e0203bec3fe5b5b10e825598dc940c4
6
+ metadata.gz: 0aabfd90159725ac7c7029ccede234ec4d5351229293a32de1f37dbf3e34a05293cf07e4f7df79aef84b7c7ea686774f616f39086c18bad588c283bc14fa8d31
7
+ data.tar.gz: ebd5f32841912550eaab333eacd9259de97ef9c7583591e71ba417f8bc1e191ba25a66325503c05747c3619745b8427f1d932d42f5951e59eecf5383b708c089
data/bin/metadata2gha CHANGED
@@ -9,7 +9,7 @@ options = {
9
9
  beaker_use_fqdn: false,
10
10
  beaker_pidfile_workaround: false,
11
11
  domain: nil,
12
- minimum_major_puppet_version: nil
12
+ minimum_major_puppet_version: nil,
13
13
  }
14
14
 
15
15
  OptionParser.new do |opts|
@@ -26,25 +26,23 @@ OptionParser.new do |opts|
26
26
 
27
27
  opts.banner = "Usage: #{$0} [options] metadata"
28
28
 
29
- opts.on("--[no-]use-fqdn", "Generate beaker setfiles with a FQDN") { |opt| options[:beaker_use_fqdn] = opt }
30
- opts.on("--pidfile-workaround VALUE", "Generate the systemd PIDFile workaround to work around a docker bug", PidfileWorkaround) { |opt| options[:beaker_pidfile_workaround] = opt }
31
- opts.on("-d", "--domain VALUE", "the domain for the box, only used when --use-fqdn is set to true") { |opt| options[:domain] = opt }
32
- opts.on("--minimum-major-puppet-version VERSION", "Don't create actions for Puppet versions less than this major version") { |opt| options[:minimum_major_puppet_version] = opt }
29
+ opts.on('--[no-]use-fqdn', 'Generate beaker setfiles with a FQDN') { |opt| options[:beaker_use_fqdn] = opt }
30
+ opts.on('--pidfile-workaround VALUE', 'Generate the systemd PIDFile workaround to work around a docker bug', PidfileWorkaround) { |opt| options[:beaker_pidfile_workaround] = opt }
31
+ opts.on('-d', '--domain VALUE', 'the domain for the box, only used when --use-fqdn is set to true') { |opt| options[:domain] = opt }
32
+ opts.on('--minimum-major-puppet-version VERSION', "Don't create actions for Puppet versions less than this major version") { |opt| options[:minimum_major_puppet_version] = opt }
33
33
  end.parse!
34
34
 
35
35
  filename = ARGV[0]
36
- if filename.nil? || filename.empty?
37
- filename = 'metadata.json'
38
- end
36
+ filename = 'metadata.json' if filename.nil? || filename.empty?
39
37
 
40
38
  begin
41
39
  metadata = PuppetMetadata.read(filename)
42
40
  rescue StandardError => e
43
- STDERR.puts "Failed to read #{filename}: #{e}"
41
+ warn "Failed to read #{filename}: #{e}"
44
42
  exit 2
45
43
  end
46
44
 
47
- github_output = !ENV['GITHUB_OUTPUT'].nil? ? File.open(ENV['GITHUB_OUTPUT'], 'a') : $stdout
45
+ github_output = ENV['GITHUB_OUTPUT'].nil? ? $stdout : File.open(ENV.fetch('GITHUB_OUTPUT', nil), 'a')
48
46
  metadata.github_actions(options).outputs.each do |name, value|
49
47
  github_output.write("#{name}=#{value.to_json}\n")
50
48
  end
@@ -1,12 +1,12 @@
1
1
  module PuppetMetadata
2
2
  class AIO
3
3
  COMPATIBLE = {
4
- 'AlmaLinux' => 'RedHat',
5
- 'Amazon' => 'RedHat',
6
- 'CentOS' => 'RedHat',
4
+ 'AlmaLinux' => 'RedHat',
5
+ 'Amazon' => 'RedHat',
6
+ 'CentOS' => 'RedHat',
7
7
  'OracleLinux' => 'RedHat',
8
- 'Rocky' => 'RedHat',
9
- 'Scientific' => 'RedHat',
8
+ 'Rocky' => 'RedHat',
9
+ 'Scientific' => 'RedHat',
10
10
  }.freeze
11
11
 
12
12
  BUILDS = {
@@ -47,7 +47,7 @@ module PuppetMetadata
47
47
  return unless os_supported?(os)
48
48
 
49
49
  name = "#{os.downcase}#{release.tr('.', '')}-64"
50
- hostname = puppet_version != nil ? "#{name}-#{puppet_version}" : name
50
+ hostname = (puppet_version.nil? && puppet_version != 'none') ? name : "#{name}-#{puppet_version}"
51
51
  domain ||= 'example.com' if use_fqdn
52
52
 
53
53
  options = {}
@@ -71,7 +71,7 @@ module PuppetMetadata
71
71
  # Return whether a Beaker setfile can be generated for the given OS
72
72
  # @param [String] os The operating system
73
73
  def os_supported?(os)
74
- ['Archlinux', 'CentOS', 'Fedora', 'Debian', 'Ubuntu', 'Rocky', 'AlmaLinux'].include?(os)
74
+ %w[Archlinux CentOS Fedora Debian Ubuntu Rocky AlmaLinux].include?(os)
75
75
  end
76
76
 
77
77
  private
@@ -1,7 +1,6 @@
1
1
  module PuppetMetadata
2
2
  class GithubActions
3
- attr_reader :metadata
4
- attr_reader :options
3
+ attr_reader :metadata, :options
5
4
 
6
5
  # @param [PuppetMetadata::Metadata] metadata
7
6
  # @param [Hash] options
@@ -49,14 +48,20 @@ module PuppetMetadata
49
48
  def beaker_os_releases
50
49
  majors = puppet_major_versions
51
50
 
51
+ distro_puppet_version = {
52
+ name: 'Distro Puppet',
53
+ value: nil, # We don't know the version and since it's rolling, it can be anything
54
+ collection: 'none',
55
+ }
56
+
52
57
  metadata.operatingsystems.each do |os, releases|
53
58
  case os
54
59
  when 'Archlinux', 'Gentoo'
55
- yield [os, 'rolling', majors.max_by { |v| v[:value] }]
60
+ yield [os, 'rolling', distro_puppet_version]
56
61
  else
57
62
  releases&.each do |release|
58
63
  majors.each do |puppet_version|
59
- if AIO.has_aio_build?(os, release, puppet_version[:value])
64
+ if AIO.has_aio_build?(os, release, puppet_version[:value]) # rubocop:disable Style/IfUnlessModifier
60
65
  yield [os, release, puppet_version]
61
66
  end
62
67
  end
@@ -80,7 +85,7 @@ module PuppetMetadata
80
85
  name: setfile[1],
81
86
  value: setfile[0],
82
87
  },
83
- puppet: puppet_version
88
+ puppet: puppet_version,
84
89
  }
85
90
  end
86
91
 
@@ -88,7 +93,7 @@ module PuppetMetadata
88
93
  end
89
94
 
90
95
  def puppet_version_below_minimum?(version)
91
- return false unless options[:minimum_major_puppet_version]
96
+ return false unless version && options[:minimum_major_puppet_version]
92
97
 
93
98
  Gem::Version.new(version) < Gem::Version.new(options[:minimum_major_puppet_version])
94
99
  end
@@ -35,7 +35,7 @@ module PuppetMetadata
35
35
  if validate
36
36
  require 'metadata_json_lint'
37
37
  schema_errors = MetadataJsonLint::Schema.new.validate(metadata)
38
- raise InvalidMetadataException.new(schema_errors) if schema_errors.any?
38
+ raise InvalidMetadataException, schema_errors if schema_errors.any?
39
39
  end
40
40
 
41
41
  @metadata = metadata
@@ -67,10 +67,11 @@ module PuppetMetadata
67
67
 
68
68
  supported = metadata['operatingsystem_support'].map do |os|
69
69
  next unless os['operatingsystem']
70
+
70
71
  [os['operatingsystem'], os['operatingsystemrelease']]
71
72
  end
72
73
 
73
- Hash[supported.compact]
74
+ supported.compact.to_h
74
75
  end
75
76
  end
76
77
 
@@ -98,11 +99,12 @@ module PuppetMetadata
98
99
 
99
100
  unsupported = operatingsystems.map do |os, rels|
100
101
  next unless rels
102
+
101
103
  eol = rels.select { |rel| OperatingSystem.eol?(os, rel, at) }
102
104
  [os, eol] if eol.any?
103
105
  end
104
106
 
105
- Hash[unsupported.compact]
107
+ unsupported.compact.to_h
106
108
  end
107
109
 
108
110
  # A hash representation of the requirements
@@ -143,10 +145,12 @@ module PuppetMetadata
143
145
 
144
146
  # Current latest major is 7. It is highly recommended that modules
145
147
  # actually specify exact bounds, but this prevents an infinite loop.
146
- end_major = requirement.end == SemanticPuppet::Version::MAX ? 7 : requirement.end.major
148
+ end_major = (requirement.end == SemanticPuppet::Version::MAX) ? 7 : requirement.end.major
147
149
 
148
150
  (requirement.begin.major..end_major).select do |major|
149
- requirement.include?(SemanticPuppet::Version.new(major, 0, 0)) || requirement.include?(SemanticPuppet::Version.new(major, 99, 99))
151
+ requirement.include?(SemanticPuppet::Version.new(major, 0,
152
+ 0)) || requirement.include?(SemanticPuppet::Version.new(major,
153
+ 99, 99))
150
154
  end
151
155
  end
152
156
 
@@ -197,11 +201,12 @@ module PuppetMetadata
197
201
 
198
202
  reqs = array.map do |requirement|
199
203
  next unless requirement['name']
204
+
200
205
  version_requirement = requirement['version_requirement'] || '>= 0'
201
206
  [requirement['name'], SemanticPuppet::VersionRange.parse(version_requirement)]
202
207
  end
203
208
 
204
- Hash[reqs.compact]
209
+ reqs.compact.to_h
205
210
  end
206
211
 
207
212
  def matches?(required_version, provided_version)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
2
4
 
3
5
  module PuppetMetadata
@@ -157,8 +159,10 @@ module PuppetMetadata
157
159
  def eol_date(operatingsystem, release)
158
160
  releases = EOL_DATES[operatingsystem]
159
161
  return unless releases
162
+
160
163
  date = releases[release]
161
164
  return unless date
165
+
162
166
  Date.parse(date)
163
167
  end
164
168
 
@@ -193,8 +197,8 @@ module PuppetMetadata
193
197
  def supported_releases(operatingsystem)
194
198
  releases = EOL_DATES[operatingsystem]
195
199
  today = Date.today
196
- releases.select { |release, eol_date| !eol_date || Date.parse(eol_date) > today }.keys.
197
- sort_by { |release| Gem::Version.new(release) }
200
+ releases.select { |_release, eol_date| !eol_date || Date.parse(eol_date) > today }.keys
201
+ .sort_by { |release| Gem::Version.new(release) }
198
202
  end
199
203
  end
200
204
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # A module that provides abstractions around Puppet's metadata format.
2
4
  module PuppetMetadata
3
5
  autoload :AIO, 'puppet_metadata/aio'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet_metadata
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vox Pupuli
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-04-29 00:00:00.000000000 Z
12
+ date: 2023-07-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: metadata-json-lint
@@ -59,6 +59,20 @@ dependencies:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '13.0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rdoc
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '6.0'
69
+ type: :development
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '6.0'
62
76
  - !ruby/object:Gem::Dependency
63
77
  name: rspec
64
78
  requirement: !ruby/object:Gem::Requirement
@@ -88,19 +102,19 @@ dependencies:
88
102
  - !ruby/object:Gem::Version
89
103
  version: '1.0'
90
104
  - !ruby/object:Gem::Dependency
91
- name: rdoc
105
+ name: voxpupuli-rubocop
92
106
  requirement: !ruby/object:Gem::Requirement
93
107
  requirements:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
- version: '6.0'
110
+ version: 2.0.0
97
111
  type: :development
98
112
  prerelease: false
99
113
  version_requirements: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: '6.0'
117
+ version: 2.0.0
104
118
  - !ruby/object:Gem::Dependency
105
119
  name: yard
106
120
  requirement: !ruby/object:Gem::Requirement
@@ -147,6 +161,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
161
  - - ">="
148
162
  - !ruby/object:Gem::Version
149
163
  version: '2.7'
164
+ - - "<"
165
+ - !ruby/object:Gem::Version
166
+ version: '4'
150
167
  required_rubygems_version: !ruby/object:Gem::Requirement
151
168
  requirements:
152
169
  - - ">="