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, resetting to their master
Browse files Browse the repository at this point in the history
Conflicts:
	Changelog.md
	README.md
	Rakefile
	features/install.feature
	features/support/env.rb
	lib/librarian/puppet/extension.rb
	lib/librarian/puppet/source/forge.rb
	lib/librarian/puppet/source/git.rb
	spec/requirement_spec.rb
  • Loading branch information
Carlos Sanchez committed Dec 11, 2013
2 parents dbae23a + 47ffa0a commit 4a2fd15
Show file tree
Hide file tree
Showing 22 changed files with 468 additions and 108 deletions.
14 changes: 14 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
## Changelog

### 0.9.11
* Better sort of githib tarball versions when there are mixed tags starting with and without 'v'
* Add modulefile dsl to reuse Modulefile dependencies
* Fix error if a git module has a dependency without version
* Fix git dependency with :path attribute
* Cleaner output when no Puppetfile found
* Reduce the number of API calls to the Forge
* Don't sort versions as strings. Rely on the forge returning them ordered
* Pass --module_repository to `puppet module install` to install from other forges
* Cache forge responses and print an error if returns an invalid response
* Add a User-Agent header to all requests to the GitHub API
* Convert puppet version requirements to rubygems, pessimistic and ranges
* Use librarian gem

### 0.9.10.1

* Catch GitHub API rate limit exceeded
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Librarian-puppet

[![Build Status](https://travis-ci.org/rodjek/librarian-puppet.png?branch=master)](https://travis-ci.org/rodjek/librarian-puppet)

## Note

This is a fork of [rodjek librarian-puppet](https://github.com/rodjek/librarian-puppet) with
a bunch of fixes submitted as pull requests there.
It is published to rubygems as [librarian-puppet-maestrodev](https://rubygems.org/gems/librarian-puppet-maestrodev)
so you can easily try it.


## Introduction

Librarian-puppet is a bundler for your puppet infrastructure. You can use
Expand All @@ -30,6 +31,15 @@ Every Puppet repository that uses Librarian-puppet will have a file named
`Puppetfile` in the root directory of that repository. The full specification
for which modules your puppet infrastructure repository depends goes in here.

### Simple Puppetfile

This Puppetfile will download all the dependencies listed in your Modulefile from the Puppet Forge

forge "http://forge.puppetlabs.com"

modulefile


### Example Puppetfile

forge "http://forge.puppetlabs.com"
Expand Down
12 changes: 9 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
require 'rake/clean'
require 'bundler/setup'
require 'cucumber/rake/task'
require 'rspec/core/rake_task'
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'rake/clean'

CLEAN.include('pkg/', 'tmp/')
CLOBBER.include('Gemfile.lock')

RSpec::Core::RakeTask.new
Cucumber::Rake::Task.new(:features)

task :default => [:spec, :features]
Rake::TestTask.new do |test|
test.pattern = 'test/**/*_test.rb'
test.verbose = true
end

# Use our custom tag name
module Bundler
Expand All @@ -19,4 +25,4 @@ module Bundler
end
end

require 'bundler/gem_tasks'
task :default => [:test, :spec, :features]
7 changes: 7 additions & 0 deletions features/examples/dependency_without_version/Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name 'librarian-test'
version '0.0.1'

author 'librarian'
license 'Apache License, Version 2.0'

dependency 'puppetlabs/stdlib'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class test {}
7 changes: 7 additions & 0 deletions features/examples/test/Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name 'librarian-test'
version '0.0.1'

author 'librarian'
license 'Apache License, Version 2.0'

dependency 'puppetlabs/stdlib', '>=0'
1 change: 1 addition & 0 deletions features/examples/test/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class test {}
68 changes: 65 additions & 3 deletions features/install.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ Feature: cli/install
In order to be worth anything
Puppet librarian needs to install modules properly

@slow
Scenario: Running install with no Puppetfile
Given there is no Puppetfile
When I run `librarian-puppet install`
Then the output should contain "Could not find Puppetfile"
And the exit status should be 1

@veryslow
Scenario: Installing a module and its dependencies
Given a file named "Puppetfile" with:
"""
Expand All @@ -15,7 +21,7 @@ Feature: cli/install
And the file "modules/apt/Modulefile" should match /name *'puppetlabs-apt'/
And the file "modules/stdlib/Modulefile" should match /name *'puppetlabs-stdlib'/

@slow
@veryveryslow
Scenario: Installing an exact version of a module
Given a file named "Puppetfile" with:
"""
Expand Down Expand Up @@ -167,8 +173,9 @@ 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
Scenario: Install a module with dependencies specified in a Puppetfile
Given a file named "Puppetfile" with:
Given PENDING a file named "Puppetfile" with:
"""
mod 'super', :git => 'git://github.com/mpalmer/puppet-super'
Expand All @@ -189,3 +196,58 @@ Feature: cli/install
When I run `librarian-puppet install`
Then the exit status should be 1
And the output should contain "Could not resolve the dependencies"

@veryslow
Scenario: Install a module from git and using path
Given a file named "Puppetfile" with:
"""
forge "http://forge.puppetlabs.com"
mod 'test', :git => 'https://github.com/rodjek/librarian-puppet.git', :path => 'features/examples/test'
"""
When I run `librarian-puppet install`
Then the exit status should be 0
And the file "modules/test/Modulefile" should match /version *'0\.0\.1'/
And a file named "modules/stdlib/Modulefile" should exist

@slow
Scenario: Install a module from the Forge with dependencies without version
Given a file named "Puppetfile" with:
"""
forge "http://forge.puppetlabs.com"
mod 'sbadia/gitlab', '0.1.0'
"""
When I run `librarian-puppet install`
Then the exit status should be 0
And the file "modules/gitlab/Modulefile" should match /version *'0\.1\.0'/

@veryslow
Scenario: Install a module from git without version
Given a file named "Puppetfile" with:
"""
forge "http://forge.puppetlabs.com"
mod 'test', :git => 'https://github.com/rodjek/librarian-puppet.git', :path => 'features/examples/dependency_without_version'
"""
When I run `librarian-puppet install`
Then the exit status should be 0
And the file "modules/test/Modulefile" should match /version *'0\.0\.1'/
And a file named "modules/stdlib/Modulefile" should exist

@veryslow
Scenario: Source dependencies from Modulefile
Given a file named "Puppetfile" with:
"""
forge "http://forge.puppetlabs.com"
modulefile
"""
And a file named "Modulefile" with:
"""
name "random name"
dependency "puppetlabs/postgresql", "2.4.1"
"""
When I run `librarian-puppet install`
Then the exit status should be 0
And the file "modules/postgresql/Modulefile" should match /name *'puppetlabs-postgresql'/
16 changes: 14 additions & 2 deletions features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,21 @@
end

Before('@slow') do
@aruba_timeout_seconds = 25
@aruba_timeout_seconds = 30
end

Before('@veryslow') do
@aruba_timeout_seconds = 50
@aruba_timeout_seconds = 60
end

Before('@veryveryslow') do
@aruba_timeout_seconds = 90
end

Given /^PENDING/ do |x|
pending
end

Given(/^there is no Puppetfile$/) do
fail if (File.exist?('Puppetfile'))
end
6 changes: 6 additions & 0 deletions lib/librarian/puppet/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ def init
option "destructive", :type => :boolean, :default => false
option "local", :type => :boolean, :default => false
def install

unless File.exist?('Puppetfile')
say "Could not find Puppetfile in #{Dir.pwd}", :red
exit 1
end

ensure!
clean! if options["clean"]
unless options["destructive"].nil?
Expand Down
13 changes: 13 additions & 0 deletions lib/librarian/puppet/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,16 @@ class Dsl < Librarian::Dsl
end
end
end

module Librarian
class Dsl
class Receiver
def modulefile
File.read('Modulefile').lines.each do |line|
regexp = /\s*dependency\s+('|")([^'"]+)\1\s*(?:,\s*('|")([^'"]+)\3)?/
regexp =~ line && mod($2, $4)
end
end
end
end
end
Loading

0 comments on commit 4a2fd15

Please sign in to comment.