Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into maestrodev
Browse files Browse the repository at this point in the history
Conflicts:
	.travis.yml
  • Loading branch information
Carlos Sanchez committed Jan 3, 2014
2 parents 3a7aa1c + 5effc62 commit dd79293
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 32 deletions.
17 changes: 9 additions & 8 deletions .travis.yml
@@ -1,18 +1,19 @@
rvm:
- 1.9.2
- 1.8.7
- 1.9.3
notifications:
email:
- support@maestrodev.com
env:
- PUPPET_VERSION=2.6.18
- PUPPET_VERSION=2.7.23
- PUPPET_VERSION=3.0.2
- PUPPET_VERSION=3.1.1
- PUPPET_VERSION=3.2.4
matrix:
exclude:
- rvm: 1.9.2
env: PUPPET_VERSION=2.6.18
- rvm: 1.9.3
env: PUPPET_VERSION=2.6.18
- PUPPET_VERSION=3.3.2
- PUPPET_VERSION=3.4.1

before_install:
- gem update --system 2.1.11 # todo: workaround for https://github.com/rubygems/rubygems/pull/763

before_script:
- bundle list
1 change: 1 addition & 0 deletions Changelog.md
Expand Up @@ -13,6 +13,7 @@
* Add a User-Agent header to all requests to the GitHub API
* Convert puppet version requirements to rubygems, pessimistic and ranges
* Use librarian gem
* Consider Puppetfile-dependencies recursively in git-source

### 0.9.10.1

Expand Down
5 changes: 5 additions & 0 deletions README.md
Expand Up @@ -54,6 +54,11 @@ This Puppetfile will download all the dependencies listed in your Modulefile fro
*See [jenkins-appliance](https://github.com/aussielunix/jenkins-appliance) for
a puppet repo already setup to use librarian-puppet.*

### Recursive module dependency resolving

When fetching a module from a `:git`-source all dependencies specified in its
`Modulefile` and `Puppetfile` will be resolved and installed.

### Puppetfile Breakdown

forge "http://forge.puppetlabs.com"
Expand Down
5 changes: 5 additions & 0 deletions features/examples/with_puppetfile/Modulefile
@@ -0,0 +1,5 @@
name 'with-puppetfile'
version '0.0.1'

author 'librarian'
license 'Apache License, Version 2.0'
1 change: 1 addition & 0 deletions features/examples/with_puppetfile/Puppetfile
@@ -0,0 +1 @@
mod 'test', :git => 'https://github.com/rodjek/librarian-puppet.git', :path => 'features/examples/test'
1 change: 1 addition & 0 deletions features/examples/with_puppetfile/manifests/init.pp
@@ -0,0 +1 @@
class test {}
11 changes: 5 additions & 6 deletions features/install.feature
Expand Up @@ -173,17 +173,16 @@ Feature: cli/install
Then the exit status should be 1
And the output should contain "Unable to find module 'puppetlabs/xxxxx' on http://forge.puppetlabs.com"

@pending
@slow
Scenario: Install a module with dependencies specified in a Puppetfile
Given PENDING a file named "Puppetfile" with:
Given a file named "Puppetfile" with:
"""
mod 'super', :git => 'git://github.com/mpalmer/puppet-super'
mod 'with_puppetfile', :git => 'https://github.com/rodjek/librarian-puppet.git', :path => 'features/examples/with_puppetfile'
"""
When I run `librarian-puppet install`
Then the exit status should be 0
And the file "modules/super/Puppetfile" should match /mod *'sub'/
And the file "Puppetfile.lock" should match /remote: git:..github\.com.mpalmer.puppet-sub/
And the file "modules/with_puppetfile/Modulefile" should match /name *'with-puppetfile'/
And the file "modules/test/Modulefile" should match /name *'librarian-test'/

Scenario: Install a module with conflicts
Given a file named "Puppetfile" with:
Expand Down
45 changes: 28 additions & 17 deletions lib/librarian/puppet/source/git.rb
Expand Up @@ -67,10 +67,27 @@ def fetch_version(name, extra)
end

def fetch_dependencies(name, version, extra)
dependencies.map do |k, v|
v = Requirement.new(v).gem_requirement
Dependency.new(k, v, forge_source)
dependencies = []

if modulefile?
metadata = ::Puppet::ModuleTool::Metadata.new

::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)

metadata.dependencies.each do |dependency|
name = dependency.instance_variable_get(:@full_module_name)
version = dependency.instance_variable_get(:@version_requirement)
gem_requirement = Requirement.new(version).gem_requirement
dependencies.push Dependency.new(name, gem_requirement, forge_source)
end
end

if specfile?
spec = environment.dsl(Pathname(specfile))
dependencies.concat spec.dependencies
end

dependencies
end

def forge_source
Expand All @@ -89,20 +106,6 @@ def module_version
metadata.version
end

def dependencies
return {} unless modulefile?

metadata = ::Puppet::ModuleTool::Metadata.new

::Puppet::ModuleTool::ModulefileReader.evaluate(metadata, modulefile)

metadata.dependencies.inject({}) do |h, dependency|
name = dependency.instance_variable_get(:@full_module_name)
version = dependency.instance_variable_get(:@version_requirement)
h.update(name => version)
end
end

def modulefile
File.join(filesystem_path, 'Modulefile')
end
Expand All @@ -111,6 +114,14 @@ def modulefile?
File.exists?(modulefile)
end

def specfile
File.join(filesystem_path, environment.specfile_name)
end

def specfile?
File.exists?(specfile)
end

end
end
end
Expand Down
2 changes: 1 addition & 1 deletion librarian-puppet.gemspec
Expand Up @@ -30,7 +30,7 @@ Gem::Specification.new do |s|
s.add_development_dependency "rspec"
s.add_development_dependency "cucumber"
s.add_development_dependency "aruba"
s.add_development_dependency "puppet"
s.add_development_dependency "puppet", ENV["PUPPET_VERSION"]
s.add_development_dependency "minitest", "~> 5"
s.add_development_dependency "mocha"
end

0 comments on commit dd79293

Please sign in to comment.