puppet_metadata 1.9.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -23
- data/bin/metadata2gha +13 -5
- data/lib/puppet_metadata/beaker.rb +10 -4
- data/lib/puppet_metadata/github_actions.rb +21 -18
- data/lib/puppet_metadata/metadata.rb +3 -19
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1763188bcd3297af8beb78aca2fc95986371390ea4e0d95178558c4744257a24
|
4
|
+
data.tar.gz: 9f00b77fef19f20ff4a0efc020c39e651aa4a35c71778ec6aba8d0538a10110c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 205f35c88e3d3106f3403505c90e5e6f14271c2be756662bc347fc79aee1fc03ef8e1b5b32d5b3374b95df0a628ecba8cc009f8bdb8ab5260252d45173aed4ba
|
7
|
+
data.tar.gz: e168ab33e1b0420031a08b833f46b85e22e60279b1c7228ad7188824021a9e0c12546995a406bfaa0016dcb3db3a07ab12635f9a615187f40746b648223da631
|
data/README.md
CHANGED
@@ -16,33 +16,10 @@ To get outputs [usable in Github Actions](https://docs.github.com/en/free-pro-te
|
|
16
16
|
|
17
17
|
```console
|
18
18
|
$ metadata2gha-beaker
|
19
|
-
beaker_setfiles=[{"name":"CentOS 7","value":"centos7-64"},{"name":"CentOS 8","value":"centos8-64"},{"name":"Debian 10","value":"debian10-64"},{"name":"Ubuntu 18.04","value":"ubuntu1804-64"}]
|
20
19
|
puppet_major_versions=[{"name":"Puppet 6","value":6,"collection":"puppet6"},{"name":"Puppet 5","value":5,"collection":"puppet5"}]
|
21
20
|
puppet_unit_test_matrix=[{"puppet":6,"ruby":"2.5"},{"puppet":5,"ruby":"2.4"}]
|
22
21
|
```
|
23
22
|
|
24
|
-
Beaker setfiles formatted for readability:
|
25
|
-
```json
|
26
|
-
[
|
27
|
-
{
|
28
|
-
"name": "CentOS 7",
|
29
|
-
"value": "centos7-64"
|
30
|
-
},
|
31
|
-
{
|
32
|
-
"name": "CentOS 8",
|
33
|
-
"value": "centos8-64"
|
34
|
-
},
|
35
|
-
{
|
36
|
-
"name": "Debian 10",
|
37
|
-
"value": "debian10-64"
|
38
|
-
},
|
39
|
-
{
|
40
|
-
"name": "Ubuntu 18.04",
|
41
|
-
"value": "ubuntu1804-64"
|
42
|
-
}
|
43
|
-
]
|
44
|
-
```
|
45
|
-
|
46
23
|
Puppet major versions formatted for readability:
|
47
24
|
```json
|
48
25
|
[
|
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
|
-
|
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
|
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] = "#{
|
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.
|
@@ -65,7 +71,7 @@ module PuppetMetadata
|
|
65
71
|
# Return whether a Beaker setfile can be generated for the given OS
|
66
72
|
# @param [String] os The operating system
|
67
73
|
def os_supported?(os)
|
68
|
-
['Archlinux', 'CentOS', 'Fedora', 'Debian', 'Ubuntu'].include?(os)
|
74
|
+
['Archlinux', 'CentOS', 'Fedora', 'Debian', 'Ubuntu', 'Rocky', 'AlmaLinux'].include?(os)
|
69
75
|
end
|
70
76
|
|
71
77
|
private
|
@@ -1,49 +1,43 @@
|
|
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
|
-
|
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
|
14
|
+
def outputs
|
12
15
|
{
|
13
|
-
beaker_setfiles: beaker_setfiles(beaker_use_fqdn, beaker_pidfile_workaround),
|
14
16
|
puppet_major_versions: puppet_major_versions,
|
15
17
|
puppet_unit_test_matrix: puppet_unit_test_matrix,
|
16
|
-
github_action_test_matrix: github_action_test_matrix
|
18
|
+
github_action_test_matrix: github_action_test_matrix,
|
17
19
|
}
|
18
20
|
end
|
19
21
|
|
20
22
|
private
|
21
23
|
|
22
|
-
def beaker_setfiles(use_fqdn, pidfile_workaround)
|
23
|
-
setfiles = []
|
24
|
-
metadata.beaker_setfiles(use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround) do |setfile, name|
|
25
|
-
setfiles << {
|
26
|
-
name: name,
|
27
|
-
value: setfile,
|
28
|
-
}
|
29
|
-
end
|
30
|
-
setfiles
|
31
|
-
end
|
32
|
-
|
33
24
|
def puppet_major_versions
|
34
25
|
metadata.puppet_major_versions.sort.reverse.map do |version|
|
26
|
+
next if puppet_version_below_minimum?(version)
|
27
|
+
|
35
28
|
{
|
36
29
|
name: "Puppet #{version}",
|
37
30
|
value: version,
|
38
31
|
collection: "puppet#{version}",
|
39
32
|
}
|
40
|
-
end
|
33
|
+
end.compact
|
41
34
|
end
|
42
35
|
|
43
36
|
def puppet_unit_test_matrix
|
44
37
|
metadata.puppet_major_versions.sort.reverse.map do |puppet|
|
45
38
|
ruby = PuppetMetadata::AIO::PUPPET_RUBY_VERSIONS[puppet]
|
46
39
|
next unless ruby
|
40
|
+
next if puppet_version_below_minimum?(puppet)
|
47
41
|
|
48
42
|
{
|
49
43
|
puppet: puppet,
|
@@ -71,12 +65,15 @@ module PuppetMetadata
|
|
71
65
|
end
|
72
66
|
end
|
73
67
|
|
74
|
-
def github_action_test_matrix
|
68
|
+
def github_action_test_matrix
|
75
69
|
matrix_include = []
|
76
70
|
|
77
71
|
beaker_os_releases do |os, release, puppet_version|
|
78
|
-
setfile = PuppetMetadata::Beaker.os_release_to_setfile(
|
72
|
+
setfile = PuppetMetadata::Beaker.os_release_to_setfile(
|
73
|
+
os, release, use_fqdn: options[:beaker_use_fqdn], pidfile_workaround: options[:beaker_pidfile_workaround], domain: options[:domain], puppet_version: puppet_version[:collection]
|
74
|
+
)
|
79
75
|
next unless setfile
|
76
|
+
next if puppet_version_below_minimum?(puppet_version[:value])
|
80
77
|
|
81
78
|
matrix_include << {
|
82
79
|
setfile: {
|
@@ -89,5 +86,11 @@ module PuppetMetadata
|
|
89
86
|
|
90
87
|
matrix_include
|
91
88
|
end
|
89
|
+
|
90
|
+
def puppet_version_below_minimum?(version)
|
91
|
+
return false unless options[:minimum_major_puppet_version]
|
92
|
+
|
93
|
+
Gem::Version.new(version) < Gem::Version.new(options[:minimum_major_puppet_version])
|
94
|
+
end
|
92
95
|
end
|
93
96
|
end
|
@@ -182,26 +182,10 @@ 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)
|
188
|
-
end
|
189
|
-
|
190
|
-
# @param [Boolean] use_fqdn
|
191
|
-
# Whether to set the hostname to a fully qualified domain name
|
192
|
-
# @param [Boolean] pidfile_workaround
|
193
|
-
# Whether to apply the Docker pidfile workaround
|
194
|
-
# @yieldparam [String] setfile
|
195
|
-
# The supported setfile configurations
|
196
|
-
# @see PuppetMetadata::Beaker#os_release_to_setfile
|
197
|
-
def beaker_setfiles(use_fqdn: false, pidfile_workaround: false)
|
198
|
-
operatingsystems.each do |os, releases|
|
199
|
-
next unless PuppetMetadata::Beaker.os_supported?(os)
|
200
|
-
releases&.each do |release|
|
201
|
-
setfile = PuppetMetadata::Beaker.os_release_to_setfile(os, release, use_fqdn: use_fqdn, pidfile_workaround: pidfile_workaround)
|
202
|
-
yield setfile if setfile
|
203
|
-
end
|
204
|
-
end
|
187
|
+
def github_actions(options)
|
188
|
+
PuppetMetadata::GithubActions.new(self, options)
|
205
189
|
end
|
206
190
|
|
207
191
|
private
|
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:
|
4
|
+
version: 2.0.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-
|
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
|
@@ -132,7 +132,7 @@ files:
|
|
132
132
|
- lib/puppet_metadata/github_actions.rb
|
133
133
|
- lib/puppet_metadata/metadata.rb
|
134
134
|
- lib/puppet_metadata/operatingsystem.rb
|
135
|
-
homepage:
|
135
|
+
homepage: https://github.com/voxpupuli/puppet_metadata
|
136
136
|
licenses:
|
137
137
|
- Apache-2.0
|
138
138
|
metadata: {}
|