puppet_metadata 1.9.0 → 1.10.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: a5ed509fe1ad25088c9596721f674e5d2c730db03958d3f538fbd3c05d87d330
4
- data.tar.gz: a66c279bfd4f85ad8dfabf8d85ba73bd406363a190af4bbac6b9c3d3a561cb7b
3
+ metadata.gz: 68bedde8f6ea8a9ec17503af06a802c698f01778c67c9e9d5ad4a94a607ae8c9
4
+ data.tar.gz: 9e0681df7996aeb6238a8527b053d136004c3616de2b81389b7a8e045a5fbf1c
5
5
  SHA512:
6
- metadata.gz: 2ee5a4ec7f9ae96f7da02dcbc2dadc83a16a20d44c31ec4991abe638adcd34524d920f28039e5c5b78fb09ac7b0a63529b531cc5e7e8da339af170abc174b638
7
- data.tar.gz: 02c8a63f6ae12572cd88582c6ad74804888bbfbc2de273ea277a249d39d429ad4f69676446ee460e39d6f89658d6b0f1d99429cdb71dd40425aa7023eab1ca84
6
+ metadata.gz: c46ae6d205020e08d950d9c67c237b5a8e1ddf97ab07c304f429b0457ec68c6f1df09f9ef8f7232f10ff6e3179827d30db16a464ab35b89919d5c6f26c09ef49
7
+ data.tar.gz: 1a5bac401ba8acce959f7c1e5bf415eff67f6b46513b810c74bd7befc61f87be8b772aaee42ba009668a80a001e52e9302095e7ea0834f698e83bcd1e0433cde
data/bin/metadata2gha CHANGED
@@ -5,7 +5,13 @@ require 'puppet_metadata'
5
5
 
6
6
  PidfileWorkaround = Object.new
7
7
 
8
- options = {}
8
+ options = {
9
+ beaker_use_fqdn: false,
10
+ beaker_pidfile_workaround: false,
11
+ domain: nil,
12
+ minimum_major_puppet_version: nil
13
+ }
14
+
9
15
  OptionParser.new do |opts|
10
16
  opts.accept(PidfileWorkaround) do |value|
11
17
  case value
@@ -20,9 +26,11 @@ OptionParser.new do |opts|
20
26
 
21
27
  opts.banner = "Usage: #{$0} [options] metadata"
22
28
 
23
- opts.on("--[no-]use-fqdn", "Generate beaker setfiles with a FQDN")
24
- opts.on("--pidfile-workaround VALUE", "Generate the systemd PIDFile workaround to work around a docker bug", PidfileWorkaround)
25
- end.parse!(into: options)
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
+ end.parse!
26
34
 
27
35
  filename = ARGV[0]
28
36
  if filename.nil? || filename.empty?
@@ -37,7 +45,7 @@ rescue StandardError => e
37
45
  end
38
46
 
39
47
  github_output = !ENV['GITHUB_OUTPUT'].nil? ? File.open(ENV['GITHUB_OUTPUT'], 'a') : $stdout
40
- metadata.github_actions.outputs(beaker_use_fqdn: options[:'use-fqdn'], beaker_pidfile_workaround: options[:'pidfile-workaround']).each do |name, value|
48
+ metadata.github_actions(options).outputs.each do |name, value|
41
49
  github_output.write("#{name}=#{value.to_json}\n")
42
50
  end
43
51
  github_output.close
@@ -28,7 +28,7 @@ module PuppetMetadata
28
28
  # based on Facter's operatingsystem fact.
29
29
  # @param [String] release The OS release
30
30
  # @param [Boolean] use_fqdn
31
- # Whether or not to use a FQDN, ensuring a domain
31
+ # Whether or not to use a FQDN, ensuring a domain (deprecated, use domain)
32
32
  # @param [Boolean, Array[String]] pidfile_workaround
33
33
  # Whether or not to apply the systemd PIDFile workaround. This is only
34
34
  # needed when the daemon uses PIDFile in its service file and using
@@ -36,16 +36,22 @@ module PuppetMetadata
36
36
  # limitations.
37
37
  # When a boolean, it's applied on applicable operating systems. On arrays
38
38
  # it's applied only when os is included in the provided array.
39
+ # @param [Optional[String]] domain
40
+ # Enforce a domain to be appended to the hostname, making it an FQDN
41
+ # @param [Optional[String]] puppet_version
42
+ # The desired puppet version. Will be appended to the hostname
39
43
  #
40
44
  # @return [nil] If no setfile is available
41
45
  # @return [Array<(String, String)>] The beaker setfile description with a readable name
42
- def os_release_to_setfile(os, release, use_fqdn: false, pidfile_workaround: false)
46
+ def os_release_to_setfile(os, release, use_fqdn: false, pidfile_workaround: false, domain: nil, puppet_version: nil)
43
47
  return unless os_supported?(os)
44
48
 
45
49
  name = "#{os.downcase}#{release.tr('.', '')}-64"
50
+ hostname = puppet_version != nil ? "#{name}-#{puppet_version}" : name
51
+ domain ||= 'example.com' if use_fqdn
46
52
 
47
53
  options = {}
48
- options[:hostname] = "#{name}.example.com" if use_fqdn
54
+ options[:hostname] = "#{hostname}.#{domain}" if domain
49
55
 
50
56
  # Docker messes up cgroups and some systemd versions can't deal with
51
57
  # that when PIDFile is used.
@@ -1,27 +1,31 @@
1
1
  module PuppetMetadata
2
2
  class GithubActions
3
3
  attr_reader :metadata
4
+ attr_reader :options
4
5
 
5
6
  # @param [PuppetMetadata::Metadata] metadata
6
- def initialize(metadata)
7
+ # @param [Hash] options
8
+ def initialize(metadata, options)
7
9
  @metadata = metadata
10
+ @options = options
8
11
  end
9
12
 
10
13
  # @return [Hash[Symbol, Any]] The outputs for Github Actions
11
- def outputs(beaker_use_fqdn: false, beaker_pidfile_workaround: false)
14
+ def outputs
12
15
  {
13
- beaker_setfiles: beaker_setfiles(beaker_use_fqdn, beaker_pidfile_workaround),
16
+ beaker_setfiles: beaker_setfiles,
14
17
  puppet_major_versions: puppet_major_versions,
15
18
  puppet_unit_test_matrix: puppet_unit_test_matrix,
16
- github_action_test_matrix: github_action_test_matrix(use_fqdn: beaker_use_fqdn, pidfile_workaround: beaker_pidfile_workaround),
19
+ github_action_test_matrix: github_action_test_matrix,
17
20
  }
18
21
  end
19
22
 
20
23
  private
21
24
 
22
- def beaker_setfiles(use_fqdn, pidfile_workaround)
25
+
26
+ def beaker_setfiles
23
27
  setfiles = []
24
- metadata.beaker_setfiles(use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround) do |setfile, name|
28
+ metadata.beaker_setfiles(use_fqdn: options[:beaker_use_fqdn], pidfile_workaround: options[:beaker_pidfile_workaround], domain: options[:domain]) do |setfile, name|
25
29
  setfiles << {
26
30
  name: name,
27
31
  value: setfile,
@@ -32,18 +36,21 @@ module PuppetMetadata
32
36
 
33
37
  def puppet_major_versions
34
38
  metadata.puppet_major_versions.sort.reverse.map do |version|
39
+ next if puppet_version_below_minimum?(version)
40
+
35
41
  {
36
42
  name: "Puppet #{version}",
37
43
  value: version,
38
44
  collection: "puppet#{version}",
39
45
  }
40
- end
46
+ end.compact
41
47
  end
42
48
 
43
49
  def puppet_unit_test_matrix
44
50
  metadata.puppet_major_versions.sort.reverse.map do |puppet|
45
51
  ruby = PuppetMetadata::AIO::PUPPET_RUBY_VERSIONS[puppet]
46
52
  next unless ruby
53
+ next if puppet_version_below_minimum?(puppet)
47
54
 
48
55
  {
49
56
  puppet: puppet,
@@ -71,12 +78,15 @@ module PuppetMetadata
71
78
  end
72
79
  end
73
80
 
74
- def github_action_test_matrix(use_fqdn: false, pidfile_workaround: false)
81
+ def github_action_test_matrix
75
82
  matrix_include = []
76
83
 
77
84
  beaker_os_releases do |os, release, puppet_version|
78
- setfile = PuppetMetadata::Beaker.os_release_to_setfile(os, release, use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround)
85
+ setfile = PuppetMetadata::Beaker.os_release_to_setfile(
86
+ os, release, use_fqdn: options[:beaker_use_fqdn], pidfile_workaround: options[:beaker_pidfile_workaround], domain: options[:domain], puppet_version: puppet_version[:collection]
87
+ )
79
88
  next unless setfile
89
+ next if puppet_version_below_minimum?(puppet_version[:value])
80
90
 
81
91
  matrix_include << {
82
92
  setfile: {
@@ -89,5 +99,11 @@ module PuppetMetadata
89
99
 
90
100
  matrix_include
91
101
  end
102
+
103
+ def puppet_version_below_minimum?(version)
104
+ return false unless options[:minimum_major_puppet_version]
105
+
106
+ Gem::Version.new(version) < Gem::Version.new(options[:minimum_major_puppet_version])
107
+ end
92
108
  end
93
109
  end
@@ -182,23 +182,26 @@ module PuppetMetadata
182
182
  matches?(dependencies[name], version)
183
183
  end
184
184
 
185
+ # @param [Hash] options A hash containing the command line options
185
186
  # @return [PuppetMetadata::GithubActions] A GithubActions instance
186
- def github_actions
187
- PuppetMetadata::GithubActions.new(self)
187
+ def github_actions(options)
188
+ PuppetMetadata::GithubActions.new(self, options)
188
189
  end
189
190
 
190
191
  # @param [Boolean] use_fqdn
191
- # Whether to set the hostname to a fully qualified domain name
192
+ # Whether to set the hostname to a fully qualified domain name (deprecated, use domain)
192
193
  # @param [Boolean] pidfile_workaround
193
194
  # Whether to apply the Docker pidfile workaround
195
+ # @param [String] domain
196
+ # Enforce a domain to be appended to the hostname, making it an FQDN
194
197
  # @yieldparam [String] setfile
195
198
  # The supported setfile configurations
196
199
  # @see PuppetMetadata::Beaker#os_release_to_setfile
197
- def beaker_setfiles(use_fqdn: false, pidfile_workaround: false)
200
+ def beaker_setfiles(use_fqdn: false, pidfile_workaround: false, domain: nil)
198
201
  operatingsystems.each do |os, releases|
199
202
  next unless PuppetMetadata::Beaker.os_supported?(os)
200
203
  releases&.each do |release|
201
- setfile = PuppetMetadata::Beaker.os_release_to_setfile(os, release, use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround)
204
+ setfile = PuppetMetadata::Beaker.os_release_to_setfile(os, release, use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround, domain: domain)
202
205
  yield setfile if setfile
203
206
  end
204
207
  end
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: 1.9.0
4
+ version: 1.10.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: 2022-12-05 00:00:00.000000000 Z
12
+ date: 2022-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: metadata-json-lint