1
0
mirror of https://github.com/projectatomic/atomic.git synced 2026-02-05 18:45:01 +01:00

Allow anonymous push

Added an --anonymous switch to the push command to allow users
to push anonymously without having to be prompted for a username
and password.

Closes: #964
Approved by: rhatdan
This commit is contained in:
Brent Baude
2017-04-12 09:19:23 -05:00
committed by Atomic Bot
parent 2b744bfdbb
commit 9525bfefa0
5 changed files with 19 additions and 9 deletions

View File

@@ -19,6 +19,10 @@ def cli(subparser):
"push", aliases=['upload'], help=_("push latest image to repository"),
epilog="push the latest specified image to a repository.")
pushp.set_defaults(_class=Push, func='push')
pushp.add_argument("--anonymous",
default=False,
action="store_true",
help=_("Push images without a username or password"))
# making it so we cannot call both the --pulp and --satellite commands
# at the same time (mutually exclusive)
pushgroup = pushp.add_mutually_exclusive_group()
@@ -165,7 +169,7 @@ class Push(Atomic):
else:
reg, _, _, tag, _ = util.Decompose(self.image).all
# Check if any local tokens exist
if reg not in [x for x in self.get_local_tokens()]:
if reg not in [x for x in self.get_local_tokens()] and not self.args.anonymous:
# If we find a token for the registry, we don't
# prompt for a username or password
prompt()

View File

@@ -47,6 +47,7 @@ class atomic_dbus(slip.dbus.service.Object):
self.all = False
self.args = []
self.assumeyes = True
self.anonymous = False
self.command = []
self.compares = []
self.container = False
@@ -300,9 +301,9 @@ class atomic_dbus(slip.dbus.service.Object):
# The ImagePush method will push the specific image to a registry
@slip.dbus.polkit.require_auth("org.atomic.readwrite")
@dbus.service.method("org.atomic", in_signature='sbbbssssssssb', out_signature='i')
@dbus.service.method("org.atomic", in_signature='sbbbssssssssbb', out_signature='i')
def ImagePush(self, image, pulp, satellite, verify_ssl, url, username, password,
activation_key, repo_id, registry_type, sign_by, gnupghome, insecure):
activation_key, repo_id, registry_type, sign_by, gnupghome, insecure, anonymous):
p = Push()
args = self.Args()
args.image = image
@@ -310,6 +311,7 @@ class atomic_dbus(slip.dbus.service.Object):
args.satellite = satellite
args.verify_ssl = verify_ssl
args.insecure = insecure
args.anonymous = anonymous
args.url = None if not url else url
args.username = None if not username else username
args.password = None if not password else password

View File

@@ -431,7 +431,7 @@ _atomic_push() {
--verify_ssl
--insecure
--debug
--all -a
--anonymous
--force -f
--help
"

View File

@@ -7,6 +7,7 @@ atomic-push - push Image to repository
# SYNOPSIS
**atomic push**
[**-a**][**--activation_key**[=*ACTIVATION_KEY*]]
[**--anonymous**]
[**--debug**]
[**-h**|**--help**]
[**--insecure**]
@@ -27,6 +28,9 @@ atomic-push - push Image to repository
**-a ACTIVATION_KEY** **--activation_key ACTIVATION_KEY**
Activation Key
**--anonymous**
Push without a username or password
**--debug**
Debug mode

View File

@@ -162,13 +162,13 @@ class TestDBus():
TestDBus.add_cleanup_cmd('docker rmi docker.io/library/registry:2')
TestDBus.add_cleanup_cmd('docker rmi docker.io/alpine:latest')
TestDBus.add_cleanup_cmd('docker rmi localhost:5000/alpine:latest')
results = self.dbus_object.ImagePush("localhost:5000/alpine:latest", False, False, False, "", "foo", "bar", "", "", "", "", "", True)
results = self.dbus_object.ImagePush("localhost:5000/alpine:latest", False, False, False, "", "foo", "bar", "", "", "", "", "", True, False)
assert(results == 0)
@integration_test
def test_push_no_password(self):
try:
self.dbus_object.ImagePush("localhost:5000/alpine:latest", False, False, False, "", "foo", "", "", "", "", "", "", True)
self.dbus_object.ImagePush("localhost:5000/alpine:latest", False, False, False, "", "foo", "", "", "", "", "", "", True, False)
raise ValueError("Expected an exception to be raised and was not.")
except dbus.DBusException:
pass
@@ -176,7 +176,7 @@ class TestDBus():
@integration_test
def test_push_no_username(self):
try:
self.dbus_object.ImagePush("localhost:5000/alpine:latest", False, False, False, "", "", "", "", "", "", "", "", True)
self.dbus_object.ImagePush("localhost:5000/alpine:latest", False, False, False, "", "", "", "", "", "", "", "", True, False)
raise ValueError("Expected an exception to be raised and was not.")
except dbus.DBusException:
pass
@@ -184,7 +184,7 @@ class TestDBus():
@integration_test
def test_push_pulp_no_username(self):
try:
self.dbus_object.ImagePush("localhost:5000/alpine:latest", True, False, False, "url", "", "", "", "", "", "", "", True)
self.dbus_object.ImagePush("localhost:5000/alpine:latest", True, False, False, "url", "", "", "", "", "", "", "", True, False)
raise ValueError("Expected an exception to be raised and was not.")
except dbus.DBusException:
pass
@@ -192,7 +192,7 @@ class TestDBus():
@integration_test
def test_push_pulp_no_url(self):
try:
self.dbus_object.ImagePush("localhost:5000/alpine:latest", True, False, False, "", "foo", "bar", "", "", "", "", "", True)
self.dbus_object.ImagePush("localhost:5000/alpine:latest", True, False, False, "", "foo", "bar", "", "", "", "", "", True, False)
raise ValueError("Expected an exception to be raised and was not.")
except dbus.DBusException:
pass