[DRE-commits] [librarian-puppet] 34/153: Implement metadata syntax for Puppetfile

Stig Sandbeck Mathisen ssm at debian.org
Wed Jun 1 20:30:37 UTC 2016


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository librarian-puppet.

commit 5bfe9a753f452271929c6dca67f9c72bfc4ef556
Author: Carlos Sanchez <csanchez at maestrodev.com>
Date:   Fri Aug 1 14:32:18 2014 +0200

    Implement metadata syntax for Puppetfile
---
 Changelog.md                                       |   2 +
 README.md                                          |   4 +-
 features/examples/metadata_syntax/Puppetfile       |   3 +
 .../examples/metadata_syntax/manifests/init.pp     |   1 +
 features/examples/metadata_syntax/metadata.json    | 103 +++++++++++++++++++++
 features/install/forge.feature                     |  23 +++++
 features/install/git.feature                       |  10 ++
 lib/librarian/puppet/dsl.rb                        |   8 ++
 8 files changed, 152 insertions(+), 2 deletions(-)

diff --git a/Changelog.md b/Changelog.md
index 753cb77..fb27ac4 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -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
 
@@ -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
 
diff --git a/README.md b/README.md
index 6c3d6cc..c46733d 100644
--- a/README.md
+++ b/README.md
@@ -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
@@ -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
 
diff --git a/features/examples/metadata_syntax/Puppetfile b/features/examples/metadata_syntax/Puppetfile
new file mode 100644
index 0000000..2303f7e
--- /dev/null
+++ b/features/examples/metadata_syntax/Puppetfile
@@ -0,0 +1,3 @@
+forge 'http://forge.puppetlabs.com'
+
+metadata
diff --git a/features/examples/metadata_syntax/manifests/init.pp b/features/examples/metadata_syntax/manifests/init.pp
new file mode 100644
index 0000000..e2be432
--- /dev/null
+++ b/features/examples/metadata_syntax/manifests/init.pp
@@ -0,0 +1 @@
+class test {}
diff --git a/features/examples/metadata_syntax/metadata.json b/features/examples/metadata_syntax/metadata.json
new file mode 100644
index 0000000..67300b5
--- /dev/null
+++ b/features/examples/metadata_syntax/metadata.json
@@ -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"
+    }
+  ]
+}
diff --git a/features/install/forge.feature b/features/install/forge.feature
index 8f80ef3..8cc2098 100644
--- a/features/install/forge.feature
+++ b/features/install/forge.feature
@@ -161,6 +161,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:
     """
diff --git a/features/install/git.feature b/features/install/git.feature
index 7696336..90731f4 100644
--- a/features/install/git.feature
+++ b/features/install/git.feature
@@ -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/modulefile_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/Modulefile" 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:
     """
diff --git a/lib/librarian/puppet/dsl.rb b/lib/librarian/puppet/dsl.rb
index e0dcc4c..3f84c10 100644
--- a/lib/librarian/puppet/dsl.rb
+++ b/lib/librarian/puppet/dsl.rb
@@ -45,6 +45,14 @@ module Librarian
             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

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/librarian-puppet.git



More information about the Pkg-ruby-extras-commits mailing list