metadata_json_deps 0.4.0 → 0.5.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 +30 -0
- data/bin/bump-dependency-upper-bound +32 -0
- data/lib/metadata_json_deps.rb +38 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6179bcf58c7d31443f14ee253a6138a39eb9cc5ee6522ad3ce90808af18b72c9
|
4
|
+
data.tar.gz: df68258de0fe2b4a056fd0bf71b00652f97ff127e5a925c99fc11cf0bb72ca82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7386a095e6ae88bae37389863f813d07748bb8bd4a194f0d9a27b6156202670f2f93bd9b10b856d8d16f35f3e8be7da6386bc255d06d3f9cd31b7445d94ded0e
|
7
|
+
data.tar.gz: a02885daa2cae0fc442dbb92041a9db103a8fa72f10cf0bb3b46d75b1021198f9c24c40e7f563b119105f71b6eafccf4088ba55754daa58a0842754e3db12e25
|
data/README.md
CHANGED
@@ -28,6 +28,20 @@ On the command line, run `metadata-json-deps` with the path(s) of your `metadata
|
|
28
28
|
metadata-json-deps /path/to/metadata.json
|
29
29
|
```
|
30
30
|
|
31
|
+
Example output:
|
32
|
+
|
33
|
+
```console
|
34
|
+
$ metadata-json-deps modules/*/*/metadata.json
|
35
|
+
Checking modules/theforeman/puppet-candlepin/metadata.json
|
36
|
+
puppetlabs/stdlib (>= 4.2.0 < 8.0.0) doesn't match 8.1.0
|
37
|
+
puppet/extlib (>= 3.0.0 < 6.0.0) doesn't match 6.0.0
|
38
|
+
Checking modules/theforeman/puppet-certs/metadata.json
|
39
|
+
puppetlabs-stdlib (>= 4.25.0 < 8.0.0) doesn't match 8.1.0
|
40
|
+
puppet-extlib (>= 3.0.0 < 6.0.0) doesn't match 6.0.0
|
41
|
+
Checking modules/theforeman/puppet-dhcp/metadata.json
|
42
|
+
Checking modules/theforeman/puppet-dns/metadata.json
|
43
|
+
```
|
44
|
+
|
31
45
|
It can also be run verbosely to show valid dependencies:
|
32
46
|
|
33
47
|
```shell
|
@@ -47,3 +61,19 @@ task :metadata_deps do
|
|
47
61
|
MetadataJsonDeps::run(files)
|
48
62
|
end
|
49
63
|
```
|
64
|
+
|
65
|
+
### Bumping dependency upper bounds
|
66
|
+
|
67
|
+
After detecting outdated dependencies, it's important to do something about this. Taking the earlier example, you can see some modules should allow newer dependencies (candlepin and certs) while others are up to date (dhcp and dns).
|
68
|
+
|
69
|
+
The next step is to look into the newer dependencies. In this case stdlib and extlib had a major version bump. It is then important to look at the changes and see if it does affect modules. Sometimes it doesn't, like when a module drops support for Puppet 5 but our modules already dropped Puppet 5. In that case, it's safe to raise the upper version bound.
|
70
|
+
|
71
|
+
To update the upper bounds, [bump-dependency-upper-bound](https://github.com/voxpupuli/modulesync_config/blob/master/bin/bump-dependency-upper-bound) can be used. For example, to allow puppetlabs/stdlib 8.x, the new upper bound is 9.0.0:
|
72
|
+
|
73
|
+
```console
|
74
|
+
$ bump-dependency-upper-bound puppetlabs/stdlib 9.0.0 modules/*/*/metadata.json
|
75
|
+
Updated modules/theforeman/puppet-candlepin/metadata.json: '>= 4.2.0 < 8.0.0' to '>= 4.2.0 < 9.0.0'
|
76
|
+
Updated modules/theforeman/puppet-certs/metadata.json: '>= 4.25.0 < 8.0.0' to '>= 4.25.0 < 9.0.0'
|
77
|
+
modules/theforeman/puppet-dhcp/metadata.json already matches 9.0.0
|
78
|
+
modules/theforeman/puppet-dns/metadata.json already matches 9.0.0
|
79
|
+
```
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require 'metadata_json_deps'
|
4
|
+
|
5
|
+
def main
|
6
|
+
parser = OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: #{opts.program_name} module_name new_upper_bound metadata"
|
8
|
+
end
|
9
|
+
|
10
|
+
parser.parse!
|
11
|
+
if ARGV.length < 3
|
12
|
+
STDERR.puts parser.help
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
|
16
|
+
module_name, upper_bound, *paths = ARGV
|
17
|
+
module_name = PuppetForge::V3.normalize_name(module_name)
|
18
|
+
paths.each do |path|
|
19
|
+
begin
|
20
|
+
old, new = MetadataJsonDeps.bump_dependency(path, module_name, upper_bound)
|
21
|
+
if old != new
|
22
|
+
puts "Updated #{path}: '#{old}' to '#{new}'"
|
23
|
+
else
|
24
|
+
puts "#{path} already matches #{upper_bound}"
|
25
|
+
end
|
26
|
+
rescue Exception => e
|
27
|
+
puts "Failed to update #{path}: #{e}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
main
|
data/lib/metadata_json_deps.rb
CHANGED
@@ -35,6 +35,44 @@ module MetadataJsonDeps
|
|
35
35
|
puts result.to_yaml
|
36
36
|
end
|
37
37
|
|
38
|
+
# Bump a dependency in a filename
|
39
|
+
#
|
40
|
+
# @param [String] filename A path to a metadata file. An error is raised if
|
41
|
+
# it's invalid metadata.
|
42
|
+
# @param [String] module_name The module name listed in dependencies. It must
|
43
|
+
# be normalized to the forge style (using a dash). It can fall back to a
|
44
|
+
# slash if metadata uses a slash.
|
45
|
+
# @param [String] upper_bound The new upper bound for the module name
|
46
|
+
# @return [Array<String>] An array with the old and new version. Can be used
|
47
|
+
# to determine if a change was made.
|
48
|
+
# @see PuppetMetadata.read
|
49
|
+
def self.bump_dependency(filename, module_name, upper_bound)
|
50
|
+
metadata = PuppetMetadata.read(filename)
|
51
|
+
|
52
|
+
requirement = metadata.dependencies[module_name]
|
53
|
+
unless requirement
|
54
|
+
# TODO: normalize keys in puppet_metadata so we don't need 2 lookups?
|
55
|
+
module_name = module_name.tr('-', '/')
|
56
|
+
requirement = metadata.dependencies[module_name]
|
57
|
+
raise Exception.new("Dependency #{module_name} not found") unless requirement
|
58
|
+
end
|
59
|
+
|
60
|
+
return [requirement.to_s, requirement.to_s] if requirement.end == upper_bound
|
61
|
+
|
62
|
+
new = ">= #{requirement.begin} < #{upper_bound}"
|
63
|
+
|
64
|
+
new_metadata = metadata.metadata.clone
|
65
|
+
new_metadata['dependencies'].each do |dependency|
|
66
|
+
if dependency['name'] == module_name
|
67
|
+
dependency['version_requirement'] = new
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
File.write(filename, JSON.pretty_generate(new_metadata) + "\n")
|
72
|
+
|
73
|
+
[requirement.to_s, new]
|
74
|
+
end
|
75
|
+
|
38
76
|
def self.run(filenames, verbose = false)
|
39
77
|
forge = ForgeVersions.new
|
40
78
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metadata_json_deps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ewoud Kohl van Wijngaarden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puppet_forge
|
@@ -81,6 +81,7 @@ dependencies:
|
|
81
81
|
description: Verify all your dependencies allow the latest versions on Puppet Forge
|
82
82
|
email: ewoud+rubygems@kohlvanwijngaarden.nl
|
83
83
|
executables:
|
84
|
+
- bump-dependency-upper-bound
|
84
85
|
- generate-fixtures-yaml
|
85
86
|
- metadata-json-deps
|
86
87
|
extensions: []
|
@@ -89,6 +90,7 @@ extra_rdoc_files:
|
|
89
90
|
files:
|
90
91
|
- LICENSE
|
91
92
|
- README.md
|
93
|
+
- bin/bump-dependency-upper-bound
|
92
94
|
- bin/generate-fixtures-yaml
|
93
95
|
- bin/metadata-json-deps
|
94
96
|
- lib/metadata_json_deps.rb
|