Skip to content

Commit

Permalink
Allow no credentials to be passed to #push.
Browse files Browse the repository at this point in the history
  • Loading branch information
nahiluhmot committed Apr 2, 2014
1 parent fd83ca2 commit 6dbaa1e
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/docker/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def push(creds = nil, options = {})

raise ArgumentError, "Image does not have a name to push." unless repository

credentials = creds || Docker.creds
headers = Docker::Util.build_auth_header(credentials)
creds ||= Docker.creds
headers = creds.nil? ? {} : Docker::Util.build_auth_header(creds)
connection.post(
"/images/#{repository}/push",
options,
Expand Down
11 changes: 11 additions & 0 deletions spec/docker/image_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@
it 'pushes the Image', :vcr do
new_image.push(credentials)
end

context 'when there are no credentials' do
let(:credentials) { nil }

before { Docker.creds = nil }

it 'still pushes', :vcr do
expect { base_image.tag('repo' => 'localhost/base', 'tag' => 'latest') }
.to_not raise_error
end
end
end

describe '#tag' do
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6dbaa1e

Please sign in to comment.