puppetfile-resolver 0.4.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/puppetfile-resolver/data/ruby_ca_certs.pem +640 -740
- data/lib/puppetfile-resolver/resolution_provider.rb +15 -8
- data/lib/puppetfile-resolver/resolver.rb +2 -1
- data/lib/puppetfile-resolver/spec_searchers/configuration.rb +21 -0
- data/lib/puppetfile-resolver/spec_searchers/forge.rb +17 -19
- data/lib/puppetfile-resolver/spec_searchers/forge_configuration.rb +17 -0
- data/lib/puppetfile-resolver/spec_searchers/git/gclone.rb +82 -0
- data/lib/puppetfile-resolver/spec_searchers/git/github.rb +53 -0
- data/lib/puppetfile-resolver/spec_searchers/git/gitlab.rb +55 -0
- data/lib/puppetfile-resolver/spec_searchers/git.rb +16 -34
- data/lib/puppetfile-resolver/spec_searchers/git_configuration.rb +9 -0
- data/lib/puppetfile-resolver/spec_searchers/local.rb +3 -2
- data/lib/puppetfile-resolver/spec_searchers/local_configuration.rb +13 -0
- data/lib/puppetfile-resolver/util.rb +43 -0
- data/lib/puppetfile-resolver/version.rb +1 -1
- data/puppetfile-cli.rb +14 -1
- data/spec/fixtures/modulepath/test_module/README.md +1 -0
- data/spec/fixtures/modulepath/test_module/metadata.json +9 -0
- data/spec/fixtures/proxy.rb +9 -0
- data/spec/integration/deprecation_spec.rb +32 -0
- data/spec/integration/kitchensink_spec.rb +49 -0
- data/spec/integration/proxy_spec.rb +91 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/puppetfile-resolver/resolver_spec.rb +1 -1
- data/spec/unit/puppetfile-resolver/spec_searchers/git/gclone_spec.rb +49 -0
- metadata +28 -7
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'puppetfile-resolver/resolver'
|
4
|
+
require 'puppetfile-resolver/puppetfile'
|
5
|
+
|
6
|
+
describe 'KitchenSink Tests' do
|
7
|
+
it 'should resolve a complete Puppetfile' do
|
8
|
+
content = <<-PUPFILE
|
9
|
+
forge 'https://forge.puppet.com'
|
10
|
+
|
11
|
+
mod 'powershell',
|
12
|
+
:git => 'https://github.com/puppetlabs/puppetlabs-powershell',
|
13
|
+
:tag => 'v4.0.0'
|
14
|
+
|
15
|
+
mod 'simpkv',
|
16
|
+
:git => 'https://gitlab.com/simp/pupmod-simp-simpkv.git',
|
17
|
+
:tag => '0.7.1'
|
18
|
+
|
19
|
+
mod 'puppetlabs/stdlib', '6.3.0'
|
20
|
+
|
21
|
+
# Local module path module
|
22
|
+
mod 'testfixture/test_module', :latest
|
23
|
+
|
24
|
+
PUPFILE
|
25
|
+
|
26
|
+
puppetfile = ::PuppetfileResolver::Puppetfile::Parser::R10KEval.parse(content)
|
27
|
+
|
28
|
+
config = PuppetfileResolver::SpecSearchers::Configuration.new
|
29
|
+
config.local.puppet_module_paths = [File.join(FIXTURES_DIR, 'modulepath')]
|
30
|
+
|
31
|
+
resolver = PuppetfileResolver::Resolver.new(puppetfile)
|
32
|
+
result = resolver.resolve({
|
33
|
+
allow_missing_modules: false,
|
34
|
+
spec_searcher_configuration: config,
|
35
|
+
})
|
36
|
+
|
37
|
+
expect(result.specifications).to include('powershell')
|
38
|
+
expect(result.specifications['powershell'].version.to_s).to eq('4.0.0')
|
39
|
+
|
40
|
+
expect(result.specifications).to include('simpkv')
|
41
|
+
expect(result.specifications['simpkv'].version.to_s).to eq('0.7.1')
|
42
|
+
|
43
|
+
expect(result.specifications).to include('stdlib')
|
44
|
+
expect(result.specifications['stdlib'].version.to_s).to eq('6.3.0')
|
45
|
+
|
46
|
+
expect(result.specifications).to include('test_module')
|
47
|
+
expect(result.specifications['test_module'].version.to_s).to eq('0.1.0')
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'open3'
|
3
|
+
require 'puppetfile-resolver/resolver'
|
4
|
+
require 'puppetfile-resolver/puppetfile'
|
5
|
+
|
6
|
+
describe 'Proxy Tests' do
|
7
|
+
let(:content) do <<-PUPFILE
|
8
|
+
forge 'https://forge.puppet.com'
|
9
|
+
|
10
|
+
mod 'powershell',
|
11
|
+
:git => 'https://github.com/puppetlabs/puppetlabs-powershell',
|
12
|
+
:tag => 'v4.0.0'
|
13
|
+
|
14
|
+
mod 'puppetlabs/stdlib', '6.3.0'
|
15
|
+
PUPFILE
|
16
|
+
end
|
17
|
+
let(:puppetfile) { ::PuppetfileResolver::Puppetfile::Parser::R10KEval.parse(content) }
|
18
|
+
let(:resolver_config) do
|
19
|
+
PuppetfileResolver::SpecSearchers::Configuration.new.tap do |obj|
|
20
|
+
obj.git.proxy = 'http://localhost:32768'
|
21
|
+
obj.forge.proxy = 'http://localhost:32768'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with an invalid proxy server' do
|
26
|
+
it 'should not resolve a complete Puppetfile' do
|
27
|
+
resolver = PuppetfileResolver::Resolver.new(puppetfile)
|
28
|
+
result = resolver.resolve({
|
29
|
+
allow_missing_modules: true,
|
30
|
+
spec_searcher_configuration: resolver_config,
|
31
|
+
})
|
32
|
+
|
33
|
+
expect(result.specifications).to include('powershell')
|
34
|
+
expect(result.specifications['powershell']).to be_a(PuppetfileResolver::Models::MissingModuleSpecification)
|
35
|
+
|
36
|
+
expect(result.specifications).to include('stdlib')
|
37
|
+
expect(result.specifications['stdlib']).to be_a(PuppetfileResolver::Models::MissingModuleSpecification)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with a valid proxy server' do
|
42
|
+
def start_proxy_server(start_options = ['--timeout=5'])
|
43
|
+
cmd = "ruby \"#{File.join(FIXTURES_DIR, 'proxy.rb')}\" 32768"
|
44
|
+
|
45
|
+
stdin, stdout, stderr, wait_thr = Open3.popen3(cmd)
|
46
|
+
# Wait for the Proxy server to indicate it started
|
47
|
+
line = nil
|
48
|
+
begin
|
49
|
+
line = stderr.readline
|
50
|
+
end until line =~ /#start/
|
51
|
+
stdout.close
|
52
|
+
stdin.close
|
53
|
+
[wait_thr, stderr]
|
54
|
+
end
|
55
|
+
|
56
|
+
before(:each) do
|
57
|
+
@server_thr, @server_pipe = start_proxy_server
|
58
|
+
end
|
59
|
+
|
60
|
+
after(:each) do
|
61
|
+
begin
|
62
|
+
Process.kill("KILL", @server_thr[:pid])
|
63
|
+
Process.wait(@server_thr[:pid])
|
64
|
+
rescue
|
65
|
+
# The server process may not exist and checking in a cross platform way in ruby is difficult
|
66
|
+
# Instead just swallow any errors
|
67
|
+
end
|
68
|
+
|
69
|
+
begin
|
70
|
+
@server_pipe.close
|
71
|
+
rescue
|
72
|
+
# The server process may not exist and checking in a cross platform way in ruby is difficult
|
73
|
+
# Instead just swallow any errors
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should resolve a complete Puppetfile' do
|
78
|
+
resolver = PuppetfileResolver::Resolver.new(puppetfile)
|
79
|
+
result = resolver.resolve({
|
80
|
+
allow_missing_modules: false,
|
81
|
+
spec_searcher_configuration: resolver_config,
|
82
|
+
})
|
83
|
+
|
84
|
+
expect(result.specifications).to include('powershell')
|
85
|
+
expect(result.specifications['powershell'].version.to_s).to eq('4.0.0')
|
86
|
+
|
87
|
+
expect(result.specifications).to include('stdlib')
|
88
|
+
expect(result.specifications['stdlib'].version.to_s).to eq('6.3.0')
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,6 +4,8 @@ root = File.join(__dir__,'..',)
|
|
4
4
|
# Add the language server into the load path
|
5
5
|
$LOAD_PATH.unshift(File.join(root,'lib'))
|
6
6
|
|
7
|
+
FIXTURES_DIR = File.join(__dir__,'fixtures')
|
8
|
+
|
7
9
|
# A cache which we can preload for the purposes of testing, mimicing
|
8
10
|
# Local modules
|
9
11
|
require 'puppetfile-resolver/cache/base'
|
@@ -7,7 +7,7 @@ describe PuppetfileResolver::Resolver do
|
|
7
7
|
let(:puppet_version) { nil }
|
8
8
|
let(:subject) { PuppetfileResolver::Resolver.new(puppetfile_document, puppet_version) }
|
9
9
|
let(:cache) { MockLocalModuleCache.new }
|
10
|
-
let(:default_resolve_options) { { cache: cache
|
10
|
+
let(:default_resolve_options) { { cache: cache } }
|
11
11
|
let(:resolve_options) { default_resolve_options }
|
12
12
|
|
13
13
|
RSpec.shared_examples 'a resolver flag' do |flag|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'puppetfile-resolver/spec_searchers/git/gclone'
|
3
|
+
require 'puppetfile-resolver/spec_searchers/git_configuration'
|
4
|
+
require 'logger'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
describe PuppetfileResolver::SpecSearchers::Git::GClone do
|
8
|
+
PuppetfileModule = Struct.new(:remote, :ref, :branch, :commit, :tag, keyword_init: true)
|
9
|
+
config = PuppetfileResolver::SpecSearchers::GitConfiguration.new
|
10
|
+
|
11
|
+
let(:url) do
|
12
|
+
'https://github.com/puppetlabs/puppetlabs-powershell'
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:puppetfile_module) do
|
16
|
+
PuppetfileModule.new(remote: url)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
context 'valid url' do
|
21
|
+
it 'reads metadata' do
|
22
|
+
content = subject.metadata(puppetfile_module, Logger.new(STDERR), config)
|
23
|
+
expect(JSON.parse(content)['name']).to eq('puppetlabs-powershell')
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'with ref' do
|
27
|
+
|
28
|
+
let(:puppetfile_module) do
|
29
|
+
PuppetfileModule.new(remote: url, ref: '2.1.2')
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'reads metadata' do
|
33
|
+
content = subject.metadata(puppetfile_module, Logger.new(STDERR), config)
|
34
|
+
expect(JSON.parse(content)['name']).to eq('puppetlabs-powershell')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'invalid url' do
|
40
|
+
let(:url) do
|
41
|
+
'https://user:password@github.com/puppetlabs/puppetlabs-powershellbad'
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'throws exception' do
|
45
|
+
expect{subject.metadata(puppetfile_module, Logger.new(STDERR), config)}
|
46
|
+
.to raise_exception(RuntimeError)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppetfile-resolver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Glenn Sarti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: molinillo
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
41
|
description: Resolves the Puppet Modules in a Puppetfile with a full dependency graph,
|
42
|
-
including Puppet version
|
42
|
+
including Puppet version checks.
|
43
43
|
email:
|
44
44
|
- glennsarti@users.noreply.github.com
|
45
45
|
executables: []
|
@@ -81,18 +81,32 @@ files:
|
|
81
81
|
- lib/puppetfile-resolver/resolution_result.rb
|
82
82
|
- lib/puppetfile-resolver/resolver.rb
|
83
83
|
- lib/puppetfile-resolver/spec_searchers/common.rb
|
84
|
+
- lib/puppetfile-resolver/spec_searchers/configuration.rb
|
84
85
|
- lib/puppetfile-resolver/spec_searchers/forge.rb
|
86
|
+
- lib/puppetfile-resolver/spec_searchers/forge_configuration.rb
|
85
87
|
- lib/puppetfile-resolver/spec_searchers/git.rb
|
88
|
+
- lib/puppetfile-resolver/spec_searchers/git/gclone.rb
|
89
|
+
- lib/puppetfile-resolver/spec_searchers/git/github.rb
|
90
|
+
- lib/puppetfile-resolver/spec_searchers/git/gitlab.rb
|
91
|
+
- lib/puppetfile-resolver/spec_searchers/git_configuration.rb
|
86
92
|
- lib/puppetfile-resolver/spec_searchers/local.rb
|
93
|
+
- lib/puppetfile-resolver/spec_searchers/local_configuration.rb
|
87
94
|
- lib/puppetfile-resolver/ui/debug_ui.rb
|
88
95
|
- lib/puppetfile-resolver/ui/null_ui.rb
|
89
96
|
- lib/puppetfile-resolver/util.rb
|
90
97
|
- lib/puppetfile-resolver/version.rb
|
91
98
|
- puppetfile-cli.rb
|
99
|
+
- spec/fixtures/modulepath/test_module/README.md
|
100
|
+
- spec/fixtures/modulepath/test_module/metadata.json
|
101
|
+
- spec/fixtures/proxy.rb
|
102
|
+
- spec/integration/deprecation_spec.rb
|
103
|
+
- spec/integration/kitchensink_spec.rb
|
104
|
+
- spec/integration/proxy_spec.rb
|
92
105
|
- spec/spec_helper.rb
|
93
106
|
- spec/unit/puppetfile-resolver/puppetfile/document_spec.rb
|
94
107
|
- spec/unit/puppetfile-resolver/puppetfile/parser/r10k_eval_spec.rb
|
95
108
|
- spec/unit/puppetfile-resolver/resolver_spec.rb
|
109
|
+
- spec/unit/puppetfile-resolver/spec_searchers/git/gclone_spec.rb
|
96
110
|
homepage: https://glennsarti.github.io/puppetfile-resolver/
|
97
111
|
licenses:
|
98
112
|
- Apache-2.0
|
@@ -105,19 +119,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
119
|
requirements:
|
106
120
|
- - ">="
|
107
121
|
- !ruby/object:Gem::Version
|
108
|
-
version: 2.
|
122
|
+
version: 2.5.3
|
109
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
124
|
requirements:
|
111
125
|
- - ">="
|
112
126
|
- !ruby/object:Gem::Version
|
113
127
|
version: '0'
|
114
128
|
requirements: []
|
115
|
-
rubygems_version: 3.
|
129
|
+
rubygems_version: 3.0.3
|
116
130
|
signing_key:
|
117
131
|
specification_version: 4
|
118
132
|
summary: Dependency resolver for Puppetfiles
|
119
133
|
test_files:
|
120
|
-
- spec/
|
121
|
-
- spec/
|
134
|
+
- spec/fixtures/proxy.rb
|
135
|
+
- spec/fixtures/modulepath/test_module/README.md
|
136
|
+
- spec/fixtures/modulepath/test_module/metadata.json
|
122
137
|
- spec/unit/puppetfile-resolver/puppetfile/parser/r10k_eval_spec.rb
|
138
|
+
- spec/unit/puppetfile-resolver/puppetfile/document_spec.rb
|
123
139
|
- spec/unit/puppetfile-resolver/resolver_spec.rb
|
140
|
+
- spec/unit/puppetfile-resolver/spec_searchers/git/gclone_spec.rb
|
141
|
+
- spec/spec_helper.rb
|
142
|
+
- spec/integration/proxy_spec.rb
|
143
|
+
- spec/integration/kitchensink_spec.rb
|
144
|
+
- spec/integration/deprecation_spec.rb
|