puppetfile-resolver 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7369652a185b5b8cbd2cbcbf4c0a728303a03779e8c5fc363430855de1f90f31
4
- data.tar.gz: 7b9457a73ad065fed6edefd3c756ed4b90a1c660548a88ba2b1411d07668e8fd
3
+ metadata.gz: b1199057b00e6f612fd02343cc707cc1e6a4dba3ab20a6956b270c92387a66c7
4
+ data.tar.gz: d5e706548dc0a8a31fa8573ef96fd130c84307a9a3ca74e97a9966612c731baf
5
5
  SHA512:
6
- metadata.gz: c7af088bf31a4c96bd1fe3cf2a3853297d079c2fdd15d7c49a4aeb3f1e1290c88c58298ab7a63c326420e67fc74c86051f6858ed98b9337ddcf0e73a25603c15
7
- data.tar.gz: 0d32efc05cd6a1ffcb6825ce4a78fd919aa8705a5b45cd930912ac723d9271988e912a2985c91b4603a2610be4edc9fb687d644e4ac8df0cb53197fc776a1ad1
6
+ metadata.gz: c1424077c5301bd3b7bdc95bee51576c469d27a29d0637b7bada2d7a04f22b744b560cd84c47652e0ca9ff780d1d07252bffd103a096c1b5e931ca20fda58bb3
7
+ data.tar.gz: 6492e8028bbb1e4c91ea2a3fe9825a3554cdf30826a3d5eff16a519589422b452cd0faebf1663ca8cd53bbe24ba70ee84ac14f16f067234166b73df3471801ff
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- [![Build Status](https://travis-ci.com/lingua-pupuli/puppetfile-resolver.svg?branch=master)](https://travis-ci.com/lingua-pupuli/puppetfile-resolver)
1
+ [![Build Status](https://travis-ci.com/glennsarti/puppetfile-resolver.svg?branch=master)](https://travis-ci.com/glennsarti/puppetfile-resolver)
2
+ [![Gem Version](https://img.shields.io/gem/v/puppetfile-resolver)](https://rubygems.org/gems/puppetfile-resolver)
2
3
 
3
4
  # Puppetfile Resolver
4
5
 
@@ -12,158 +13,10 @@ This library includes all of the code to parse a Puppetfile and then calculate a
12
13
 
13
14
  **Note** This is still in active development. Git history may be re-written until an initial version is released
14
15
 
15
- ## To Do
16
+ ## Documentation
16
17
 
17
- - Could do with more tests
18
- - Add YARD documentation
19
-
20
- ## Why a library and not a CLI tool?
21
-
22
- Due to all of the different needs of tool developers, this is offered as a library instead of full blown CLI tool. For example, the needs of a VSCode Extensions developer are very different than that of the Puppet Developer Kit developer.
23
-
24
- Therefore this is a library which is intended to be used by tool developers to create useful tools for users, and not really for direct use by users.
25
-
26
- Note that a CLI is included (`puppetfile-cli.rb`) only as an example of how to create a tool using this library.
27
-
28
- ## Architecture
29
-
30
- ``` text
31
- +-----------------+ +-----------------+ +-----------------+
32
- | Forge Searcher | | Github Searcher | | Local Searcher |
33
- +-------+---------+ +--------+--------+ +-------+---------+
34
- | | |
35
- +----------------------+--------------------+
36
- |
37
- |
38
- V
39
- +--------+ +----------+ +-------------------+
40
- -- Text --> | Parser | -- Document Model -+-> | Resolver | -- Dependency Graph -+-> | Resolution Result |
41
- +--------+ | +----------+ | +-------------------+
42
- | |
43
- | |
44
- V V
45
- +-----------+ +------------+
46
- | Document | | Resolution |
47
- | Validator | | Validator |
48
- +-----------+ +------------+
49
- ```
50
-
51
- ### Puppetfile Parser
52
-
53
- The parser converts the content of a Puppetfile into a document model (`PuppetfileResolver::Puppetfile`).
54
-
55
- Currently only one Parser is available, `R10KEval`, which uses the same parsing logic as the [R10K Parser](https://github.com/puppetlabs/r10k/blob/master/lib/r10k/puppetfile.rb). In the future other parsers may be added, such as a [Ruby AST based parser](https://github.com/puppetlabs/r10k/pull/885).
56
-
57
- #### R10KEval Parser
58
-
59
- Sometimes it necessary to instruct the Resolver to ignore certain rules, for example ignoring the Puppet restrictions on a module because it has old metadata. The R10KEval Parser can read ruby comments which have special meanings, similar to how [rubocop](https://docs.rubocop.org/en/stable/) uses [magic comments](https://docs.rubocop.org/en/stable/configuration/#disabling-cops-within-source-code).
60
-
61
- The R10KEval Parser uses the magic comment of `# resolver:disable` to disable tasks. For example;
62
-
63
- You can set a comment for one module like this:
64
-
65
- ``` ruby
66
- mod 'puppetlabs-stdlib', :latest # resolver:disable Dependency/All
67
- ```
68
-
69
- or for many modules by wrapping the modules like this:
70
-
71
- ``` ruby
72
- # resolver:disable Dependency/All
73
- mod 'puppetlabs-stdlib', :latest
74
- mod 'puppetlabs-apache', '1.0.0'
75
- # resolver:ensable Dependency/All
76
- ```
77
-
78
- You can also set multiple items by using a comma like this:
79
-
80
- ``` ruby
81
- mod 'puppetlabs-stdlib', :latest # resolver:disable Dependency/All,Dependency/Puppet
82
- ```
83
-
84
- Note there is no space between items.
85
-
86
- The available settings are:
87
-
88
- | Setting Name | Description |
89
- | --------------------| ----------- |
90
- | `Dependency/Puppet` | Instructs the resolver to ignore any Puppet version in its dependency traversal for the specified modules. Useful for modules with outdated metadata.json information |
91
- | `Dependency/All` | Instructs the resolver to ignore any, and all, dependencies in its dependency traversal of the specified module. Useful for modules with outdated metadata.json information. |
92
-
93
- ### Puppetfile Document Validation
94
-
95
- Even though a Puppetfile can be parsed, doesn't mean it's valid. For example, defining a module twice.
96
-
97
- ### Puppetfile Resolution
98
-
99
- Given a Puppetfile document model, the library can attempt to recursively resolve all of the modules and their dependencies. The resolver be default will not be strict, that is, missing dependencies will not throw an error, and will attempt to also be resolved. When in strict mode, any missing dependencies will throw errors.
100
-
101
- ### Module Searchers
102
-
103
- The Puppetfile resolution needs information about all of the available modules and versions, and does this through calling various Specification Searchers. Currently Puppet Forge, Github and Local FileSystem searchers are implemented. Additional searchers could be added, for example GitLab or SVN.
104
-
105
- The result is a dependency graph listing all of the modules, dependencies and version information.
106
-
107
- ### Resolution validation
108
-
109
- Even though a Puppetfile can be resolved, doesn't mean it is valid. For example, missing module dependencies are not considered valid.
110
-
111
- ### Dependency Graph
112
-
113
- The resolver uses the [Molinillo](https://github.com/CocoaPods/Molinillo) ruby gem for dependency resolution. Molinillo is used in Bundler, among other gems, so it's well used and maintained project.
114
-
115
- ### Example workflow
116
-
117
- 1. Load the contents of a Puppetfile from disk
118
-
119
- 2. Parse the Puppetfile into a document model
120
-
121
- 3. Verify that the document model is valid
122
-
123
- 4. Create a resolver object with the document model, and the required Puppet version (optional)
124
-
125
- 5. Start the resolution
126
-
127
- 6. Validate the resolution against the document model
128
-
129
- ### Example usage
130
-
131
- ``` ruby
132
- puppetfile_path = '/path/to/Puppetfile'
133
-
134
- # Parse the Puppetfile into an object model
135
- content = File.open(puppetfile_path, 'rb') { |f| f.read }
136
- require 'puppetfile-resolver/puppetfile/parser/r10k_eval'
137
- puppetfile = ::PuppetfileResolver::Puppetfile::Parser::R10KEval.parse(content)
138
-
139
- # Make sure the Puppetfile is valid
140
- unless puppetfile.valid?
141
- puts 'Puppetfile is not valid'
142
- puppetfile.validation_errors.each { |err| puts err }
143
- exit 1
144
- end
145
-
146
- # Create the resolver
147
- # - Use the document we just parsed (puppetfile)
148
- # - Don't restrict by Puppet version (nil)
149
- resolver = PuppetfileResolver::Resolver.new(puppetfile, nil)
150
-
151
- # Configure the resolver
152
- cache = nil # Use the default inmemory cache
153
- ui = nil # Don't output any information
154
- module_paths = [] # List of paths to search for modules on the local filesystem
155
- allow_missing_modules = true # Allow missing dependencies to be resolved
156
- opts = { cache: cache, ui: ui, module_paths: module_paths, allow_missing_modules: allow_missing_modules }
157
-
158
- # Resolve
159
- result = resolver.resolve(opts)
160
-
161
- # Output resolution validation errors
162
- result.validation_errors.each { |err| puts "Resolution Validation Error: #{err}\n"}
163
- ```
164
-
165
- ## Known issues
166
-
167
- - The Forge module searcher will only use the internet facing forge ([https://forge.puppet.com](https://forge.puppet.com/)). Self-hosted forges are not supported
168
-
169
- - The Git module searcher will only search public Github based modules. Private repositories or other VCS systems are not supported
18
+ - [About](https://glennsarti.github.io/puppetfile-resolver/)
19
+ - [Architecture](https://glennsarti.github.io/puppetfile-resolver/architecture)
20
+ - [Parsers](https://glennsarti.github.io/puppetfile-resolver/parsers)
21
+ - [Example Usage](https://glennsarti.github.io/puppetfile-resolver/example_usage)
22
+ - [Known Issues](https://glennsarti.github.io/puppetfile-resolver/known_issues)
@@ -1,7 +1,7 @@
1
1
  ##
2
2
  ## Bundle of CA Root Certificates
3
3
  ##
4
- ## Certificate data from Mozilla as of: Wed Oct 16 03:12:09 2019 GMT
4
+ ## Certificate data from Mozilla as of: Wed Jan 1 04:12:10 2020 GMT
5
5
  ##
6
6
  ## This is a bundle of X.509 certificates of public Certificate Authorities
7
7
  ## (CA). These were automatically extracted from Mozilla's root certificates
@@ -14,7 +14,7 @@
14
14
  ## Just configure this file as the SSLCACertificateFile.
15
15
  ##
16
16
  ## Conversion done with mk-ca-bundle.pl version 1.27.
17
- ## SHA256: c979c6f35714a0fedb17d9e5ba37adecbbc91a8faf4186b4e23d6f9ca44fd6cb
17
+ ## SHA256: f3bdcd74612952da8476a9d4147f50b29ad0710b7dd95b4c8690500209986d70
18
18
  ##
19
19
 
20
20
 
@@ -3430,3 +3430,37 @@ hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
3430
3430
  60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
3431
3431
  dBb9HxEGmpv0
3432
3432
  -----END CERTIFICATE-----
3433
+
3434
+ Entrust Root Certification Authority - G4
3435
+ =========================================
3436
+ -----BEGIN CERTIFICATE-----
3437
+ MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAwgb4xCzAJBgNV
3438
+ BAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu
3439
+ bmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1
3440
+ dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3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AG - Instructs the resolver to not consider Puppet version in its dependency traversal. Useful for modules with outdated metadata.json information.
8
8
  # DISABLE_ALL_DEPENDENCIES_FLAG - Instructs the resolver to ignore any dependencies in its dependency traversal. Useful for modules with outdated metadata.json information.
9
+ # DISABLE_LATEST_VALIDATION_FLAG - Instructs the resolution validator to ignore modules that have a version of :latest
9
10
  #
10
11
  DISABLE_PUPPET_DEPENDENCY_FLAG = :disable_puppet_dependency
11
12
  DISABLE_ALL_DEPENDENCIES_FLAG = :disable_all_dependencies
13
+ DISABLE_LATEST_VALIDATION_FLAG = :disable_latest_validation
12
14
  end
13
15
  end
14
16
 
@@ -20,3 +22,4 @@ require 'puppetfile-resolver/puppetfile/git_module'
20
22
  require 'puppetfile-resolver/puppetfile/invalid_module'
21
23
  require 'puppetfile-resolver/puppetfile/local_module'
22
24
  require 'puppetfile-resolver/puppetfile/svn_module'
25
+ require 'puppetfile-resolver/puppetfile/parser/r10k_eval'
@@ -75,6 +75,7 @@ module PuppetfileResolver
75
75
  next unless mod.version == :latest
76
76
  resolved_module = resolution_result.specifications[mod.name]
77
77
  next if resolved_module.nil? || resolved_module.is_a?(PuppetfileResolver::Models::MissingModuleSpecification)
78
+ next if mod.resolver_flags.include?(PuppetfileResolver::Puppetfile::DISABLE_LATEST_VALIDATION_FLAG)
78
79
  @validation_errors << DocumentLatestVersionError.new(
79
80
  "Latest version of #{mod.name} is #{resolved_module.version}",
80
81
  mod,
@@ -105,6 +105,8 @@ module PuppetfileResolver
105
105
  PuppetfileResolver::Puppetfile::DISABLE_PUPPET_DEPENDENCY_FLAG
106
106
  when 'dependency/all'
107
107
  PuppetfileResolver::Puppetfile::DISABLE_ALL_DEPENDENCIES_FLAG
108
+ when 'validation/latestversion'
109
+ PuppetfileResolver::Puppetfile::DISABLE_LATEST_VALIDATION_FLAG
108
110
  else # rubocop:disable Style/EmptyElse We will be adding something here later
109
111
  # TODO: Should we log a warning/info here?
110
112
  nil
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PuppetfileResolver
4
- VERSION ||= '0.1.0'
4
+ VERSION ||= '0.2.0'
5
5
  end
@@ -126,6 +126,7 @@ describe 'PuppetfileResolver::Puppetfile::Document' do
126
126
  @document_modules = document_fixtures.map do |doc_mod|
127
127
  mod = doc_mod[:class].new(doc_mod[:name])
128
128
  mod.version = doc_mod[:version]
129
+ mod.resolver_flags = doc_mod[:flags] unless doc_mod[:flags].nil?
129
130
  subject.add_module(mod)
130
131
  mod
131
132
  end
@@ -207,6 +208,19 @@ describe 'PuppetfileResolver::Puppetfile::Document' do
207
208
  puppet_module: @document_modules[0]
208
209
  )
209
210
  end
211
+
212
+ context 'and using the DISABLE_LATEST_VALIDATION_FLAG flag' do
213
+ let(:document_fixtures) do
214
+ [
215
+ { class: PuppetfileResolver::Puppetfile::ForgeModule, name: 'foo', version: :latest, flags: [PuppetfileResolver::Puppetfile::DISABLE_LATEST_VALIDATION_FLAG] }
216
+ ]
217
+ end
218
+
219
+ it 'should not return a DocumentLatestVersionError' do
220
+ errors = subject.resolution_validation_errors(resolution_result)
221
+ expect(errors.count).to eq(0)
222
+ end
223
+ end
210
224
  end
211
225
 
212
226
  context 'Given a document with a missing module' do
@@ -351,6 +351,7 @@ RSpec.shared_examples "a puppetfile parser with magic comments" do
351
351
 
352
352
  mod 'puppetlabs-magic1', :latest # resolver:disable Dependency/Puppet
353
353
  mod 'puppetlabs-magic2', :latest # resolver:disable Dependency/all
354
+ mod 'puppetlabs-magic3', :latest # resolver:disable Validation/LatestVersion
354
355
  EOT
355
356
  end
356
357
  let(:puppetfile) { subject.parse(puppetfile_content) }
@@ -364,6 +365,11 @@ RSpec.shared_examples "a puppetfile parser with magic comments" do
364
365
  mod = get_module(puppetfile, 'puppetlabs-magic2')
365
366
  expect(mod.resolver_flags).to eq([PuppetfileResolver::Puppetfile::DISABLE_ALL_DEPENDENCIES_FLAG])
366
367
  end
368
+
369
+ it 'should add the DISABLE_LATEST_VALIDATION_FLAG flag for Validation/LatestVersion' do
370
+ mod = get_module(puppetfile, 'puppetlabs-magic3')
371
+ expect(mod.resolver_flags).to eq([PuppetfileResolver::Puppetfile::DISABLE_LATEST_VALIDATION_FLAG])
372
+ end
367
373
  end
368
374
  end
369
375
 
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glenn Sarti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-04 00:00:00.000000000 Z
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: molinillo
@@ -93,7 +93,7 @@ files:
93
93
  - spec/unit/puppetfile-resolver/puppetfile/document_spec.rb
94
94
  - spec/unit/puppetfile-resolver/puppetfile/parser/r10k_eval_spec.rb
95
95
  - spec/unit/puppetfile-resolver/resolver_spec.rb
96
- homepage: https://github.com/lingua-pupuli/puppetfile-resolver/
96
+ homepage: https://glennsarti.github.io/puppetfile-resolver/
97
97
  licenses:
98
98
  - Apache-2.0
99
99
  metadata: {}