librarian-puppet 1.1.3 → 1.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
  SHA1:
3
- metadata.gz: 65da3b51c58c415edbe7148801d7eccd40232fb1
4
- data.tar.gz: fa243fef1a099850e0620c79f814561822735b6c
3
+ metadata.gz: 9e38c81fc33fcc4e0223be2ce7f705a93f3f0896
4
+ data.tar.gz: e48f55419ffc8e6fd2df107c08111c35f0c679fa
5
5
  SHA512:
6
- metadata.gz: 719f6605dc5ceb95ea7917683f2cf833a96ab39d0b1ba6ebd61b96c597d718dd56306497d0bc5bb973dfd6fcf706a59fdf26d70fb361efe5d6236405e277bdb4
7
- data.tar.gz: ff64b0efd0c19766d77f27799a900dbc2e5920e15541d3f8d640b6d2d4cc32a1406a3aa21b6be29f4d013a69cc69ba4b8f0ac5a804f2f5798670b729eb7aa07d
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
 
@@ -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
@@ -121,7 +121,7 @@ module Librarian
121
121
  end
122
122
 
123
123
  def install_path(name)
124
- environment.install_path.join(name.split('-').last)
124
+ environment.install_path.join(organization_name(name))
125
125
  end
126
126
 
127
127
  def fetch_version(name, version_uri)
@@ -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.split('-').last)
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"
@@ -98,7 +98,7 @@ module Librarian
98
98
  end
99
99
 
100
100
  def install_path(name)
101
- environment.install_path.join(name.split('-').last)
101
+ environment.install_path.join(organization_name(name))
102
102
  end
103
103
 
104
104
  def fetch_version(name, version_uri)
@@ -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.split('-').last)
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 modulefile?
52
- evaluate_modulefile(modulefile).dependencies.each do |dependency|
53
- dependency_name = dependency.instance_variable_get(:@full_module_name)
54
- version = dependency.instance_variable_get(:@version_requirement)
55
- gem_requirement = Requirement.new(version).gem_requirement
56
- dependencies << Dependency.new(dependency_name, gem_requirement, forge_source)
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
@@ -3,8 +3,11 @@
3
3
 
4
4
  forge "https://forgeapi.puppetlabs.com"
5
5
 
6
+ # use dependencies defined in metadata.json
7
+ metadata
8
+
6
9
  # use dependencies defined in Modulefile
7
- modulefile
10
+ # modulefile
8
11
 
9
12
  # A module from the Puppet Forge
10
13
  # mod 'puppetlabs-stdlib'
@@ -38,6 +38,11 @@ module Librarian
38
38
  def normalize_name(name)
39
39
  name.sub('/','-')
40
40
  end
41
+
42
+ # get the organization name from organization-module
43
+ def organization_name(name)
44
+ name.split('-',2).last
45
+ end
41
46
  end
42
47
  end
43
48
  end
@@ -1,5 +1,5 @@
1
1
  module Librarian
2
2
  module Puppet
3
- VERSION = "1.1.3"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  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.1.3
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-07-22 00:00:00.000000000 Z
12
+ date: 2014-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: librarian