Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load_command_table(self, args):
super(TestCommandsLoader, self).load_command_table(args)
with CommandGroup(self, 'foo', '{}#{{}}'.format(__name__)) as g:
g.command('list', 'list_foo')
return self.command_table
def test_register_command_group_with_no_group_name(self):
cl = CLICommandsLoader(self.mock_ctx)
command_name = self._set_command_name('sample-command')
with CommandGroup(cl, None, '{}#{{}}'.format(__name__)) as g:
g.command('sample-command', '{}.{}'.format(TestCommandRegistration.__name__,
TestCommandRegistration.sample_command_handler.__name__))
self.assertEqual(len(cl.command_table), 1, 'We expect exactly one command in the command table')
self.assertIn(command_name, cl.command_table)
def load_command_table(self, args):
super(DeprecationTestCommandLoader, self).load_command_table(args)
with CommandGroup(self, 'group1', '{}#{{}}'.format(__name__), deprecate_info=self.deprecate(redirect='alt-group1')) as g:
g.command('cmd1', 'example_handler')
with CommandGroup(self, 'group2', '{}#{{}}'.format(__name__), deprecate_info=self.deprecate(redirect='alt-group2', hide='1.0.0')) as g:
g.command('cmd1', 'example_handler')
with CommandGroup(self, 'group3', '{}#{{}}'.format(__name__), deprecate_info=self.deprecate(redirect='alt-group3', hide='0.1.0')) as g:
g.command('cmd1', 'example_handler')
with CommandGroup(self, 'group4', '{}#{{}}'.format(__name__), deprecate_info=self.deprecate(redirect='alt-group4', expiration='1.0.0')) as g:
g.command('cmd1', 'example_handler')
with CommandGroup(self, 'group5', '{}#{{}}'.format(__name__), deprecate_info=self.deprecate(redirect='alt-group5', expiration='0.1.0')) as g:
g.command('cmd1', 'example_handler')
return self.command_table
def load_command_table(self, args):
super(HelpTestCommandLoader, self).load_command_table(args)
with CommandGroup(self, '', '{}#{{}}'.format(__name__)) as g:
g.command('n1', 'example_handler')
g.command('n2', 'example_handler')
g.command('n3', 'example_handler')
g.command('n4', 'example_handler')
g.command('n5', 'example_handler')
with CommandGroup(self, 'group alpha', '{}#{{}}'.format(__name__)) as g:
g.command('n1', 'example_handler')
with CommandGroup(self, 'group beta', '{}#{{}}'.format(__name__)) as g:
g.command('n1', 'example_handler')
return self.command_table
group.command('delete', 'delete')
group.command('list', 'list')
with CommandGroup(self, 'mesh app', mesh_application_func_path,
client_factory=mesh_app_create) as group:
group.command('show', 'get')
group.command('delete', 'delete')
group.command('list', 'list')
with CommandGroup(self, 'mesh volume', mesh_volume_func_path,
client_factory=mesh_volume_create) as group:
group.command('show', 'get')
group.command('delete', 'delete')
group.command('list', 'list')
with CommandGroup(self, 'mesh service', mesh_service_func_path,
client_factory=mesh_service_create) as group:
group.command('show', 'get')
group.command('list', 'list')
with CommandGroup(self, 'mesh service-replica', mesh_service_replica_func_path,
client_factory=mesh_service_replica_create) as group:
group.command('list', 'list')
group.command('show', 'get')
# ---------------
# Custom commands
# ---------------
with CommandGroup(self, 'container', 'sfctl.custom_container#{}',
client_factory=client_create) as group:
group.command('invoke-api', 'invoke_api')
group.command('logs', 'logs')
'upgrade-rollback',
'rollback_application_upgrade'
)
group.command(
'deployed-list',
'get_deployed_application_info_list'
)
group.command('deployed', 'get_deployed_application_info')
group.command(
'deployed-health',
'get_deployed_application_health'
)
group.command('manifest', 'get_application_manifest')
group.command('load', 'get_application_load_info')
with CommandGroup(self, 'service', client_func_path,
client_factory=client_create) as group:
group.command('type-list', 'get_service_type_info_list')
group.command('manifest', 'get_service_manifest')
group.command(
'deployed-type-list',
'get_deployed_service_type_info_list'
)
group.command(
'deployed-type',
'get_deployed_service_type_info_by_name'
)
group.command('list', 'get_service_info_list')
group.command('info', 'get_service_info')
group.command('app-name', 'get_application_name_info')
group.command('delete', 'delete_service')
group.command('description', 'get_service_description')
with CommandGroup(self, '', operation_group('code_gen')) as g:
g.command('cli create', 'create_module')
g.command('extension create', 'create_extension')
with CommandGroup(self, 'verify', operation_group('help')) as g:
g.command('document-map', 'check_document_map')
with CommandGroup(self, 'verify', operation_group('legal')) as g:
g.command('license', 'check_license_headers')
with CommandGroup(self, 'perf', operation_group('performance')) as g:
g.command('load-times', 'check_load_time')
g.command('benchmark', 'benchmark', is_preview=True)
with CommandGroup(self, 'extension', operation_group('extensions')) as g:
g.command('add', 'add_extension')
g.command('remove', 'remove_extension')
g.command('list', 'list_extensions')
g.command('build', 'build_extensions')
g.command('publish', 'publish_extensions')
g.command('update-index', 'update_extension_index')
with CommandGroup(self, 'extension repo', operation_group('extensions')) as g:
g.command('add', 'add_extension_repo')
g.command('remove', 'remove_extension_repo')
g.command('list', 'list_extension_repos')
with CommandGroup(self, 'cli', operation_group('help')) as g:
g.command('generate-docs', 'generate_cli_ref_docs')
with CommandGroup(self, 'extension', operation_group('help')) as g:
"""
Loads the command table
"""
def operation_group(name):
return '{cli_name}.commands.{name}#{name}'.format(cli_name=__CLI_NAME__, name=name)
with CommandGroup(self, _COMMAND_GROUP, operation_group(_LOGIN)) as command_group:
command_group.command(_LOGIN, _LOGIN)
with CommandGroup(self, _COMMAND_GROUP, operation_group(_DOWNLOAD)) as command_group:
command_group.command(_DOWNLOAD, _DOWNLOAD)
with CommandGroup(self, _COMMAND_GROUP, operation_group(_CREATE)) as command_group:
command_group.command(_CREATE, _CREATE)
with CommandGroup(self, _COMMAND_GROUP, operation_group(_UPDATE)) as command_group:
command_group.command(_UPDATE, _UPDATE)
with CommandGroup(self, _COMMAND_GROUP, operation_group(_VALIDATE)) as command_group:
command_group.command(_VALIDATE, _VALIDATE)
with CommandGroup(self, 'sa-cluster', 'sfctl.custom_cluster_upgrade#{}',
client_factory=client_create) as group:
group.command('config-upgrade', 'sa_configuration_upgrade')
with CommandGroup(self, 'compose', 'sfctl.custom_compose#{}',
client_factory=client_create) as group:
group.command('upgrade', 'upgrade')
group.command('create', 'create')
with CommandGroup(self, 'application', 'sfctl.custom_app#{}',
client_factory=client_create) as group:
group.command('create', 'create')
group.command('upgrade', 'upgrade')
with CommandGroup(self, 'application', 'sfctl.custom_app#{}') as group:
group.command('upload', 'upload')
# Need an empty client for the select and upload operations
with CommandGroup(self, 'cluster', 'sfctl.custom_cluster#{}') as group:
group.command('select', 'select')
group.command('show-connection', 'show_connection')
with CommandGroup(self, 'chaos', 'sfctl.custom_chaos#{}',
client_factory=client_create) as group:
group.command('start', 'start')
with CommandGroup(self, 'chaos schedule', 'sfctl.custom_chaos_schedule#{}',
client_factory=client_create) as group:
group.command('set', 'set_chaos_schedule')
with CommandGroup(self, 'service', 'sfctl.custom_service#{}',