librarian-puppet 1.0.5 → 1.0.6

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: 00ea6603b1c515215bb1f55bccc63bb1cc9a43fa
4
- data.tar.gz: 369d915e3047152dac00490e1a80234bd80e1f61
3
+ metadata.gz: 6f2563b5575e2082f80e0b75f8b1ece49f070a8a
4
+ data.tar.gz: c37295903ceab4b3406d28f3f90537cd2efa20a1
5
5
  SHA512:
6
- metadata.gz: 34438184c66b52a657452b3980715830e66afa94f26329785ac4d6de0e0de6f293b8e42c054264569872f56874aeb02a865d3652196049e4e716d96c10cb8d36
7
- data.tar.gz: c06ea15a7cd05b84193ea63703c2c7ee56cb52da1b5fa8816ccda61dfc45a1842ced0806a1f864cf805bc8a93a8b06e8157e3f588eb8cffb6785330e285e3473
6
+ metadata.gz: 7c9a691b88c4813bc4dc9d90011bc194f8ccf3452ca21eb79359a95652294d049b238b955b3d6fd9fc0f13eebf44ac9e698d60621e683a29675675a20b11c9e6
7
+ data.tar.gz: 28e9ee98ba396f257dbf233550bc5983c335fe1d85da95e1d5d3621770ef904925b86654c833253dafd446f41a98ebd54e1b5f8457d1e135b7a775e4b2ae9a3d
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.0.5"
3
+ VERSION = "1.0.6"
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.0.5
4
+ version: 1.0.6
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