Skip to content

Commit

Permalink
Add default transport to push if not provided
Browse files Browse the repository at this point in the history
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #260
Approved by: rhatdan
  • Loading branch information
TomSweeneyRedHat authored and rh-atomic-bot committed Sep 21, 2017
1 parent c19c8f9 commit 1d0b48d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
13 changes: 12 additions & 1 deletion cmd/buildah/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,20 @@ func pushCmd(c *cli.Context) error {
if err != nil {
return err
}

dest, err := alltransports.ParseImageName(destSpec)
// add the docker:// transport to see if they neglected it.
if err != nil {
return err
if strings.Contains(destSpec, "://") {
return err
}

destSpec = "docker://" + destSpec
dest2, err2 := alltransports.ParseImageName(destSpec)
if err2 != nil {
return err
}
dest = dest2
}

systemContext, err := systemContextFromOptions(c)
Expand Down
9 changes: 5 additions & 4 deletions tests/test_buildah_authentication.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
########
# Create creds and store in /root/auth/htpasswd
########
docker run --entrypoint htpasswd registry:2 -Bbn testuser testpassword > /root/auth/htpasswd
registry=$(buildah from registry:2)
buildah run $registry -- htpasswd -Bbn testuser testpassword > /root/auth/htpasswd

########
# Create certificate via openssl
Expand Down Expand Up @@ -93,12 +94,12 @@ docker logout localhost:5000
buildah push --cert-dir /root/auth --tls-verify=true alpine docker://localhost:5000/my-alpine

########
# Push using creds and certs, this should work.
# Push using creds, certs and no transport, this should work.
########
buildah push --cert-dir ~/auth --tls-verify=true --creds=testuser:testpassword alpine docker://localhost:5000/my-alpine
buildah push --cert-dir ~/auth --tls-verify=true --creds=testuser:testpassword alpine localhost:5000/my-alpine

########
# This should fail, no creds anywhere, only the certificate
# No creds anywhere, only the certificate, this should fail.
########
buildah from localhost:5000/my-alpine --cert-dir /root/auth --tls-verify=true

Expand Down

0 comments on commit 1d0b48d

Please sign in to comment.