Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to using API v3 #102

Merged
merged 1 commit into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,8 @@ source specified. This command writes the complete resolution into
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; ignored for official Puppet Forge
$ librarian-puppet install --no-use-v1-api # use the v3 API; default for official Puppet Forge

Please note that this does not apply for the official Puppet Forge, where v3 is used by default.
$ librarian-puppet install --use-v1-api # use the v1 API
$ librarian-puppet install --no-use-v1-api # use the v3 API; this is the default

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

Expand Down
10 changes: 5 additions & 5 deletions features/install/forge.feature
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Feature: cli/install/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"
forge "http://127.0.0.1:8080"

mod 'tester/tester', :path => './tester-tester'
"""
Expand All @@ -276,12 +276,12 @@ Feature: cli/install/forge
"summary": "Just our own test",
"license": "MIT",
"dependencies": [
{ "name": "puppetlabs/inifile" },
{ "name": "tester/tester_dependency1" }
{ "name": "puppetlabs/inifile" }
]
}
"""

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"
And the output should not contain "puppetlabs.com"
And the output should not contain "puppet.com"
And the output should contain "Resolving puppetlabs-inifile (>= 0) <http://127.0.0.1:8080>"
4 changes: 2 additions & 2 deletions lib/librarian/puppet/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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
option "use-v1-api", :type => :boolean, :default => false
def install

ensure!
Expand All @@ -73,7 +73,7 @@ def install
desc "update", "Updates and installs the dependencies you specify."
option "verbose", :type => :boolean, :default => false
option "line-numbers", :type => :boolean, :default => false
option "use-v1-api", :type => :boolean, :default => true
option "use-v1-api", :type => :boolean, :default => false
def update(*names)

environment.config_db.local['use-v1-api'] = options['use-v1-api'] ? '1' : nil
Expand Down
2 changes: 1 addition & 1 deletion lib/librarian/puppet/source/forge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def repo(name)
unless @repo[name]
# If we are using the official Forge then use API v3, otherwise use the preferred api
# as defined by the CLI option use_v1_api
if uri.hostname =~ /\.puppetlabs\.com$/ || !environment.use_v1_api
if !environment.use_v1_api
@repo[name] = RepoV3.new(self, name)
else
@repo[name] = RepoV1.new(self, name)
Expand Down