puppetfile-resolver 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/puppetfile-resolver/cache/persistent.rb +1 -1
- data/lib/puppetfile-resolver/models/module_dependency.rb +1 -3
- data/lib/puppetfile-resolver/models/module_specification.rb +1 -5
- data/lib/puppetfile-resolver/puppetfile/document.rb +2 -6
- data/lib/puppetfile-resolver/puppetfile/git_module.rb +1 -4
- data/lib/puppetfile-resolver/puppetfile/parser/r10k_eval/dsl.rb +1 -1
- data/lib/puppetfile-resolver/puppetfile/parser/r10k_eval/module/local.rb +1 -2
- data/lib/puppetfile-resolver/puppetfile/parser/r10k_eval.rb +6 -6
- data/lib/puppetfile-resolver/puppetfile/validation_errors.rb +2 -4
- data/lib/puppetfile-resolver/resolver.rb +1 -2
- data/lib/puppetfile-resolver/spec_searchers/configuration.rb +1 -3
- data/lib/puppetfile-resolver/spec_searchers/git/gclone.rb +0 -1
- data/lib/puppetfile-resolver/spec_searchers/git/github.rb +3 -3
- data/lib/puppetfile-resolver/spec_searchers/git/gitlab.rb +3 -3
- data/lib/puppetfile-resolver/util.rb +1 -1
- data/lib/puppetfile-resolver/version.rb +1 -1
- data/puppetfile-cli.rb +2 -2
- data/spec/spec_helper.rb +26 -0
- metadata +25 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7673218a6f7c10c7e28ae17d8bc7ebbe7da5d820ae31c4aa10781710aa26c12
|
4
|
+
data.tar.gz: a5bdc145cd5bc3233f031617e281d9a0f6927a80057a1a1ea32300cef8ea1004
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8aaeacdba844e37b2090585eaa922352520384271703f06007ce6f658e06e2cb44132ad730d1663060f28376f5018086fcff4b9a6a93363b8e3486c03929ed48
|
7
|
+
data.tar.gz: 7c7a6804f9bb7fa4404a50d087f5b931db6cbf31b021cc4bf3c2124489b9b738e65f61887352f0fb531267dfd81a3f54514e67f8e35f39f8457d6676014f984b
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
[![
|
2
|
-
[![Gem Version](https://
|
1
|
+
[![ci](https://github.com/puppetlabs/puppetfile-resolver/actions/workflows/ci.yml/badge.svg)](https://github.com/puppetlabs/puppetfile-resolver/actions/workflows/ci.yml)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/puppetfile-resolver.svg)](https://badge.fury.io/rb/puppetfile-resolver)
|
3
3
|
|
4
4
|
# Puppetfile Resolver
|
5
5
|
|
@@ -7,11 +7,7 @@ require 'puppetfile-resolver/puppetfile'
|
|
7
7
|
module PuppetfileResolver
|
8
8
|
module Models
|
9
9
|
class ModuleSpecification
|
10
|
-
attr_accessor :name
|
11
|
-
attr_accessor :owner
|
12
|
-
attr_accessor :version
|
13
|
-
attr_accessor :origin # Same as R10K module :type
|
14
|
-
attr_accessor :resolver_flags
|
10
|
+
attr_accessor :name, :owner, :version, :origin, :resolver_flags # origin attr same as R10K module :type
|
15
11
|
|
16
12
|
def initialize(options = {})
|
17
13
|
require 'semantic_puppet'
|
@@ -5,16 +5,12 @@ require 'puppetfile-resolver/puppetfile/invalid_module'
|
|
5
5
|
module PuppetfileResolver
|
6
6
|
module Puppetfile
|
7
7
|
class DocumentLocation
|
8
|
-
attr_accessor :start_line # Base 0
|
9
|
-
attr_accessor :start_char # Base 0
|
10
|
-
attr_accessor :end_line # Base 0
|
11
|
-
attr_accessor :end_char # Base 0
|
8
|
+
attr_accessor :start_line, :start_char, :end_line, :end_char # Base 0 # Base 0 # Base 0 # Base 0
|
12
9
|
end
|
13
10
|
|
14
11
|
class Document
|
15
|
-
attr_accessor :forge_uri
|
12
|
+
attr_accessor :forge_uri, :content
|
16
13
|
attr_reader :modules
|
17
|
-
attr_accessor :content
|
18
14
|
|
19
15
|
def initialize(puppetfile_content)
|
20
16
|
@content = puppetfile_content
|
@@ -5,10 +5,7 @@ require 'puppetfile-resolver/puppetfile/base_module'
|
|
5
5
|
module PuppetfileResolver
|
6
6
|
module Puppetfile
|
7
7
|
class GitModule < BaseModule
|
8
|
-
attr_accessor :remote
|
9
|
-
attr_accessor :ref
|
10
|
-
attr_accessor :commit
|
11
|
-
attr_accessor :tag
|
8
|
+
attr_accessor :remote, :ref, :commit, :tag
|
12
9
|
|
13
10
|
def initialize(title)
|
14
11
|
super
|
@@ -41,7 +41,7 @@ module PuppetfileResolver
|
|
41
41
|
|
42
42
|
def find_load_line_number
|
43
43
|
loc = Kernel.caller_locations
|
44
|
-
.find { |call_loc| call_loc.
|
44
|
+
.find { |call_loc| call_loc.path == ::PuppetfileResolver::Puppetfile::Parser::R10KEval::PUPPETFILE_MONIKER }
|
45
45
|
loc.nil? ? 0 : loc.lineno - 1 # Line numbers from ruby are base 1
|
46
46
|
end
|
47
47
|
end
|
@@ -21,7 +21,7 @@ module PuppetfileResolver
|
|
21
21
|
rescue StandardError, LoadError => e
|
22
22
|
# Find the originating error from within the puppetfile
|
23
23
|
loc = e.backtrace_locations
|
24
|
-
.select { |item| item.
|
24
|
+
.select { |item| item.path == PUPPETFILE_MONIKER }
|
25
25
|
.first
|
26
26
|
start_line_number = loc.nil? ? 0 : loc.lineno - 1 # Line numbers from ruby are base 1
|
27
27
|
end_line_number = loc.nil? ? puppetfile_contents.lines.count - 1 : loc.lineno - 1 # Line numbers from ruby are base 1
|
@@ -65,19 +65,19 @@ module PuppetfileResolver
|
|
65
65
|
def self.post_process_flags!(document)
|
66
66
|
flag_ranges = {}
|
67
67
|
document.content.lines.each_with_index do |line, index|
|
68
|
-
if (matches = line.match(%r{^\s*# resolver:disable ([A-Za-z
|
68
|
+
if (matches = line.match(%r{^\s*# resolver:disable ([A-Za-z/,]+)(?:\s|$)}))
|
69
69
|
flags_from_line(matches[1]).each do |flag|
|
70
70
|
# Start a flag range if there isn't already one going
|
71
71
|
next unless flag_ranges[flag].nil?
|
72
72
|
flag_ranges[flag] = index
|
73
73
|
end
|
74
|
-
elsif (matches = line.match(%r{# resolver:disable ([A-Za-z
|
74
|
+
elsif (matches = line.match(%r{# resolver:disable ([A-Za-z/,]+)(?:\s|$)}))
|
75
75
|
flags_from_line(matches[1]).each do |flag|
|
76
76
|
# Assert the flag if we're not already within a range
|
77
77
|
next unless flag_ranges[flag].nil?
|
78
78
|
assert_resolver_flag(document, flag, index, index)
|
79
79
|
end
|
80
|
-
elsif (matches = line.match(%r{^\s*# resolver:enable ([A-Za-z
|
80
|
+
elsif (matches = line.match(%r{^\s*# resolver:enable ([A-Za-z/,]+)(?:\s|$)}))
|
81
81
|
flags_from_line(matches[1]).each do |flag|
|
82
82
|
# End a flag range if there isn't already one going
|
83
83
|
next if flag_ranges[flag].nil?
|
@@ -122,8 +122,8 @@ module PuppetfileResolver
|
|
122
122
|
next if mod.location.start_line.nil? || mod.location.end_line.nil?
|
123
123
|
|
124
124
|
# If the module doesn't span the range we're looking for (from_line --> to_line) ignore it
|
125
|
-
next unless mod.location.start_line >= from_line && mod.location.start_line <= to_line ||
|
126
|
-
mod.location.end_line >= from_line && mod.location.end_line <= to_line
|
125
|
+
next unless (mod.location.start_line >= from_line && mod.location.start_line <= to_line) ||
|
126
|
+
(mod.location.end_line >= from_line && mod.location.end_line <= to_line)
|
127
127
|
mod.resolver_flags << flag unless mod.resolver_flags.include?(flag)
|
128
128
|
end
|
129
129
|
nil
|
@@ -3,8 +3,7 @@
|
|
3
3
|
module PuppetfileResolver
|
4
4
|
module Puppetfile
|
5
5
|
class DocumentValidationErrorBase
|
6
|
-
attr_accessor :message
|
7
|
-
attr_accessor :puppet_module
|
6
|
+
attr_accessor :message, :puppet_module
|
8
7
|
|
9
8
|
def initialize(message, puppet_module)
|
10
9
|
@message = message
|
@@ -79,8 +78,7 @@ module PuppetfileResolver
|
|
79
78
|
# Resolution Validation Error classes for validating
|
80
79
|
# a valid Puppetfile against a dependency resolution
|
81
80
|
class DocumentResolutionErrorBase < DocumentValidationErrorBase
|
82
|
-
attr_accessor :puppet_module
|
83
|
-
attr_accessor :module_specification
|
81
|
+
attr_accessor :puppet_module, :module_specification
|
84
82
|
|
85
83
|
def initialize(message, puppet_module, module_specification)
|
86
84
|
super(message, puppet_module)
|
@@ -7,8 +7,7 @@ require 'puppetfile-resolver/models'
|
|
7
7
|
|
8
8
|
module PuppetfileResolver
|
9
9
|
class Resolver
|
10
|
-
attr_reader :puppetfile
|
11
|
-
attr_reader :dependencies_to_resolve
|
10
|
+
attr_reader :puppetfile, :dependencies_to_resolve
|
12
11
|
|
13
12
|
def initialize(puppetfile_document, puppet_version = nil)
|
14
13
|
@puppetfile = puppetfile_document
|
@@ -7,9 +7,7 @@ require 'puppetfile-resolver/spec_searchers/local_configuration'
|
|
7
7
|
module PuppetfileResolver
|
8
8
|
module SpecSearchers
|
9
9
|
class Configuration
|
10
|
-
attr_reader :local
|
11
|
-
attr_reader :forge
|
12
|
-
attr_reader :git
|
10
|
+
attr_reader :local, :forge, :git
|
13
11
|
|
14
12
|
def initialize
|
15
13
|
@local = LocalConfiguration.new
|
@@ -19,11 +19,11 @@ module PuppetfileResolver
|
|
19
19
|
end
|
20
20
|
return nil if repo_url.nil?
|
21
21
|
|
22
|
-
metadata_url =
|
22
|
+
metadata_url = "https://raw.githubusercontent.com/#{repo_url}/"
|
23
23
|
if puppetfile_module.ref
|
24
|
-
metadata_url += puppetfile_module.ref
|
24
|
+
metadata_url += "#{puppetfile_module.ref}/"
|
25
25
|
elsif puppetfile_module.tag
|
26
|
-
metadata_url += puppetfile_module.tag
|
26
|
+
metadata_url += "#{puppetfile_module.tag}/"
|
27
27
|
else
|
28
28
|
# Default to master. Should it raise?
|
29
29
|
metadata_url += 'master/'
|
@@ -21,11 +21,11 @@ module PuppetfileResolver
|
|
21
21
|
|
22
22
|
# Example URL
|
23
23
|
# https://gitlab.com/simp/pupmod-simp-crypto_policy/-/raw/0.1.4/metadata.json
|
24
|
-
metadata_url =
|
24
|
+
metadata_url = "https://gitlab.com/#{repo_url}/-/raw/"
|
25
25
|
if puppetfile_module.ref
|
26
|
-
metadata_url += puppetfile_module.ref
|
26
|
+
metadata_url += "#{puppetfile_module.ref}/"
|
27
27
|
elsif puppetfile_module.tag
|
28
|
-
metadata_url += puppetfile_module.tag
|
28
|
+
metadata_url += "#{puppetfile_module.tag}/"
|
29
29
|
else
|
30
30
|
# Default to master. Should it raise?
|
31
31
|
metadata_url += 'master/'
|
@@ -29,7 +29,7 @@ module PuppetfileResolver
|
|
29
29
|
def self.net_http_get(uri, proxy = nil)
|
30
30
|
uri = URI.parse(uri) unless uri.is_a?(URI)
|
31
31
|
|
32
|
-
http_options = { :use_ssl => uri.
|
32
|
+
http_options = { :use_ssl => uri.instance_of?(URI::HTTPS) }
|
33
33
|
# Because on Windows Ruby doesn't use the Windows certificate store which has up-to date
|
34
34
|
# CA certs, we can't depend on someone setting the environment variable correctly. So use our
|
35
35
|
# static CA PEM file if SSL_CERT_FILE is not set.
|
data/puppetfile-cli.rb
CHANGED
@@ -72,9 +72,9 @@ else
|
|
72
72
|
end
|
73
73
|
|
74
74
|
# Parse the Puppetfile into an object model
|
75
|
-
content = File.
|
75
|
+
content = File.binread(options[:path])
|
76
76
|
require 'puppetfile-resolver/puppetfile/parser/r10k_eval'
|
77
|
-
puppetfile =
|
77
|
+
puppetfile = PuppetfileResolver::Puppetfile::Parser::R10KEval.parse(content)
|
78
78
|
|
79
79
|
# Make sure the Puppetfile is valid
|
80
80
|
unless puppetfile.valid?
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
if ENV['COVERAGE'] == 'yes'
|
4
|
+
begin
|
5
|
+
require 'simplecov'
|
6
|
+
require 'simplecov-console'
|
7
|
+
|
8
|
+
SimpleCov.formatters = [
|
9
|
+
SimpleCov::Formatter::HTMLFormatter,
|
10
|
+
SimpleCov::Formatter::Console,
|
11
|
+
]
|
12
|
+
|
13
|
+
SimpleCov.start do
|
14
|
+
track_files 'lib/**/*.rb'
|
15
|
+
add_filter '/spec'
|
16
|
+
add_filter 'lib/puppetfile-resolver/version.rb'
|
17
|
+
|
18
|
+
add_filter '/docs'
|
19
|
+
|
20
|
+
# do not track vendored files
|
21
|
+
add_filter '/vendor'
|
22
|
+
add_filter '/.vendor'
|
23
|
+
end
|
24
|
+
rescue LoadError
|
25
|
+
raise 'Add the simplecov & simplecov-console gems to Gemfile to enable this task'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
3
29
|
root = File.join(__dir__,'..',)
|
4
30
|
# Add the language server into the load path
|
5
31
|
$LOAD_PATH.unshift(File.join(root,'lib'))
|
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.6.
|
4
|
+
version: 0.6.3
|
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: 2024-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: molinillo
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: webrick
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.8'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.8'
|
41
55
|
description: Resolves the Puppet Modules in a Puppetfile with a full dependency graph,
|
42
56
|
including Puppet version checks.
|
43
57
|
email:
|
@@ -126,19 +140,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
140
|
- !ruby/object:Gem::Version
|
127
141
|
version: '0'
|
128
142
|
requirements: []
|
129
|
-
rubygems_version: 3.
|
143
|
+
rubygems_version: 3.1.6
|
130
144
|
signing_key:
|
131
145
|
specification_version: 4
|
132
146
|
summary: Dependency resolver for Puppetfiles
|
133
147
|
test_files:
|
134
|
-
- spec/
|
148
|
+
- spec/fixtures/proxy.rb
|
149
|
+
- spec/fixtures/modulepath/test_module/README.md
|
150
|
+
- spec/fixtures/modulepath/test_module/metadata.json
|
151
|
+
- spec/spec_helper.rb
|
152
|
+
- spec/integration/deprecation_spec.rb
|
153
|
+
- spec/integration/kitchensink_spec.rb
|
154
|
+
- spec/integration/proxy_spec.rb
|
135
155
|
- spec/unit/puppetfile-resolver/puppetfile/document_spec.rb
|
136
156
|
- spec/unit/puppetfile-resolver/puppetfile/parser/r10k_eval_spec.rb
|
157
|
+
- spec/unit/puppetfile-resolver/spec_searchers/git/gclone_spec.rb
|
137
158
|
- spec/unit/puppetfile-resolver/resolver_spec.rb
|
138
|
-
- spec/integration/proxy_spec.rb
|
139
|
-
- spec/integration/kitchensink_spec.rb
|
140
|
-
- spec/integration/deprecation_spec.rb
|
141
|
-
- spec/spec_helper.rb
|
142
|
-
- spec/fixtures/modulepath/test_module/metadata.json
|
143
|
-
- spec/fixtures/modulepath/test_module/README.md
|
144
|
-
- spec/fixtures/proxy.rb
|