def repo_creds(username, encrypted_password, has_pass):
"""Get a representation of the container repository credentials"""
from azure.servicefabric.models import RegistryCredential
from getpass import getpass
# Wonky since we allow empty string as an encrypted passphrase
if not any([username, encrypted_password is not None, has_pass]):
return None
if (encrypted_password is not None) and (not username):
raise CLIError('Missing container repository username')
if has_pass and (not username):
raise CLIError('Missing container repository username')
if encrypted_password is not None:
return RegistryCredential(registry_user_name=username,
registry_password=encrypted_password,
password_encrypted=True)
elif has_pass:
passphrase = getpass(prompt='Container repository password: ')
return RegistryCredential(registry_user_name=username,
registry_password=passphrase,
password_encrypted=False)
return RegistryCredential(registry_user_name=username)
评论列表
文章目录