librarian-puppet 1.1.3 → 1.2.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/README.md +2 -2
- data/lib/librarian/puppet/dsl.rb +8 -0
- data/lib/librarian/puppet/source/forge.rb +1 -1
- data/lib/librarian/puppet/source/forge/repo.rb +1 -1
- data/lib/librarian/puppet/source/githubtarball.rb +1 -1
- data/lib/librarian/puppet/source/local.rb +39 -18
- data/lib/librarian/puppet/templates/Puppetfile +4 -1
- data/lib/librarian/puppet/util.rb +5 -0
- data/lib/librarian/puppet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e38c81fc33fcc4e0223be2ce7f705a93f3f0896
|
4
|
+
data.tar.gz: e48f55419ffc8e6fd2df107c08111c35f0c679fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9f5ade15b27c5a35eb7ada03313f1da390cc5854d1abfe184041640192bcfcd2e6601b4bdf2cfe21ae65eda5bd912a6bf0286c1c1bd1414e5c364b9b673359d
|
7
|
+
data.tar.gz: 2054b93a68ce5f4a9e64c7bf02a057ce274250737528f97ccaa39c4058dad3828c7c7e59bebea6dc8d3d0dd82a75dbcd0640cf6c3d19201a12031e3bb12003f7
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ librarian-puppet to manage the puppet modules your infrastructure depends on,
|
|
9
9
|
whether the modules come from the [Puppet Forge](https://forge.puppetlabs.com/),
|
10
10
|
Git repositories or a just a path.
|
11
11
|
|
12
|
-
* Librarian-puppet can reuse the dependencies listed in your Modulefile
|
12
|
+
* Librarian-puppet can reuse the dependencies listed in your `Modulefile` or `metadata.json`
|
13
13
|
* Forge modules can be installed from [Puppetlabs Forge](https://forge.puppetlabs.com/) or an internal Forge such as [Pulp](http://www.pulpproject.org/)
|
14
14
|
* Git modules can be installed from a branch, tag or specific commit, optionally using a path inside the repository
|
15
15
|
* Modules can be installed from GitHub using tarballs, without needing Git installed
|
@@ -70,7 +70,7 @@ This Puppetfile will download all the dependencies listed in your Modulefile fro
|
|
70
70
|
### Recursive module dependency resolution
|
71
71
|
|
72
72
|
When fetching a module all dependencies specified in its
|
73
|
-
`Modulefile` and `Puppetfile` will be resolved and installed.
|
73
|
+
`Modulefile`, `metadata.json` and `Puppetfile` will be resolved and installed.
|
74
74
|
|
75
75
|
### Puppetfile Breakdown
|
76
76
|
|
data/lib/librarian/puppet/dsl.rb
CHANGED
@@ -45,6 +45,14 @@ module Librarian
|
|
45
45
|
regexp =~ line && mod($2, $4)
|
46
46
|
end
|
47
47
|
end
|
48
|
+
|
49
|
+
# implement the 'metadata' syntax for Puppetfile
|
50
|
+
def metadata
|
51
|
+
dependencyList = JSON.parse(File.read(Pathname.new(specfile).parent.join('metadata.json')))['dependencies']
|
52
|
+
dependencyList.each do |d|
|
53
|
+
mod(d['name'], d['version_requirement'])
|
54
|
+
end
|
55
|
+
end
|
48
56
|
end
|
49
57
|
end
|
50
58
|
end
|
@@ -59,7 +59,7 @@ module Librarian
|
|
59
59
|
install_path.rmtree
|
60
60
|
end
|
61
61
|
|
62
|
-
unpacked_path = version_unpacked_cache_path(version).join(name
|
62
|
+
unpacked_path = version_unpacked_cache_path(version).join(organization_name(name))
|
63
63
|
|
64
64
|
unless unpacked_path.exist?
|
65
65
|
raise Error, "#{unpacked_path} does not exist, something went wrong. Try removing it manually"
|
@@ -1,16 +1,5 @@
|
|
1
1
|
require 'librarian/puppet/util'
|
2
2
|
|
3
|
-
begin
|
4
|
-
require 'puppet'
|
5
|
-
require 'puppet/module_tool'
|
6
|
-
rescue LoadError
|
7
|
-
$stderr.puts <<-EOF
|
8
|
-
Unable to load puppet, the puppet gem is required for :git and :path source.
|
9
|
-
Install it with: gem install puppet
|
10
|
-
EOF
|
11
|
-
exit 1
|
12
|
-
end
|
13
|
-
|
14
3
|
module Librarian
|
15
4
|
module Puppet
|
16
5
|
module Source
|
@@ -30,7 +19,7 @@ module Librarian
|
|
30
19
|
warn { "Invalid module name '#{name}', you should qualify it with 'ORGANIZATION-#{name}' for resolution to work correctly" }
|
31
20
|
end
|
32
21
|
|
33
|
-
install_path = environment.install_path.join(name
|
22
|
+
install_path = environment.install_path.join(organization_name(name))
|
34
23
|
if install_path.exist?
|
35
24
|
debug { "Deleting #{relative_path_to(install_path)}" }
|
36
25
|
install_path.rmtree
|
@@ -48,13 +37,21 @@ module Librarian
|
|
48
37
|
def fetch_dependencies(name, version, extra)
|
49
38
|
dependencies = Set.new
|
50
39
|
|
51
|
-
if
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
40
|
+
dependencyList = if metadata?
|
41
|
+
JSON.parse(File.read(metadata))['dependencies']
|
42
|
+
elsif modulefile?
|
43
|
+
evaluate_modulefile(modulefile).dependencies.map do |dependency|
|
44
|
+
{
|
45
|
+
'name' => dependency.instance_variable_get(:@full_module_name),
|
46
|
+
'version_requirement' => dependency.instance_variable_get(:@version_requirement)
|
47
|
+
}
|
57
48
|
end
|
49
|
+
else []
|
50
|
+
end
|
51
|
+
|
52
|
+
dependencyList.each do |d|
|
53
|
+
gem_requirement = Requirement.new(d['version_requirement']).gem_requirement
|
54
|
+
dependencies << Dependency.new(d['name'], gem_requirement, forge_source)
|
58
55
|
end
|
59
56
|
|
60
57
|
if specfile?
|
@@ -77,7 +74,23 @@ module Librarian
|
|
77
74
|
evaluate_modulefile(modulefile).version
|
78
75
|
end
|
79
76
|
|
77
|
+
def require_puppet
|
78
|
+
begin
|
79
|
+
require 'puppet'
|
80
|
+
require 'puppet/module_tool'
|
81
|
+
rescue LoadError
|
82
|
+
$stderr.puts <<-EOF
|
83
|
+
Unable to load puppet, the puppet gem is required for :git and :path source.
|
84
|
+
Install it with: gem install puppet
|
85
|
+
EOF
|
86
|
+
exit 1
|
87
|
+
end
|
88
|
+
true
|
89
|
+
end
|
90
|
+
|
80
91
|
def evaluate_modulefile(modulefile)
|
92
|
+
@@require_puppet ||= require_puppet
|
93
|
+
|
81
94
|
metadata = ::Puppet::ModuleTool::Metadata.new
|
82
95
|
begin
|
83
96
|
::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)
|
@@ -100,6 +113,14 @@ module Librarian
|
|
100
113
|
File.exists?(modulefile)
|
101
114
|
end
|
102
115
|
|
116
|
+
def metadata
|
117
|
+
File.join(filesystem_path, 'metadata.json')
|
118
|
+
end
|
119
|
+
|
120
|
+
def metadata?
|
121
|
+
File.exists?(metadata)
|
122
|
+
end
|
123
|
+
|
103
124
|
def specfile
|
104
125
|
File.join(filesystem_path, environment.specfile_name)
|
105
126
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: librarian-puppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Sharpe
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: librarian
|