ra10ke 0.6.2 → 1.0.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/CHANGELOG.md +11 -0
- data/README.md +23 -1
- data/lib/ra10ke.rb +3 -0
- data/lib/ra10ke/duplicates.rb +79 -0
- data/lib/ra10ke/validate.rb +6 -6
- data/lib/ra10ke/version.rb +1 -1
- data/ra10ke.gemspec +1 -1
- data/spec/fixtures/Puppetfile +1 -1
- data/spec/fixtures/Puppetfile_with_duplicates +50 -0
- data/spec/ra10ke/duplicates_spec.rb +31 -0
- data/spec/ra10ke/puppetfile_parser_spec.rb +2 -2
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b40e69bd38407cb3c0e54c36a83cdc1699ac85ea8512118275bce2f9e8dc6ef
|
4
|
+
data.tar.gz: 4cedb006d2cf6591280e75df20fcf33ba4abdd5f8647caf68497f13c53c05f36
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d87d64c5635eb697987a69e3ce56dcb230175f43182ee67e54817da51624c07426ad5f7c82b6f31c896ef88e2ed2132584c5dfc4d085c591e9336fc1d5fc6b3
|
7
|
+
data.tar.gz: 84247260dbf741c18cd0aef1888b40f07328c015b228f1c021ae15c1d8846497819bbe6a6226e51cfe43697e84707c4d0a827f57796a6e73cce76015b354272a
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,17 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
=========
|
3
3
|
|
4
|
+
1.0.0
|
5
|
+
-----
|
6
|
+
|
7
|
+
2020-02-08
|
8
|
+
|
9
|
+
Closed Pull Requests:
|
10
|
+
|
11
|
+
* [#44](https://github.com/voxpupuli/ra10ke/pull/44) - Fix the faulty docs for Ra10ke::Validate#all_refs after [#42](https://github.com/voxpupuli/ra10ke/pull/42)
|
12
|
+
* [#45](https://github.com/voxpupuli/ra10ke/pull/45) - Add a duplicates check
|
13
|
+
* [#48](https://github.com/voxpupuli/ra10ke/pull/48) - Allow semverse 3.x
|
14
|
+
|
4
15
|
0.6.2
|
5
16
|
-----
|
6
17
|
|
data/README.md
CHANGED
@@ -111,7 +111,7 @@ Example
|
|
111
111
|
```
|
112
112
|
NAME | URL | REF | STATUS
|
113
113
|
---------|-----------------------------------------------|--------------------------------|-------
|
114
|
-
splunk | https://github.com/cudgel/splunk.git |
|
114
|
+
splunk | https://github.com/cudgel/splunk.git | dev | 👍
|
115
115
|
r10k | https://github.com/acidprime/r10k | v3.1.1 | 👍
|
116
116
|
gms | https://github.com/npwalker/abrader-gms | gitlab_disable_ssl_verify_s... | 👍
|
117
117
|
rbac | https://github.com/puppetlabs/pltraining-rbac | 2f60e1789a721ce83f8df061e13... | 👍
|
@@ -123,3 +123,25 @@ gitlab | https://github.com/vshn/puppet-gitlab | 00397b86dfb3487d9df76
|
|
123
123
|
👍👍 Puppetfile looks good.👍👍
|
124
124
|
```
|
125
125
|
|
126
|
+
### r10k:duplicates
|
127
|
+
|
128
|
+
This rake task parses the Puppetfile and looks for modules with duplicate
|
129
|
+
declarations.
|
130
|
+
|
131
|
+
All found duplicates are reported along with their source and their version
|
132
|
+
(if taken from the Forge) or their ref/tag/branch. (if taken from git)
|
133
|
+
|
134
|
+
Example
|
135
|
+
|
136
|
+
```
|
137
|
+
puppet:
|
138
|
+
- abstractit/puppet from the forge at version 2.4.1
|
139
|
+
- theforeman/puppet from the forge at version 12.0.1
|
140
|
+
- puppet from git on the branch master at https://github.com/voxpupuli/puppet-module.git
|
141
|
+
|
142
|
+
gitlab:
|
143
|
+
- puppet/gitlab from the forge at version 4.0.1
|
144
|
+
- gitlab from git on the ref 00397b86dfb3487d9df768cbd3698d362132b5bf at https://github.com/vshn/puppet-gitlab
|
145
|
+
|
146
|
+
Error: Duplicates exist in the Puppetfile
|
147
|
+
```
|
data/lib/ra10ke.rb
CHANGED
@@ -4,6 +4,7 @@ require 'ra10ke/version'
|
|
4
4
|
require 'ra10ke/solve'
|
5
5
|
require 'ra10ke/syntax'
|
6
6
|
require 'ra10ke/dependencies'
|
7
|
+
require 'ra10ke/duplicates'
|
7
8
|
require 'ra10ke/install'
|
8
9
|
require 'ra10ke/validate'
|
9
10
|
require 'git'
|
@@ -14,6 +15,7 @@ module Ra10ke
|
|
14
15
|
include Ra10ke::Solve
|
15
16
|
include Ra10ke::Syntax
|
16
17
|
include Ra10ke::Dependencies
|
18
|
+
include Ra10ke::Duplicates
|
17
19
|
include Ra10ke::Install
|
18
20
|
include Ra10ke::Validate
|
19
21
|
|
@@ -33,6 +35,7 @@ module Ra10ke
|
|
33
35
|
define_task_solve_dependencies(*args)
|
34
36
|
define_task_syntax(*args)
|
35
37
|
define_task_dependencies(*args)
|
38
|
+
define_task_duplicates(*args)
|
36
39
|
define_task_install(*args)
|
37
40
|
define_task_validate(*args)
|
38
41
|
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'ra10ke/monkey_patches'
|
4
|
+
require 'ra10ke/puppetfile_parser'
|
5
|
+
|
6
|
+
module Ra10ke::Duplicates
|
7
|
+
def define_task_duplicates(*_args)
|
8
|
+
desc "Check Puppetfile for duplicates"
|
9
|
+
task :duplicates do
|
10
|
+
duplicates = Ra10ke::Duplicates::Verification.new(get_puppetfile.puppetfile_path).duplicates
|
11
|
+
exit_code = 0
|
12
|
+
if duplicates.any?
|
13
|
+
exit_code = 1
|
14
|
+
message = 'Error: Duplicates exist in the Puppetfile'
|
15
|
+
|
16
|
+
duplicates.map do |name, sources|
|
17
|
+
puts "#{name}:"
|
18
|
+
sources.each do |source|
|
19
|
+
puts "- #{source}"
|
20
|
+
end
|
21
|
+
|
22
|
+
puts
|
23
|
+
end
|
24
|
+
else
|
25
|
+
message = 'Puppetfile is free of duplicates'
|
26
|
+
end
|
27
|
+
|
28
|
+
abort(message) if exit_code.positive?
|
29
|
+
puts message
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Verification
|
34
|
+
include Ra10ke::PuppetfileParser
|
35
|
+
Module = Struct.new(:namespace, :name, :args) do
|
36
|
+
def git?
|
37
|
+
args.key? :git
|
38
|
+
end
|
39
|
+
|
40
|
+
def forge?
|
41
|
+
!git?
|
42
|
+
end
|
43
|
+
|
44
|
+
def type
|
45
|
+
git? ? 'git' : 'forge'
|
46
|
+
end
|
47
|
+
|
48
|
+
def to_s
|
49
|
+
str = "#{[namespace, name].compact.join '/'}"
|
50
|
+
|
51
|
+
if git?
|
52
|
+
ref = args[:ref] || args[:tag] || args[:branch]
|
53
|
+
ref_type = (args[:ref] && 'ref') || (args[:tag] && 'tag') || (args[:branch] && 'branch')
|
54
|
+
str += " from git on the #{ref_type} #{ref} at #{args[:git]}"
|
55
|
+
elsif args.key? :version
|
56
|
+
str += " from the forge at version #{args[:version]}"
|
57
|
+
end
|
58
|
+
|
59
|
+
str
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
attr_reader :puppetfile
|
64
|
+
|
65
|
+
def initialize(file)
|
66
|
+
file ||= './Puppetfile'
|
67
|
+
@puppetfile = File.expand_path(file)
|
68
|
+
abort("Puppetfile does not exist at #{puppetfile}") unless File.readable?(puppetfile)
|
69
|
+
end
|
70
|
+
|
71
|
+
def duplicates
|
72
|
+
to_ret = {}
|
73
|
+
modules(puppetfile).each do |mod|
|
74
|
+
(to_ret[mod[:name]] ||= []) << Module.new(mod[:namespace], mod[:name], mod[:args])
|
75
|
+
end
|
76
|
+
to_ret.select { |_k, v| v.count > 1 }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/ra10ke/validate.rb
CHANGED
@@ -55,14 +55,14 @@ module Ra10ke
|
|
55
55
|
!found.nil?
|
56
56
|
end
|
57
57
|
|
58
|
-
# @return [
|
58
|
+
# @return [Array] - an array of all the refs associated with the remote repository
|
59
59
|
# @param url [String] - the git string either https or ssh url
|
60
60
|
# @example
|
61
|
-
#
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
# [{:sha=>"0ec707e431367bbe2752966be8ab915b6f0da754", :ref=>"refs/heads/74110ac", :type=>:branch, :subtype=>nil, :name=>"74110ac"},
|
62
|
+
# :sha=>"07bb5d2d94db222dca5860eb29c184e8970f36f4", :ref=>"refs/pull/74/head", :type=>:pull, :subtype=>:head, :name=>"74"},
|
63
|
+
# :sha=>"156ca9a8ea69e056e86355b27d944e59d1b3a1e1", :ref=>"refs/heads/master", :type=>:branch, :subtype=>nil, :name=>"master"},
|
64
|
+
# :sha=>"fcc0532bbc5a5b65f3941738339e9cc7e3d767ce", :ref=>"refs/pull/249/head", :type=>:pull, :subtype=>:head, :name=>"249"},
|
65
|
+
# :sha=>"8d54891fa5df75890ee15d53080c2a81b4960f92", :ref=>"refs/pull/267/head", :type=>:pull, :subtype=>:head, :name=>"267"}]
|
66
66
|
def all_refs(url)
|
67
67
|
data = `git ls-remote --symref #{url}`
|
68
68
|
raise "Error downloading #{url}" unless $CHILD_STATUS.success?
|
data/lib/ra10ke/version.rb
CHANGED
data/ra10ke.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency "r10k"
|
22
22
|
spec.add_dependency "git"
|
23
23
|
spec.add_dependency "solve"
|
24
|
-
spec.add_dependency 'semverse', '
|
24
|
+
spec.add_dependency 'semverse', '>= 2.0'
|
25
25
|
spec.add_dependency 'table_print', '~> 1.5.6'
|
26
26
|
spec.add_development_dependency 'rspec', '~> 3.6'
|
27
27
|
end
|
data/spec/fixtures/Puppetfile
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
forge 'http://forge.puppetlabs.com'
|
4
|
+
|
5
|
+
mod 'abstractit/puppet', '2.4.1'
|
6
|
+
mod 'puppet/gitlab', '4.0.1'
|
7
|
+
mod 'puppetlabs/inifile', '2.2.0'
|
8
|
+
mod 'puppetlabs/stdlib', '4.24.0'
|
9
|
+
mod 'puppetlabs/concat', '4.0.0'
|
10
|
+
mod 'puppetlabs/ntp', '6.4.1'
|
11
|
+
mod 'theforeman/puppet', '12.0.1'
|
12
|
+
|
13
|
+
# introduced for tomcat module collaboration with uws
|
14
|
+
mod 'puppet-archive', '3.1.1'
|
15
|
+
|
16
|
+
mod 'gitlab',
|
17
|
+
git: 'https://github.com/vshn/puppet-gitlab',
|
18
|
+
ref: '00397b86dfb3487d9df768cbd3698d362132b5bf' # master
|
19
|
+
|
20
|
+
mod 'r10k',
|
21
|
+
git: 'https://github.com/acidprime/r10k',
|
22
|
+
tag: 'v3.1.1'
|
23
|
+
|
24
|
+
mod 'gms',
|
25
|
+
git: 'https://github.com/npwalker/abrader-gms',
|
26
|
+
branch: 'gitlab_disable_ssl_verify_support'
|
27
|
+
|
28
|
+
mod 'pltraining-rbac',
|
29
|
+
git: 'https://github.com/puppetlabs/pltraining-rbac',
|
30
|
+
ref: '2f60e1789a721ce83f8df061e13f8bf81cd4e4ce'
|
31
|
+
|
32
|
+
mod 'puppet-acl',
|
33
|
+
git: 'https://github.com/dobbymoodge/puppet-acl.git',
|
34
|
+
branch: 'master'
|
35
|
+
|
36
|
+
mod 'deploy',
|
37
|
+
git: 'https://github.com/cudgel/deploy.git',
|
38
|
+
branch: 'master'
|
39
|
+
|
40
|
+
mod 'dotfiles',
|
41
|
+
git: 'https://github.com/cudgel/puppet-dotfiles.git',
|
42
|
+
branch: 'master'
|
43
|
+
|
44
|
+
mod 'splunk',
|
45
|
+
git: 'https://github.com/cudgel/splunk.git',
|
46
|
+
branch: 'dev'
|
47
|
+
|
48
|
+
mod 'puppet',
|
49
|
+
git: 'https://github.com/voxpupuli/puppet-module.git',
|
50
|
+
branch: 'master'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'ra10ke/duplicates'
|
5
|
+
RSpec::Mocks.configuration.allow_message_expectations_on_nil = true
|
6
|
+
|
7
|
+
RSpec.describe 'Ra10ke::Duplicates::Verification' do
|
8
|
+
let(:instance) do
|
9
|
+
Ra10ke::Duplicates::Verification.new(puppetfile)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:puppetfile) do
|
13
|
+
File.join(fixtures_dir, 'Puppetfile_with_duplicates')
|
14
|
+
end
|
15
|
+
|
16
|
+
it '#new' do
|
17
|
+
expect(instance).to be_a Ra10ke::Duplicates::Verification
|
18
|
+
end
|
19
|
+
|
20
|
+
it '#duplicates is a hash' do
|
21
|
+
expect(instance.duplicates).to be_a Hash
|
22
|
+
end
|
23
|
+
|
24
|
+
it '#duplicates is a hash with arrays' do
|
25
|
+
expect(instance.duplicates.first.last).to be_a Array
|
26
|
+
end
|
27
|
+
|
28
|
+
it '#duplicates is a hash with arrays containing modules' do
|
29
|
+
expect(instance.duplicates.first.last.first).to be_a Ra10ke::Duplicates::Verification::Module
|
30
|
+
end
|
31
|
+
end
|
@@ -43,7 +43,7 @@ RSpec.describe 'Ra10ke::PuppetfileParser' do
|
|
43
43
|
{:branch=>"master", :git=>"https://github.com/cudgel/puppet-dotfiles.git"},
|
44
44
|
:name=>"dotfiles",
|
45
45
|
:namespace=>nil},
|
46
|
-
{:args=>{:branch=>"
|
46
|
+
{:args=>{:branch=>"dev", :git=>"https://github.com/cudgel/splunk.git"},
|
47
47
|
:name=>"splunk",
|
48
48
|
:namespace=>nil},
|
49
49
|
{:args=>{:branch=>"master", :git=>"https://github.com/voxpupuli/puppet-module.git"},
|
@@ -86,7 +86,7 @@ RSpec.describe 'Ra10ke::PuppetfileParser' do
|
|
86
86
|
{:branch=>"master", :git=>"https://github.com/cudgel/puppet-dotfiles.git"},
|
87
87
|
:name=>"dotfiles",
|
88
88
|
:namespace=>nil},
|
89
|
-
{:args=>{:branch=>"
|
89
|
+
{:args=>{:branch=>"dev", :git=>"https://github.com/cudgel/splunk.git"},
|
90
90
|
:name=>"splunk",
|
91
91
|
:namespace=>nil},
|
92
92
|
{:args=>{:branch=>"master", :git=>"https://github.com/voxpupuli/puppet-module.git"},
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ra10ke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Theo Chatzimichos
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -85,14 +85,14 @@ dependencies:
|
|
85
85
|
name: semverse
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - "
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '2.0'
|
91
91
|
type: :runtime
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - "
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '2.0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- Rakefile
|
141
141
|
- lib/ra10ke.rb
|
142
142
|
- lib/ra10ke/dependencies.rb
|
143
|
+
- lib/ra10ke/duplicates.rb
|
143
144
|
- lib/ra10ke/install.rb
|
144
145
|
- lib/ra10ke/monkey_patches.rb
|
145
146
|
- lib/ra10ke/puppetfile_parser.rb
|
@@ -151,7 +152,9 @@ files:
|
|
151
152
|
- spec/fixtures/Puppetfile
|
152
153
|
- spec/fixtures/Puppetfile_test
|
153
154
|
- spec/fixtures/Puppetfile_with_bad_refs
|
155
|
+
- spec/fixtures/Puppetfile_with_duplicates
|
154
156
|
- spec/fixtures/reflist.txt
|
157
|
+
- spec/ra10ke/duplicates_spec.rb
|
155
158
|
- spec/ra10ke/puppetfile_parser_spec.rb
|
156
159
|
- spec/ra10ke/validate_spec.rb
|
157
160
|
- spec/ra10ke_spec.rb
|