ra10ke 1.0.0 → 2.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/.github/dependabot.yml +11 -0
- data/.github/workflows/release.yml +32 -0
- data/.github/workflows/test.yml +32 -0
- data/.gitignore +3 -0
- data/.ruby-version +1 -1
- data/.travis.yml +1 -0
- data/CHANGELOG.md +72 -4
- data/Gemfile +9 -0
- data/HISTORY.md +118 -0
- data/README.md +34 -1
- data/Rakefile +13 -0
- data/lib/ra10ke/dependencies.rb +172 -49
- data/lib/ra10ke/deprecation.rb +72 -0
- data/lib/ra10ke/git_repo.rb +128 -0
- data/lib/ra10ke/puppetfile_parser.rb +9 -2
- data/lib/ra10ke/solve.rb +4 -0
- data/lib/ra10ke/validate.rb +19 -60
- data/lib/ra10ke/version.rb +1 -1
- data/lib/ra10ke.rb +6 -0
- data/ra10ke.gemspec +5 -2
- data/spec/fixtures/Puppetfile +2 -0
- data/spec/fixtures/Puppetfile_deprecation_issue +78 -0
- data/spec/fixtures/Puppetfile_git_conversion +28 -0
- data/spec/fixtures/Puppetfile_with_bad_refs +3 -0
- data/spec/fixtures/Puppetfile_with_commit +3 -0
- data/spec/fixtures/Puppetfile_with_control_branch +23 -0
- data/spec/fixtures/refs/debug.txt +0 -0
- data/spec/fixtures/refs/gitlab.txt +285 -0
- data/spec/fixtures/refs/r10k.txt +120 -0
- data/spec/fixtures/{reflist.txt → refs/reflist.txt} +0 -0
- data/spec/ra10ke/dependencies_spec.rb +108 -0
- data/spec/ra10ke/deprecation_spec.rb +48 -0
- data/spec/ra10ke/git_repo_spec.rb +92 -0
- data/spec/ra10ke/puppetfile_parser_spec.rb +3 -1
- data/spec/ra10ke/validate_spec.rb +96 -33
- data/spec/ra10ke_spec.rb +6 -4
- data/spec/spec_helper.rb +28 -0
- metadata +51 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42a64a748cf4b63602804c2aac20987e23d8a7ad2a01ca3365d3ed998324f058
|
4
|
+
data.tar.gz: daa94b8601294ed8c480f431d396eda60c2a14d2c7aa608e4941189033c01b24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1b0a572ecb7928f0e38254f6ed91f4e501f2755497a53ced15a164ada79dfa2b335afe7f4565c27ae63050a17d57c8df45dd39dd5fbac0271361f00c8063c5a
|
7
|
+
data.tar.gz: 251245599d77dbbd4b01c3946693083782fe8b1f0937236fc207ca3c69616b967743cafa0bb8e4151407199fd8d4e0be0479da8e7f83009bb22f0fe9192785e1
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: "bundler" # See documentation for possible values
|
9
|
+
directory: "/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "daily"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- '*'
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
release:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
if: github.repository_owner == 'voxpupuli'
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Install Ruby 3.0
|
15
|
+
uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: '3.0'
|
18
|
+
env:
|
19
|
+
BUNDLE_WITHOUT: release
|
20
|
+
- name: Build gem
|
21
|
+
run: gem build *.gemspec
|
22
|
+
- name: Publish gem to rubygems.org
|
23
|
+
run: gem push *.gem
|
24
|
+
env:
|
25
|
+
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
|
26
|
+
- name: Setup GitHub packages access
|
27
|
+
run: |
|
28
|
+
mkdir -p ~/.gem
|
29
|
+
echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials
|
30
|
+
chmod 0600 ~/.gem/credentials
|
31
|
+
- name: Publish gem to GitHub packages
|
32
|
+
run: gem push --key github --host https://rubygems.pkg.github.com/voxpupuli *.gem
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
- pull_request
|
5
|
+
|
6
|
+
env:
|
7
|
+
BUNDLE_WITHOUT: release
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
fail-fast: false
|
14
|
+
matrix:
|
15
|
+
include:
|
16
|
+
- ruby: "2.7"
|
17
|
+
- ruby: "3.0"
|
18
|
+
- ruby: "3.1"
|
19
|
+
coverage: "yes"
|
20
|
+
env:
|
21
|
+
COVERAGE: ${{ matrix.coverage }}
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v2
|
24
|
+
- name: Install Ruby ${{ matrix.ruby }}
|
25
|
+
uses: ruby/setup-ruby@v1
|
26
|
+
with:
|
27
|
+
ruby-version: ${{ matrix.ruby }}
|
28
|
+
bundler-cache: true
|
29
|
+
- name: Run tests
|
30
|
+
run: bundle exec rake
|
31
|
+
- name: Build gem
|
32
|
+
run: gem build *.gemspec
|
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.7
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,73 @@
|
|
1
|
-
|
2
|
-
=========
|
1
|
+
# Changelog
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
## [v2.0.0](https://github.com/voxpupuli/ra10ke/tree/v2.0.0) (2022-05-18)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/ra10ke/compare/v1.2.0...v2.0.0)
|
8
|
+
|
9
|
+
**Breaking changes:**
|
10
|
+
|
11
|
+
- Bump minimal Ruby Version 2.4.0-\>2.7.0 [\#77](https://github.com/voxpupuli/ra10ke/pull/77) ([bastelfreak](https://github.com/bastelfreak))
|
12
|
+
- Dependencies Table output [\#72](https://github.com/voxpupuli/ra10ke/pull/72) ([logicminds](https://github.com/logicminds))
|
13
|
+
|
14
|
+
**Implemented enhancements:**
|
15
|
+
|
16
|
+
- Add Ruby 3.1 support [\#78](https://github.com/voxpupuli/ra10ke/pull/78) ([bastelfreak](https://github.com/bastelfreak))
|
17
|
+
- Converts puppet forge module entries into puppetfile git entries [\#76](https://github.com/voxpupuli/ra10ke/pull/76) ([logicminds](https://github.com/logicminds))
|
18
|
+
|
19
|
+
**Fixed bugs:**
|
20
|
+
|
21
|
+
- incompatible with r10k gem \> 3.8 [\#57](https://github.com/voxpupuli/ra10ke/issues/57)
|
22
|
+
- CI: Do not run twice [\#79](https://github.com/voxpupuli/ra10ke/pull/79) ([bastelfreak](https://github.com/bastelfreak))
|
23
|
+
- Fix \#74 - server responded with 400 [\#75](https://github.com/voxpupuli/ra10ke/pull/75) ([logicminds](https://github.com/logicminds))
|
24
|
+
- Fix \#70 - cache dir does not exist [\#71](https://github.com/voxpupuli/ra10ke/pull/71) ([logicminds](https://github.com/logicminds))
|
25
|
+
|
26
|
+
**Closed issues:**
|
27
|
+
|
28
|
+
- cache dir does not exist [\#70](https://github.com/voxpupuli/ra10ke/issues/70)
|
29
|
+
|
30
|
+
## [v1.2.0](https://github.com/voxpupuli/ra10ke/tree/v1.2.0) (2022-04-21)
|
31
|
+
|
32
|
+
[Full Changelog](https://github.com/voxpupuli/ra10ke/compare/v1.1.0...v1.2.0)
|
33
|
+
|
34
|
+
**Closed issues:**
|
35
|
+
|
36
|
+
- Add support for commit ref [\#67](https://github.com/voxpupuli/ra10ke/issues/67)
|
37
|
+
|
38
|
+
**Merged pull requests:**
|
39
|
+
|
40
|
+
- Fix \#67 - Add support for commit ref [\#68](https://github.com/voxpupuli/ra10ke/pull/68) ([logicminds](https://github.com/logicminds))
|
41
|
+
|
42
|
+
## [v1.1.0](https://github.com/voxpupuli/ra10ke/tree/v1.1.0) (2021-10-26)
|
43
|
+
|
44
|
+
[Full Changelog](https://github.com/voxpupuli/ra10ke/compare/v1.0.0...v1.1.0)
|
45
|
+
|
46
|
+
**Implemented enhancements:**
|
47
|
+
|
48
|
+
- Support r10k:validate with control\_branch [\#58](https://github.com/voxpupuli/ra10ke/issues/58)
|
49
|
+
- Implement GitHub Actions and fix tests [\#62](https://github.com/voxpupuli/ra10ke/pull/62) ([bastelfreak](https://github.com/bastelfreak))
|
50
|
+
- Add handling for additional r10k args in validate for control\_branch [\#61](https://github.com/voxpupuli/ra10ke/pull/61) ([ananace](https://github.com/ananace))
|
51
|
+
- Add r10k:deprecation task [\#60](https://github.com/voxpupuli/ra10ke/pull/60) ([ananace](https://github.com/ananace))
|
52
|
+
- Support r10k:validate with control\_branch modules [\#59](https://github.com/voxpupuli/ra10ke/pull/59) ([ananace](https://github.com/ananace))
|
53
|
+
- allow to add other version formats in dependencies [\#56](https://github.com/voxpupuli/ra10ke/pull/56) ([jduepmeier](https://github.com/jduepmeier))
|
54
|
+
- Fixes \#52 - validate task fails when repo does not exist [\#53](https://github.com/voxpupuli/ra10ke/pull/53) ([logicminds](https://github.com/logicminds))
|
55
|
+
|
56
|
+
**Fixed bugs:**
|
57
|
+
|
58
|
+
- Fix source of control\_branch data [\#63](https://github.com/voxpupuli/ra10ke/pull/63) ([ananace](https://github.com/ananace))
|
59
|
+
|
60
|
+
**Closed issues:**
|
61
|
+
|
62
|
+
- validate task fails when repo does not exist [\#52](https://github.com/voxpupuli/ra10ke/issues/52)
|
63
|
+
|
64
|
+
**Merged pull requests:**
|
65
|
+
|
66
|
+
- Add Dependabot config [\#65](https://github.com/voxpupuli/ra10ke/pull/65) ([bastelfreak](https://github.com/bastelfreak))
|
67
|
+
- Set minimal Ruby version to 2.4.0 [\#64](https://github.com/voxpupuli/ra10ke/pull/64) ([bastelfreak](https://github.com/bastelfreak))
|
68
|
+
- Add coverage reports [\#54](https://github.com/voxpupuli/ra10ke/pull/54) ([logicminds](https://github.com/logicminds))
|
69
|
+
|
70
|
+
## [v1.0.0](https://github.com/voxpupuli/ra10ke/tree/v1.0.0) (2020-02-08)
|
6
71
|
|
7
72
|
2020-02-08
|
8
73
|
|
@@ -120,3 +185,6 @@ Many thanks to [Alexander "Ace" Olofsson](https://github.com/ace13) and [James P
|
|
120
185
|
2015-12-07
|
121
186
|
|
122
187
|
* Initial release
|
188
|
+
|
189
|
+
|
190
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile
CHANGED
@@ -2,3 +2,12 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in ra10ke.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
group :release do
|
7
|
+
gem 'github_changelog_generator', :require => false
|
8
|
+
end
|
9
|
+
|
10
|
+
group :coverage, optional: ENV['COVERAGE']!='yes' do
|
11
|
+
gem 'simplecov-console', :require => false
|
12
|
+
gem 'codecov', :require => false
|
13
|
+
end
|
data/HISTORY.md
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
## [v1.0.0](https://github.com/voxpupuli/ra10ke/tree/v1.0.0) (2020-02-08)
|
2
|
+
|
3
|
+
2020-02-08
|
4
|
+
|
5
|
+
Closed Pull Requests:
|
6
|
+
|
7
|
+
* [#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)
|
8
|
+
* [#45](https://github.com/voxpupuli/ra10ke/pull/45) - Add a duplicates check
|
9
|
+
* [#48](https://github.com/voxpupuli/ra10ke/pull/48) - Allow semverse 3.x
|
10
|
+
|
11
|
+
0.6.2
|
12
|
+
-----
|
13
|
+
|
14
|
+
2019-08-26
|
15
|
+
|
16
|
+
Closed Pull Requests:
|
17
|
+
|
18
|
+
* [#42](https://github.com/voxpupuli/ra10ke/pull/42) - Fix lost refs in validation
|
19
|
+
|
20
|
+
Again many thanks to the following contributors for submitting PRs:
|
21
|
+
|
22
|
+
* [Alexander Olofsson](https://github.com/ananace)
|
23
|
+
|
24
|
+
0.6.1
|
25
|
+
-----
|
26
|
+
|
27
|
+
2019-08-17
|
28
|
+
|
29
|
+
Closed Pull Requests:
|
30
|
+
|
31
|
+
* [#40](https://github.com/voxpupuli/ra10ke/pull/40) - Fix a fault in the mod handling behaviour
|
32
|
+
|
33
|
+
Closed Issues:
|
34
|
+
|
35
|
+
* [#25](https://github.com/voxpupuli/ra10ke/issues/25) - Consider making r10k:install have a default path of '.'
|
36
|
+
|
37
|
+
Many thanks to the following contributors for submitting PRs:
|
38
|
+
|
39
|
+
* [Alexander Olofsson](https://github.com/ananace)
|
40
|
+
|
41
|
+
0.6.0
|
42
|
+
-----
|
43
|
+
|
44
|
+
2019-07-30
|
45
|
+
|
46
|
+
Closed Pull Requests:
|
47
|
+
|
48
|
+
* [#35](https://github.com/voxpupuli/ra10ke/pull/35) Adds new validate task for verifying the integrity of all modules specified in the Puppetfile
|
49
|
+
* [#33](https://github.com/voxpupuli/ra10ke/pull/33) Refactor tasks, Version tag handling fix, purge option
|
50
|
+
* [#32](https://github.com/voxpupuli/ra10ke/pull/32) Make it possible to configure the tasks in the rakefile
|
51
|
+
|
52
|
+
Many thanks to the following contributors for submitting PRs:
|
53
|
+
|
54
|
+
* [Corey Osman](https://github.com/logicminds)
|
55
|
+
* [Andreas Zuber](https://github.com/ZeroPointEnergy)
|
56
|
+
|
57
|
+
0.5.0
|
58
|
+
-----
|
59
|
+
|
60
|
+
2018-12-26
|
61
|
+
|
62
|
+
Closed Pull Requests:
|
63
|
+
|
64
|
+
* [#22](https://github.com/voxpupuli/ra10ke/pull/22) Add rudimentary r10k:install task
|
65
|
+
* [#26](https://github.com/voxpupuli/ra10ke/pull/26) make use of the forge command in puppetfile
|
66
|
+
* [#29](https://github.com/voxpupuli/ra10ke/pull/29) Abort (exit 1) if Puppetfile syntax check fails
|
67
|
+
* [#30](https://github.com/voxpupuli/ra10ke/pull/30) enable travis deployment
|
68
|
+
|
69
|
+
0.4.0
|
70
|
+
-----
|
71
|
+
|
72
|
+
2018-06-17
|
73
|
+
|
74
|
+
* [#13](https://github.com/voxpupuli/ra10ke/pull/13) Avoid using `desired_ref` directly for Git
|
75
|
+
* [#14](https://github.com/voxpupuli/ra10ke/pull/14) Set required Ruby version as `>= 2.1.0`
|
76
|
+
* [#15](https://github.com/voxpupuli/ra10ke/pull/15) ignore invalid ref
|
77
|
+
* [#16](https://github.com/voxpupuli/ra10ke/pull/16) Use Semantic Versioning for Git tags
|
78
|
+
* [#17](https://github.com/voxpupuli/ra10ke/pull/17) Be careful around trimming Git tags
|
79
|
+
* [#19](https://github.com/voxpupuli/ra10ke/pull/19) Ensure Puppetfile gets parsed with absolute path
|
80
|
+
|
81
|
+
Many thanks to the following contributors for submitting the PRs:
|
82
|
+
* [Valter Jansons](https://github.com/sigv)
|
83
|
+
* [Martin Alfke](https://github.com/tuxmea)
|
84
|
+
* [Matthias Baur](https://github.com/baurmatt)
|
85
|
+
|
86
|
+
0.3.0
|
87
|
+
-----
|
88
|
+
|
89
|
+
2017-10-08
|
90
|
+
|
91
|
+
* [#6](https://github.com/voxpupuli/ra10ke/pull/6) Add a dependency solver based on the Ruby Solve library (thanks to [Jarkko Oranen](https://github.com/oranenj))
|
92
|
+
* [#8](https://github.com/voxpupuli/ra10ke/pull/8) Add numeric tag convention support (thanks to [Hervé MARTIN](https://github.com/HerveMARTIN))
|
93
|
+
|
94
|
+
0.2.0
|
95
|
+
-----
|
96
|
+
|
97
|
+
2017-01-03
|
98
|
+
|
99
|
+
* Moved to [Vox Pupuli](https://voxpupuli.org/)
|
100
|
+
* [#3](https://github.com/voxpupuli/ra10ke/pull/3) Update ra10ke with r10k 2.4.0 support
|
101
|
+
* [#4](https://github.com/voxpupuli/ra10ke/pull/4) Added git support
|
102
|
+
|
103
|
+
Many thanks to [Alexander "Ace" Olofsson](https://github.com/ace13) and [James Powis](https://github.com/james-powis) for their contributions!
|
104
|
+
|
105
|
+
0.1.1
|
106
|
+
-----
|
107
|
+
|
108
|
+
2016-08-22
|
109
|
+
|
110
|
+
* [#1](https://github.com/tampakrap/ra10ke/issues/1) update docs to mention Gemfile and Rakefile
|
111
|
+
* properly advertise the user agent
|
112
|
+
|
113
|
+
0.1.0
|
114
|
+
-----
|
115
|
+
|
116
|
+
2015-12-07
|
117
|
+
|
118
|
+
* Initial release
|
data/README.md
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
ra10ke
|
2
2
|
======
|
3
3
|
|
4
|
-
[](https://github.com/voxpupuli/ra10ke/blob/master/LICENSE.txt)
|
5
|
+
[](https://github.com/voxpupuli/ra10ke/actions/workflows/test.yml)
|
6
|
+
[](https://codecov.io/gh/voxpupuli/ra10ke)
|
7
|
+
[](https://github.com/voxpupuli/ra10ke/actions/workflows/release.yml)
|
8
|
+
[](https://rubygems.org/gems/ra10ke)
|
9
|
+
[](https://rubygems.org/gems/ra10ke)
|
5
10
|
|
6
11
|
Rake tasks related to [R10K](https://github.com/puppetlabs/r10k) and
|
7
12
|
[Puppetfile](https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd).
|
@@ -63,6 +68,15 @@ Ignoring specific modules:
|
|
63
68
|
Under specific conditions you may not wish to report on specific modules being out of date,
|
64
69
|
to ignore a module create `.r10kignore` file in the same directory as your Puppetfile.
|
65
70
|
|
71
|
+
### r10k::print_git_conversion
|
72
|
+
This rake task will go through the puppetfile and convert forge based modules into git based modules using
|
73
|
+
the modules't source repository and version tag.
|
74
|
+
|
75
|
+
This feature is useful when you want to bring all the forge modules into git source control. This assumes every module
|
76
|
+
tags the release or provides a valid repo url. We recommend to manually review
|
77
|
+
the output provided by this task before replacing the forge based content in your puppetfile as not every module author
|
78
|
+
tagged a release or provided a working url.
|
79
|
+
|
66
80
|
### r10k:solve_dependencies
|
67
81
|
|
68
82
|
Reads the Puppetfile in the current directory and uses the ruby 'solve' library to find
|
@@ -145,3 +159,22 @@ gitlab:
|
|
145
159
|
|
146
160
|
Error: Duplicates exist in the Puppetfile
|
147
161
|
```
|
162
|
+
|
163
|
+
### r10k:deprecation
|
164
|
+
|
165
|
+
This rake task checks all the Forge modules listed in the Puppetfile, looking
|
166
|
+
for modules that are marked as deprecated on the Forge.
|
167
|
+
|
168
|
+
Example
|
169
|
+
|
170
|
+
```
|
171
|
+
NAME | DEPRECATED_AT
|
172
|
+
------------------------|--------------------------
|
173
|
+
kemra102-auditd | 2021-07-22 12:11:46
|
174
|
+
puppet-staging | 2018-12-18 11:11:29
|
175
|
+
puppetlabs-resource_api | 2021-03-31 12:53:24
|
176
|
+
puppetlabs-ruby | 2021-04-22 10:29:42
|
177
|
+
puppetlabs-translate | 2021-03-19 10:11:51
|
178
|
+
|
179
|
+
Error: Puppetfile contains deprecated modules.
|
180
|
+
```
|
data/Rakefile
CHANGED
@@ -14,3 +14,16 @@ task :default => [:spec]
|
|
14
14
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
15
15
|
spec.pattern = FileList['spec/**/*_spec.rb']
|
16
16
|
end
|
17
|
+
|
18
|
+
begin
|
19
|
+
require 'github_changelog_generator/task'
|
20
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
21
|
+
version = Ra10ke::VERSION
|
22
|
+
config.future_release = "v#{version}" if version =~ /^\d+\.\d+.\d+$/
|
23
|
+
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
|
24
|
+
config.exclude_labels = %w{duplicate question invalid wontfix wont-fix skip-changelog}
|
25
|
+
config.user = 'voxpupuli'
|
26
|
+
config.project = 'ra10ke'
|
27
|
+
end
|
28
|
+
rescue LoadError
|
29
|
+
end
|
data/lib/ra10ke/dependencies.rb
CHANGED
@@ -1,7 +1,147 @@
|
|
1
|
+
require 'semverse'
|
2
|
+
require 'r10k/puppetfile'
|
3
|
+
require 'puppet_forge'
|
4
|
+
require 'table_print'
|
5
|
+
require 'git'
|
6
|
+
|
1
7
|
module Ra10ke::Dependencies
|
2
|
-
|
3
|
-
|
4
|
-
|
8
|
+
class Verification
|
9
|
+
|
10
|
+
def self.version_formats
|
11
|
+
@version_formats ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
# Registers a block that finds the latest version.
|
15
|
+
# The block will be called with a list of tags.
|
16
|
+
# If the block returns nil the next format will be tried.
|
17
|
+
def self.register_version_format(name, &block)
|
18
|
+
version_formats[name] = block
|
19
|
+
end
|
20
|
+
|
21
|
+
Ra10ke::Dependencies::Verification.register_version_format(:semver) do |tags|
|
22
|
+
latest_tag = tags.map do |tag|
|
23
|
+
begin
|
24
|
+
Semverse::Version.new tag[/\Av?(.*)\Z/, 1]
|
25
|
+
rescue Semverse::InvalidVersionFormat
|
26
|
+
# ignore tags that do not comply to semver
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
end.select { |tag| !tag.nil? }.sort.last.to_s.downcase
|
30
|
+
latest_ref = tags.detect { |tag| tag[/\Av?(.*)\Z/, 1] == latest_tag }
|
31
|
+
end
|
32
|
+
attr_reader :puppetfile
|
33
|
+
|
34
|
+
def initialize(pfile)
|
35
|
+
@puppetfile = pfile
|
36
|
+
# semver is the default version format.
|
37
|
+
|
38
|
+
puppetfile.load!
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_latest_ref(remote_refs)
|
42
|
+
tags = remote_refs['tags'].keys
|
43
|
+
latest_ref = nil
|
44
|
+
self.class.version_formats.detect { |_, block| latest_ref = block.call(tags) }
|
45
|
+
latest_ref = 'undef (tags do not follow any known pattern)' if latest_ref.nil?
|
46
|
+
latest_ref
|
47
|
+
end
|
48
|
+
|
49
|
+
def ignored_modules
|
50
|
+
# ignore file allows for "don't tell me about this"
|
51
|
+
@ignored_modules ||= begin
|
52
|
+
File.readlines('.r10kignore').each {|l| l.chomp!} if File.exist?('.r10kignore')
|
53
|
+
end || []
|
54
|
+
end
|
55
|
+
|
56
|
+
# @summary creates an array of module hashes with version info
|
57
|
+
# @param {Object} supplied_puppetfile - the parsed puppetfile object
|
58
|
+
# @returns {Array} array of version info for each module
|
59
|
+
# @note does not include ignored modules or modules up2date
|
60
|
+
def processed_modules(supplied_puppetfile = puppetfile)
|
61
|
+
threads = []
|
62
|
+
threads = supplied_puppetfile.modules.map do |puppet_module|
|
63
|
+
Thread.new do
|
64
|
+
begin
|
65
|
+
next if ignored_modules.include? puppet_module.title
|
66
|
+
if puppet_module.class == ::R10K::Module::Forge
|
67
|
+
module_name = puppet_module.title.gsub('/', '-')
|
68
|
+
forge_version = ::PuppetForge::Module.find(module_name).current_release.version
|
69
|
+
installed_version = puppet_module.expected_version
|
70
|
+
{
|
71
|
+
name: puppet_module.title,
|
72
|
+
installed: installed_version,
|
73
|
+
latest: forge_version,
|
74
|
+
type: 'forge',
|
75
|
+
message: installed_version != forge_version ? :outdated : :current
|
76
|
+
}
|
77
|
+
|
78
|
+
elsif puppet_module.class == R10K::Module::Git
|
79
|
+
# use helper; avoid `desired_ref`
|
80
|
+
# we do not want to deal with `:control_branch`
|
81
|
+
ref = puppet_module.version
|
82
|
+
next unless ref
|
83
|
+
|
84
|
+
remote = puppet_module.instance_variable_get(:@remote)
|
85
|
+
remote_refs = Git.ls_remote(remote)
|
86
|
+
|
87
|
+
# skip if ref is a branch
|
88
|
+
next if remote_refs['branches'].key?(ref)
|
89
|
+
|
90
|
+
if remote_refs['tags'].key?(ref)
|
91
|
+
# there are too many possible versioning conventions
|
92
|
+
# we have to be be opinionated here
|
93
|
+
# so semantic versioning (vX.Y.Z) it is for us
|
94
|
+
# as well as support for skipping the leading v letter
|
95
|
+
#
|
96
|
+
# register own version formats with
|
97
|
+
# Ra10ke::Dependencies.register_version_format(:name, &block)
|
98
|
+
latest_ref = get_latest_ref(remote_refs)
|
99
|
+
elsif ref.match(/^[a-z0-9]{40}$/)
|
100
|
+
ref = ref.slice(0,8)
|
101
|
+
# for sha just assume head should be tracked
|
102
|
+
latest_ref = remote_refs['head'][:sha].slice(0,8)
|
103
|
+
else
|
104
|
+
raise "Unable to determine ref type for #{puppet_module.title}"
|
105
|
+
end
|
106
|
+
{
|
107
|
+
name: puppet_module.title,
|
108
|
+
installed: ref,
|
109
|
+
latest: latest_ref,
|
110
|
+
type: 'git',
|
111
|
+
message: ref != latest_ref ? :outdated : :current
|
112
|
+
}
|
113
|
+
|
114
|
+
end
|
115
|
+
rescue R10K::Util::Subprocess::SubprocessError => e
|
116
|
+
{
|
117
|
+
name: puppet_module.title,
|
118
|
+
installed: nil,
|
119
|
+
latest: nil,
|
120
|
+
type: :error,
|
121
|
+
message: e.message
|
122
|
+
}
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
threads.map { |th| th.join.value }.compact
|
127
|
+
end
|
128
|
+
|
129
|
+
def outdated(supplied_puppetfile = puppetfile)
|
130
|
+
processed_modules.find_all do | mod |
|
131
|
+
mod[:message] == :outdated
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def print_table(mods)
|
136
|
+
puts
|
137
|
+
tp mods, { name: { width: 50 } }, :installed, :latest, :type, :message
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def define_task_print_git_conversion(*_args)
|
142
|
+
desc "Convert and print forge modules to git format"
|
143
|
+
task :print_git_conversion do
|
144
|
+
require 'ra10ke/git_repo'
|
5
145
|
require 'r10k/puppetfile'
|
6
146
|
require 'puppet_forge'
|
7
147
|
|
@@ -15,57 +155,40 @@ module Ra10ke::Dependencies
|
|
15
155
|
if File.exist?('.r10kignore')
|
16
156
|
ignore_modules = File.readlines('.r10kignore').each {|l| l.chomp!}
|
17
157
|
end
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
if puppet_module.class == R10K::Module::Git
|
31
|
-
# use helper; avoid `desired_ref`
|
32
|
-
# we do not want to deal with `:control_branch`
|
33
|
-
ref = puppet_module.version
|
34
|
-
next unless ref
|
35
|
-
|
36
|
-
remote = puppet_module.instance_variable_get(:@remote)
|
37
|
-
remote_refs = Git.ls_remote(remote)
|
38
|
-
|
39
|
-
# skip if ref is a branch
|
40
|
-
next if remote_refs['branches'].key?(ref)
|
41
|
-
|
42
|
-
if remote_refs['tags'].key?(ref)
|
43
|
-
# there are too many possible versioning conventions
|
44
|
-
# we have to be be opinionated here
|
45
|
-
# so semantic versioning (vX.Y.Z) it is for us
|
46
|
-
# as well as support for skipping the leading v letter
|
47
|
-
tags = remote_refs['tags'].keys
|
48
|
-
latest_tag = tags.map do |tag|
|
49
|
-
begin
|
50
|
-
Semverse::Version.new tag[/\Av?(.*)\Z/, 1]
|
51
|
-
rescue Semverse::InvalidVersionFormat
|
52
|
-
# ignore tags that do not comply to semver
|
53
|
-
nil
|
54
|
-
end
|
55
|
-
end.select { |tag| !tag.nil? }.sort.last.to_s.downcase
|
56
|
-
latest_ref = tags.detect { |tag| tag[/\Av?(.*)\Z/, 1] == latest_tag }
|
57
|
-
latest_ref = 'undef (tags do not match semantic versioning)' if latest_ref.nil?
|
58
|
-
elsif ref.match(/^[a-z0-9]{40}$/)
|
59
|
-
# for sha just assume head should be tracked
|
60
|
-
latest_ref = remote_refs['head'][:sha]
|
61
|
-
else
|
62
|
-
raise "Unable to determine ref type for #{puppet_module.title}"
|
158
|
+
forge_mods = puppetfile.modules.find_all { |mod| mod.instance_of?(R10K::Module::Forge) && mod.v3_module.homepage_url? }
|
159
|
+
|
160
|
+
threads = forge_mods.map do |mod|
|
161
|
+
Thread.new do
|
162
|
+
source_url = mod.v3_module.attributes.dig(:current_release, :metadata, :source) || mod.v3_module.homepage_url
|
163
|
+
# git:// does not work with ls-remote command, convert to https
|
164
|
+
source_url = source_url.gsub('git://', 'https://')
|
165
|
+
source_url = source_url.gsub(/\Agit\@(.*)\:(.*)/) do
|
166
|
+
"https://#{$1}/#{$2}"
|
63
167
|
end
|
168
|
+
repo = ::Ra10ke::GitRepo.new(source_url)
|
169
|
+
ref = repo.get_ref_like(mod.expected_version)
|
170
|
+
ref_name = ref ? ref[:name] : "bad url or tag #{mod.expected_version} is missing"
|
171
|
+
<<~EOF
|
172
|
+
mod '#{mod.name}',
|
173
|
+
:git => '#{source_url}',
|
174
|
+
:ref => '#{ref_name}'
|
64
175
|
|
65
|
-
|
176
|
+
EOF
|
66
177
|
end
|
67
178
|
end
|
179
|
+
output = threads.map { |th| th.join.value }
|
180
|
+
puts output
|
68
181
|
end
|
182
|
+
end
|
69
183
|
|
184
|
+
def define_task_dependencies(*_args)
|
185
|
+
desc "Print outdated forge modules"
|
186
|
+
task :dependencies do
|
187
|
+
PuppetForge.user_agent = "ra10ke/#{Ra10ke::VERSION}"
|
188
|
+
puppetfile = get_puppetfile
|
189
|
+
PuppetForge.host = puppetfile.forge if puppetfile.forge =~ /^http/
|
190
|
+
dependencies = Ra10ke::Dependencies::Verification.new(puppetfile)
|
191
|
+
dependencies.print_table(dependencies.outdated)
|
192
|
+
end
|
70
193
|
end
|
71
194
|
end
|