Skip to content

Commit

Permalink
Merge pull request #238 from jhaals/jhaals/custom_v3
Browse files Browse the repository at this point in the history
fix #237 add install flag for using the v3 forge api
  • Loading branch information
carlossg committed Jul 22, 2014
2 parents 8249d11 + d5f3dbf commit 5fbeee3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ source specified. This command writes the complete resolution into
`Puppetfile.lock` and then copies all of the fetched modules into your
`modules/` directory, overwriting whatever was there before.

Librarian-puppet support both v1 and v3 of the Puppet Forge API.
Specify a specific API version when installing modules:

$ librarian-puppet install --use-v1-api # this is default
$ librarian-puppet install --no-use-v1-api # use the v3 API

Please note that this does not apply for the official Puppet Forge where v3 is used by default.

Get an overview of your `Puppetfile.lock` with:

$ librarian-puppet show
Expand Down
2 changes: 2 additions & 0 deletions lib/librarian/puppet/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def init
option "path", :type => :string
option "destructive", :type => :boolean, :default => false
option "local", :type => :boolean, :default => false
option "use-v1-api", :type => :boolean, :default => true
def install

unless File.exist?('Puppetfile')
Expand All @@ -64,6 +65,7 @@ def install
environment.config_db.local["path"] = options["path"]
end

environment.config_db.local['use-v1-api'] = options['use-v1-api'] ? '1' : nil
environment.config_db.local['mode'] = options['local'] ? 'local' : nil

resolve!
Expand Down
3 changes: 3 additions & 0 deletions lib/librarian/puppet/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def local?
config_db['mode'] == 'local'
end

def use_v1_api
config_db['use-v1-api']
end
end
end
end
3 changes: 2 additions & 1 deletion lib/librarian/puppet/source/forge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ def manifests(name)

def repo(name)
@repo ||= {}

unless @repo[name]
# if we are using the official Forge then use API v3, otherwise stick to v1 for now
if uri.hostname =~ /\.puppetlabs\.com$/
if uri.hostname =~ /\.puppetlabs\.com$/ || !environment.use_v1_api
@repo[name] = RepoV3.new(self, name)
else
@repo[name] = RepoV1.new(self, name)
Expand Down

0 comments on commit 5fbeee3

Please sign in to comment.