Skip to content

Commit

Permalink
feat: add password from stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxiao committed Jun 23, 2020
1 parent 6c2c46e commit 1e7d3b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions jina/hubapi/docker.py
Expand Up @@ -82,8 +82,9 @@ def _check_docker_image(self, name: str):

def login(self):
"""A wrapper of docker login """
if self.args.username and self.args.password:
self._client.login(username=self.args.username, password=self.args.password,
password = self.args.password or self.args.password_stdin.read()
if self.args.username and password:
self._client.login(username=self.args.username, password=password,
registry=self.args.registry)
else:
# use default login
Expand Down
9 changes: 7 additions & 2 deletions jina/main/parser.py
Expand Up @@ -55,9 +55,14 @@ def set_logger_parser(parser=None):
def set_hub_base_parser(parser=None):
if not parser:
parser = set_base_parser()

import sys
parser.add_argument('--username', type=str, help='the registry username')
parser.add_argument('--password', type=str, help='the plaintext password')
_gp = parser.add_mutually_exclusive_group()
_gp.add_argument('--password-stdin', type=argparse.FileType('r'), default=(None if sys.stdin.isatty() else sys.stdin),
help='take the password from stdin')
_gp.add_argument('--password', type=str,
default=(None if sys.stdin.isatty() else sys.stdin),
help='the plaintext password')
parser.add_argument('--registry', type=str, default='https://index.docker.io/v1/',
help='the URL to the registry, e.g. https://index.docker.io/v1/')

Expand Down

0 comments on commit 1e7d3b6

Please sign in to comment.