Skip to content

Commit

Permalink
Merge branch 'master' into 1.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Sanchez committed Aug 1, 2014
2 parents c2dbedc + de155b2 commit e7a635e
Show file tree
Hide file tree
Showing 9 changed files with 156 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### 1.2.0

* Implement `metadata` syntax for `Puppetfile`
* [Issue #220](https://github.com/rodjek/librarian-puppet/issues/220) Add support for metadata.json
* [Issue #242](https://github.com/rodjek/librarian-puppet/issues/242) Get organization from name correctly if name has multiple dashes

Expand Down Expand Up @@ -33,6 +34,7 @@

### 1.0.6

* Implement `metadata` syntax for `Puppetfile`
* [Issue #220](https://github.com/rodjek/librarian-puppet/issues/220) Add support for metadata.json
* [Issue #242](https://github.com/rodjek/librarian-puppet/issues/242) Get organization from name correctly if name has multiple dashes

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ librarian-puppet to manage the puppet modules your infrastructure depends on,
whether the modules come from the [Puppet Forge](https://forge.puppetlabs.com/),
Git repositories or a just a path.

* Librarian-puppet can reuse the dependencies listed in your Modulefile
* Librarian-puppet can reuse the dependencies listed in your `Modulefile` or `metadata.json`
* Forge modules can be installed from [Puppetlabs Forge](https://forge.puppetlabs.com/) or an internal Forge such as [Pulp](http://www.pulpproject.org/)
* Git modules can be installed from a branch, tag or specific commit, optionally using a path inside the repository
* Modules can be installed from GitHub using tarballs, without needing Git installed
Expand Down Expand Up @@ -70,7 +70,7 @@ This Puppetfile will download all the dependencies listed in your Modulefile fro
### Recursive module dependency resolution

When fetching a module all dependencies specified in its
`Modulefile` and `Puppetfile` will be resolved and installed.
`Modulefile`, `metadata.json` and `Puppetfile` will be resolved and installed.

### Puppetfile Breakdown

Expand Down
3 changes: 3 additions & 0 deletions features/examples/metadata_syntax/Puppetfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
forge 'http://forge.puppetlabs.com'

metadata
1 change: 1 addition & 0 deletions features/examples/metadata_syntax/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class test {}
103 changes: 103 additions & 0 deletions features/examples/metadata_syntax/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
{
"operatingsystem_support": [
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"4",
"5",
"6"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"4",
"5",
"6"
]
},
{
"operatingsystem": "OracleLinux",
"operatingsystemrelease": [
"4",
"5",
"6"
]
},
{
"operatingsystem": "Scientific",
"operatingsystemrelease": [
"4",
"5",
"6"
]
},
{
"operatingsystem": "SLES",
"operatingsystemrelease": [
"11 SP1"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"10.04",
"12.04"
]
},
{
"operatingsystem": "Solaris",
"operatingsystemrelease": [
"10",
"11"
]
},
{
"operatingsystem": "Windows",
"operatingsystemrelease": [
"Server 2003",
"Server 2003 R2",
"Server 2008",
"Server 2008 R2",
"Server 2012",
"Server 2012 R2",
"7",
"8"
]
},
{
"operatingsystem": "AIX",
"operatingsystemrelease": [
"5.3",
"6.1",
"7.1"
]
}
],
"requirements": [
{
"name": "pe",
"version_requirement": "3.2.x"
},
{
"name": "puppet",
"version_requirement": ">=2.7.20 <4.0.0"
}
],
"name": "librarian-metadata_syntax",
"version": "0.0.1",
"license": "Apache 2.0",
"dependencies": [
{
"name": "maestrodev/test",
"version_requirement": ">= 0.0.1"
}
]
}
23 changes: 23 additions & 0 deletions features/install/forge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,29 @@ Feature: cli/install/forge
Then the exit status should be 0
And the file "modules/postgresql/Modulefile" should match /name *'puppetlabs-postgresql'/

Scenario: Source dependencies from metadata.json
Given a file named "Puppetfile" with:
"""
forge "http://forge.puppetlabs.com"
metadata
"""
And a file named "metadata.json" with:
"""
{
"name": "random name",
"dependencies": [
{
"name": "puppetlabs/postgresql",
"version_requirement": "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'/

Scenario: Source dependencies from Modulefile using dash instead of slash
Given a file named "Puppetfile" with:
"""
Expand Down
10 changes: 10 additions & 0 deletions features/install/git.feature
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ Feature: cli/install/git
And the file "modules/modulefile_syntax/Modulefile" should match /name *'librarian-modulefile_syntax'/
And the file "modules/test/Modulefile" should match /name *'maestrodev-test'/

Scenario: Install a module using metadata syntax
Given a file named "Puppetfile" with:
"""
mod 'librarian/metadata_syntax', :git => 'https://github.com/rodjek/librarian-puppet.git', :path => 'features/examples/metadata_syntax'
"""
When I run `librarian-puppet install`
Then the exit status should be 0
And the file "modules/metadata_syntax/metadata.json" should match /"name": "librarian-metadata_syntax"/
And the file "modules/test/Modulefile" should match /name *'maestrodev-test'/

Scenario: Install a module from git and using path
Given a file named "Puppetfile" with:
"""
Expand Down
8 changes: 8 additions & 0 deletions lib/librarian/puppet/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ def modulefile
regexp =~ line && mod($2, $4)
end
end

# implement the 'metadata' syntax for Puppetfile
def metadata
dependencyList = JSON.parse(File.read(Pathname.new(specfile).parent.join('metadata.json')))['dependencies']
dependencyList.each do |d|
mod(d['name'], d['version_requirement'])
end
end
end
end
end
Expand Down
5 changes: 4 additions & 1 deletion lib/librarian/puppet/templates/Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@

forge "https://forgeapi.puppetlabs.com"

# use dependencies defined in metadata.json
metadata

# use dependencies defined in Modulefile
modulefile
# modulefile

# A module from the Puppet Forge
# mod 'puppetlabs-stdlib'
Expand Down

0 comments on commit e7a635e

Please sign in to comment.