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

Add default transport to push if not provided #260

Closed
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
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