diff --git a/Atomic/push.py b/Atomic/push.py index 4ed5d07..368fe09 100644 --- a/Atomic/push.py +++ b/Atomic/push.py @@ -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() diff --git a/atomic_dbus.py b/atomic_dbus.py index 75ecb7d..ac3f9e0 100755 --- a/atomic_dbus.py +++ b/atomic_dbus.py @@ -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 diff --git a/bash/atomic b/bash/atomic index 8432e80..fc111c5 100644 --- a/bash/atomic +++ b/bash/atomic @@ -431,7 +431,7 @@ _atomic_push() { --verify_ssl --insecure --debug - --all -a + --anonymous --force -f --help " diff --git a/docs/atomic-push.1.md b/docs/atomic-push.1.md index a7a0699..73af86a 100644 --- a/docs/atomic-push.1.md +++ b/docs/atomic-push.1.md @@ -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 diff --git a/tests/integration/test_dbus.py b/tests/integration/test_dbus.py index 31ff1b0..4a857cf 100755 --- a/tests/integration/test_dbus.py +++ b/tests/integration/test_dbus.py @@ -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