[DRE-commits] [librarian-puppet] 79/153: Fix #272 Defined forge is not used when resolving dependencies

Stig Sandbeck Mathisen ssm at debian.org
Wed Jun 1 20:30:45 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 7949d81f1575b2823d1960524f64c41ee421b43a
Author: Carlos Sanchez <carlos at apache.org>
Date:   Wed Dec 3 12:03:18 2014 +0100

    Fix #272 Defined forge is not used when resolving dependencies
    
    Puppet Forge is always used
---
 Changelog.md                         |  2 ++
 features/install/forge.feature       | 11 +++++------
 lib/librarian/puppet/dsl.rb          |  8 +++++++-
 lib/librarian/puppet/source/forge.rb |  8 ++++++++
 lib/librarian/puppet/source/local.rb |  2 +-
 5 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/Changelog.md b/Changelog.md
index f132263..3a76dc5 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -4,6 +4,7 @@
 
 ### 2.1.0
 
+ * [Issue #272](https://github.com/rodjek/librarian-puppet/issues/272) Defined forge is not used when resolving dependencies
  * [Issue #150](https://github.com/rodjek/librarian-puppet/issues/150) Allow dependencies other than Puppet modules
  * [Issue #269](https://github.com/rodjek/librarian-puppet/issues/269) Better error message if metadata.json is bad
  * [Issue #264](https://github.com/rodjek/librarian-puppet/issues/264) Copying files can cause permission problems on Windows
@@ -17,6 +18,7 @@
 
 ### 1.5.0
 
+ * [Issue #272](https://github.com/rodjek/librarian-puppet/issues/272) Defined forge is not used when resolving dependencies
  * [Issue #150](https://github.com/rodjek/librarian-puppet/issues/150) Allow dependencies other than Puppet modules
  * [Issue #269](https://github.com/rodjek/librarian-puppet/issues/269) Better error message if metadata.json is bad
  * [Issue #264](https://github.com/rodjek/librarian-puppet/issues/264) Copying files can cause permission problems on Windows
diff --git a/features/install/forge.feature b/features/install/forge.feature
index 198bcaa..757aae8 100644
--- a/features/install/forge.feature
+++ b/features/install/forge.feature
@@ -250,14 +250,13 @@ Feature: cli/install/forge
     And the file "modules/collectd/Modulefile" should match /name *'pdxcat-collectd'/
     And the file "modules/stdlib/metadata.json" should match /"name": "puppetlabs-stdlib"/
 
- at other-forge
+  @other-forge
   Scenario: Installing from another forge with local reference should not try to download anything from the official forge
     Given a file named "Puppetfile" with:
     """
     forge "http://127.0.0.1"
 
-    mod 'tester/tester',
-      :path => './tester-tester'
+    mod 'tester/tester', :path => './tester-tester'
     """
     And a file named "tester-tester/metadata.json" with:
     """
@@ -271,9 +270,9 @@ Feature: cli/install/forge
             { "name": "puppetlabs/inifile" },
             { "name": "tester/tester_dependency1" }
         ]
-    }    
+    }
     """
 
-    When I run `librarian-puppet install`
-    Then the exit status should be 1
+    When I run `librarian-puppet install --verbose`
     And the output should not contain "forgeapi.puppetlabs.com"
+    And the output should contain "Querying Forge API for module puppetlabs-inifile: http://127.0.0.1/api/v1/releases.json?module=puppetlabs/inifile"
diff --git a/lib/librarian/puppet/dsl.rb b/lib/librarian/puppet/dsl.rb
index 771f6a6..27c378b 100644
--- a/lib/librarian/puppet/dsl.rb
+++ b/lib/librarian/puppet/dsl.rb
@@ -6,6 +6,8 @@ module Librarian
   module Puppet
     class Dsl < Librarian::Dsl
 
+      FORGE_URL = "https://forgeapi.puppetlabs.com"
+
       dependency :mod
 
       source :forge => Source::Forge
@@ -20,7 +22,7 @@ module Librarian
         if specfile.kind_of?(Pathname) and !File.exists?(specfile)
           debug { "Specfile not found, using defaults: #{specfile}" }
           specfile = Proc.new do
-            forge "https://forgeapi.puppetlabs.com"
+            forge FORGE_URL
             metadata
           end
         end
@@ -33,6 +35,10 @@ module Librarian
           receiver = Receiver.new(target)
           receiver.run(specfile)
 
+          # save the default forge defined
+          default_forge = target.sources.select {|s| s.is_a? Librarian::Puppet::Source::Forge}.first
+          Librarian::Puppet::Source::Forge.default = default_forge || Librarian::Puppet::Source::Forge.from_lock_options(environment, :remote => FORGE_URL)
+
           debug_named_source_cache("Post-Cached Sources", target)
         end.to_spec
       end
diff --git a/lib/librarian/puppet/source/forge.rb b/lib/librarian/puppet/source/forge.rb
index 898c129..e6355c7 100644
--- a/lib/librarian/puppet/source/forge.rb
+++ b/lib/librarian/puppet/source/forge.rb
@@ -12,6 +12,14 @@ module Librarian
         class << self
           LOCK_NAME = 'FORGE'
 
+          def default=(source)
+            @@default = source
+          end
+
+          def default
+            @@default
+          end
+
           def lock_name
             LOCK_NAME
           end
diff --git a/lib/librarian/puppet/source/local.rb b/lib/librarian/puppet/source/local.rb
index 84356c9..70e7962 100644
--- a/lib/librarian/puppet/source/local.rb
+++ b/lib/librarian/puppet/source/local.rb
@@ -55,7 +55,7 @@ module Librarian
         end
 
         def forge_source
-          Forge.from_lock_options(environment, :remote => "https://forgeapi.puppetlabs.com")
+          Forge.default
         end
 
         private

-- 
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