Fix param names in extension commands (#598)

This commit is contained in:
gauravsaralms 2019-05-17 13:52:31 +05:30 коммит произвёл GitHub
Родитель 155abe9f5e
Коммит 98b51e0211
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 35 добавлений и 25 удалений

Просмотреть файл

@ -133,8 +133,8 @@ def load_team_arguments(self, _):
help='Include built in extensions.')
context.argument('include_disabled', arg_type=get_enum_type(_TRUE_FALSE_SWITCH),
help='Include disabled extensions.')
context.argument('publisher_id', help='Publisher ID')
context.argument('extension_id', help='Extension ID')
context.argument('publisher_name', help='Publisher Name')
context.argument('extension_name', help='Extension Name')
context.argument('search_query', options_list=('--search-query', '-q'), help='Search term')
with self.argument_context('devops') as context:

Просмотреть файл

@ -112,63 +112,63 @@ def list_extensions(include_built_in='true', include_disabled='true', organizati
return extensions
def get_extension(publisher_id, extension_id, organization=None, detect=None):
def get_extension(publisher_name, extension_name, organization=None, detect=None):
""" Get detail of single extension
"""
organization = resolve_instance(detect=detect, organization=organization)
extension_client = get_extension_client(organization)
return extension_client.get_installed_extension_by_name(publisher_name=publisher_id,
extension_name=extension_id)
return extension_client.get_installed_extension_by_name(publisher_name=publisher_name,
extension_name=extension_name)
def install_extension(publisher_id, extension_id, organization=None, detect=None):
def install_extension(publisher_name, extension_name, organization=None, detect=None):
""" Install an extension
"""
organization = resolve_instance(detect=detect, organization=organization)
extension_client = get_extension_client(organization)
return extension_client.install_extension_by_name(publisher_name=publisher_id,
extension_name=extension_id)
return extension_client.install_extension_by_name(publisher_name=publisher_name,
extension_name=extension_name)
def uninstall_extension(publisher_id, extension_id, organization=None, detect=None):
def uninstall_extension(publisher_name, extension_name, organization=None, detect=None):
""" Uninstall an extension
"""
organization = resolve_instance(detect=detect, organization=organization)
extension_client = get_extension_client(organization)
return extension_client.uninstall_extension_by_name(publisher_name=publisher_id,
extension_name=extension_id)
return extension_client.uninstall_extension_by_name(publisher_name=publisher_name,
extension_name=extension_name)
def enable_extension(publisher_id, extension_id, organization=None, detect=None):
def enable_extension(publisher_name, extension_name, organization=None, detect=None):
""" Enable an extension
"""
return _update_extension_state(disable=False,
enable=True,
publisher_id=publisher_id,
extension_id=extension_id,
publisher_name=publisher_name,
extension_name=extension_name,
organization=organization,
detect=detect)
def disable_extension(publisher_id, extension_id, organization=None, detect=None):
def disable_extension(publisher_name, extension_name, organization=None, detect=None):
""" Disable an extension
"""
return _update_extension_state(disable=True,
enable=False,
publisher_id=publisher_id,
extension_id=extension_id,
publisher_name=publisher_name,
extension_name=extension_name,
organization=organization,
detect=detect)
def _update_extension_state(disable, enable,
publisher_id, extension_id,
publisher_name, extension_name,
organization=None, detect=None):
organization = resolve_instance(detect=detect, organization=organization)
extension_client = get_extension_client(organization)
current_extension = extension_client.get_installed_extension_by_name(
publisher_name=publisher_id,
extension_name=extension_id)
publisher_name=publisher_name,
extension_name=extension_name)
state_from_service = str(current_extension.install_state.flags)
logger.info('state received from service')

Просмотреть файл

@ -10,13 +10,21 @@ import subprocess
oldArguments = []
newArguments = []
allowedMissingArguments = {}
allowedMissingArguments['devops service-endpoint create'] = ['--azure-rm-service-prinicipal-key']
allowedMissingArguments['pipelines build queue'] = ['--source-branch']
allowedMissingArguments['devops extension disable'] = ['--extension-id', '--publisher-id']
allowedMissingArguments['devops extension enable'] = ['--extension-id', '--publisher-id']
allowedMissingArguments['devops extension install'] = ['--extension-id', '--publisher-id']
allowedMissingArguments['devops extension uninstall'] = ['--extension-id', '--publisher-id']
allowedMissingArguments['devops extension show'] = ['--extension-id', '--publisher-id']
allowedNewMandatoryArguments = {}
allowedNewMandatoryArguments['devops extension disable'] = ['--extension-name', '--publisher-name']
allowedNewMandatoryArguments['devops extension enable'] = ['--extension-name', '--publisher-name']
allowedNewMandatoryArguments['devops extension install'] = ['--extension-name', '--publisher-name']
allowedNewMandatoryArguments['devops extension uninstall'] = ['--extension-name', '--publisher-name']
allowedNewMandatoryArguments['devops extension show'] = ['--extension-name', '--publisher-name']
# Do not compare these commands
ignoreCommands = []
ignoreCommands.append('pipelines build task list')
ignoreCommands.append('pipelines build task show')
class Arguments(dict):
def __init__(self, command, name, isRequired):
@ -109,7 +117,9 @@ for newArgument in newArguments:
break
if isNewMandatory is True:
errorList.append('New Mandatory argument found for command ' + newArgument.command + ' argument ' + newArgument.name)
allowedNewMandatoryArgumentsForCommand = allowedNewMandatoryArguments.get(newArgument.command, [])
if not newArgument.name in allowedNewMandatoryArgumentsForCommand:
errorList.append('New Mandatory argument found for command ' + newArgument.command + ' argument ' + newArgument.name)
# make sure no argument is removed
for oldArgument in oldArguments: