Skip to content

Commit

Permalink
Fix #272 Defined forge is not used when resolving dependencies
Browse files Browse the repository at this point in the history
Puppet Forge is always used
  • Loading branch information
carlossg committed Dec 3, 2014
1 parent 7471095 commit 7949d81
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 8 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 @@

### 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
Expand All @@ -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
Expand Down
11 changes: 5 additions & 6 deletions features/install/forge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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"/

@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:
"""
Expand All @@ -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"
8 changes: 7 additions & 1 deletion lib/librarian/puppet/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module Librarian
module Puppet
class Dsl < Librarian::Dsl

FORGE_URL = "https://forgeapi.puppetlabs.com"

dependency :mod

source :forge => Source::Forge
Expand All @@ -20,7 +22,7 @@ def run(specfile = nil, sources = [])
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
Expand All @@ -33,6 +35,10 @@ def run(specfile = nil, sources = [])
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
Expand Down
8 changes: 8 additions & 0 deletions lib/librarian/puppet/source/forge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ class Forge
class << self
LOCK_NAME = 'FORGE'

def default=(source)
@@default = source
end

def default
@@default
end

def lock_name
LOCK_NAME
end
Expand Down
2 changes: 1 addition & 1 deletion lib/librarian/puppet/source/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def fetch_dependencies(name, version, extra)
end

def forge_source
Forge.from_lock_options(environment, :remote => "https://forgeapi.puppetlabs.com")
Forge.default
end

private
Expand Down

0 comments on commit 7949d81

Please sign in to comment.