def testGetFormatRegistryHidden(self): with mock.patch.object(resource_printer, '_FORMATTERS', {'default': {}}): resource_printer.RegisterFormatter('hidden', {}, hidden=True) registry = resource_printer.GetFormatRegistry(hidden=True) self.assertIn('default', registry) self.assertIn('hidden', registry)
def Args(cls, parser): super(Describe, cls).Args(parser) parser.add_argument('component', help='Name of the component.') resource_printer.RegisterFormatter( component_printer.COMPONENT_PRINTER_FORMAT, component_printer.ComponentPrinter, hidden=True) parser.display_info.AddFormat(component_printer.COMPONENT_PRINTER_FORMAT)
def Run(self, args): """Update the traffic split for the service. Args: args: Args! Returns: List of traffic.TrafficTargetStatus instances reflecting the change. """ # TODO(b/143898356) Begin code that should be in Args resource_printer.RegisterFormatter( traffic_printer.TRAFFIC_PRINTER_FORMAT, traffic_printer.TrafficPrinter) args.GetDisplayInfo().AddFormat('traffic') # End code that should be in Args conn_context = connection_context.GetConnectionContext( args, flags.Product.RUN, self.ReleaseTrack()) service_ref = flags.GetService(args) changes = flags.GetConfigurationChanges(args) if not changes: raise exceptions.NoConfigurationChangeError( 'No traffic configuration change requested.') is_managed = flags.GetPlatform() == flags.PLATFORM_MANAGED with serverless_operations.Connect(conn_context) as client: deployment_stages = stages.UpdateTrafficStages() try: with progress_tracker.StagedProgressTracker( 'Updating traffic...', deployment_stages, failure_message='Updating traffic failed', suppress_output=args.async_) as tracker: client.UpdateTraffic(service_ref, changes, tracker, args.async_) except: serv = client.GetService(service_ref) if serv: resources = traffic_pair.GetTrafficTargetPairs( serv.spec_traffic, serv.status_traffic, is_managed, serv.status.latestReadyRevisionName, serv.status.url) display.Displayer( self, args, resources, display_info=args.GetDisplayInfo()).Display() raise if args.async_: pretty_print.Success('Updating traffic asynchronously.') else: serv = client.GetService(service_ref) resources = traffic_pair.GetTrafficTargetPairs( serv.spec_traffic, serv.status_traffic, is_managed, serv.status.latestReadyRevisionName, serv.status.url) return resources
def CommonArgs(parser): job_presentation = presentation_specs.ResourcePresentationSpec( 'JOB', resource_args.GetJobResourceSpec(), 'Job to describe.', required=True, prefixes=False) concept_parsers.ConceptParser([job_presentation]).AddToParser(parser) resource_printer.RegisterFormatter(job_printer.JOB_PRINTER_FORMAT, job_printer.JobPrinter, hidden=True) parser.display_info.AddFormat(job_printer.JOB_PRINTER_FORMAT) resource_printer.RegisterFormatter( export_printer.EXPORT_PRINTER_FORMAT, export_printer.ExportPrinter, hidden=True)
def Args(cls, parser): super(Describe, cls).Args(parser) parser.add_argument('devkit', help='The Development Kit to show details for.') resource_printer.RegisterFormatter( devkit_printer.DEVKIT_PRINTER_FORMAT, devkit_printer.DevKitPrinter, hidden=True) parser.display_info.AddFormat(devkit_printer.DEVKIT_PRINTER_FORMAT)
def Args(cls, parser): super(Describe, cls).Args(parser) parser.add_argument('resource', help='Name of the resource.') resource_printer.RegisterFormatter( backing_resource_printer.RESOURCE_PRINTER_FORMAT, backing_resource_printer.ResourcePrinter, hidden=True) parser.display_info.AddFormat( backing_resource_printer.RESOURCE_PRINTER_FORMAT)
def Args(cls, parser): super(Describe, cls).Args(parser) parser.add_argument( 'service', help='The KubeRun service for which to show details.') resource_printer.RegisterFormatter( service_printer.SERVICE_PRINTER_FORMAT, service_printer.ServicePrinter, hidden=True) parser.display_info.AddFormat(service_printer.SERVICE_PRINTER_FORMAT)
def Args(cls, parser): super(Describe, cls).Args(parser) parser.add_argument( 'revision', help='The Knative revision to show details for.') resource_printer.RegisterFormatter( revision_printer.REVISION_PRINTER_FORMAT, revision_printer.RevisionPrinter, hidden=True) parser.display_info.AddFormat(revision_printer.REVISION_PRINTER_FORMAT)
def Args(parser): resource_args.AddRegistrationResourceArg(parser, 'to describe') resource_printer.RegisterFormatter( registration_printer.REGISTRATION_PRINTER_FORMAT, registration_printer.RegistrationPrinter, hidden=True) parser.display_info.AddFormat( registration_printer.REGISTRATION_PRINTER_FORMAT)
def Args(cls, parser): super(UpdateTraffic, cls).Args(parser) parser.add_argument( 'service', help='Knative service for which to update the traffic settings.') resource_printer.RegisterFormatter( traffic_printer.TRAFFIC_PRINTER_FORMAT, traffic_printer.TrafficPrinter, hidden=True) parser.display_info.AddFormat(traffic_printer.TRAFFIC_PRINTER_FORMAT)
def CommonArgs(parser): service_presentation = presentation_specs.ResourcePresentationSpec( 'SERVICE', resource_args.GetServiceResourceSpec(), 'Service to describe.', required=True, prefixes=False) concept_parsers.ConceptParser([service_presentation ]).AddToParser(parser) resource_printer.RegisterFormatter( service_printer.SERVICE_PRINTER_FORMAT, service_printer.ServicePrinter, hidden=True) parser.display_info.AddFormat(service_printer.SERVICE_PRINTER_FORMAT) resource_printer.RegisterFormatter( export_printer.EXPORT_PRINTER_FORMAT, export_printer.ExportPrinter, hidden=True)
def CommonArgs(parser): revision_presentation = presentation_specs.ResourcePresentationSpec( 'REVISION', resource_args.GetRevisionResourceSpec(), 'Revision to describe.', required=True, prefixes=False) concept_parsers.ConceptParser([revision_presentation ]).AddToParser(parser) resource_printer.RegisterFormatter( revision_printer.REVISION_PRINTER_FORMAT, revision_printer.RevisionPrinter, hidden=True) parser.display_info.AddFormat(revision_printer.REVISION_PRINTER_FORMAT) resource_printer.RegisterFormatter( export_printer.EXPORT_PRINTER_FORMAT, export_printer.ExportPrinter, hidden=True)
def Args(cls, parser): """Set up arguments for this command. Args: parser: An argparse.ArgumentParser. """ flags.AddNamePositionalArg(parser) resource_printer.RegisterFormatter( integration_printer.INTEGRATION_PRINTER_FORMAT, integration_printer.IntegrationPrinter, hidden=True) parser.display_info.AddFormat( integration_printer.INTEGRATION_PRINTER_FORMAT)
def CommonArgs(parser): task_presentation = presentation_specs.ResourcePresentationSpec( 'TASK', resource_args.GetTaskResourceSpec(), 'Task to describe.', required=True, prefixes=False) concept_parsers.ConceptParser([task_presentation]).AddToParser(parser) resource_printer.RegisterFormatter(job_printer.TASK_PRINTER_FORMAT, job_printer.TaskPrinter, hidden=True) parser.display_info.AddFormat(job_printer.TASK_PRINTER_FORMAT)
def CommonArgs(cls, parser): service_presentation = presentation_specs.ResourcePresentationSpec( 'SERVICE', resource_args.GetServiceResourceSpec(prompt=True), 'Service to update the configuration of.', required=True, prefixes=False) flags.AddAsyncFlag(parser) flags.AddUpdateTrafficFlags(parser) flags.AddTrafficTagsFlags(parser) concept_parsers.ConceptParser([service_presentation]).AddToParser(parser) resource_printer.RegisterFormatter( traffic_printer.TRAFFIC_PRINTER_FORMAT, traffic_printer.TrafficPrinter, hidden=True) parser.display_info.AddFormat(traffic_printer.TRAFFIC_PRINTER_FORMAT)
def Run(self, args): """Obtain details about a given service.""" # TODO(b/143898356) Begin code that should be in Args resource_printer.RegisterFormatter( service_printer.SERVICE_PRINTER_FORMAT, service_printer.ServicePrinter) args.GetDisplayInfo().AddFormat('service') # End code that should be in Args conn_context = connection_context.GetConnectionContext( args, flags.Product.RUN, self.ReleaseTrack()) service_ref = flags.GetService(args) with serverless_operations.Connect(conn_context) as client: serv = client.GetService(service_ref) if not serv: raise flags.ArgumentError('Cannot find service [{}]'.format( service_ref.servicesId)) return serv
def Run(self, args): """Show details about a revision.""" # TODO(b/143898356) Begin code that should be in Args resource_printer.RegisterFormatter( revision_printer.REVISION_PRINTER_FORMAT, revision_printer.RevisionPrinter) args.GetDisplayInfo().AddFormat(revision_printer.REVISION_PRINTER_FORMAT) # End code that should be in Args conn_context = connection_context.GetConnectionContext( args, flags.Product.RUN, self.ReleaseTrack()) revision_ref = args.CONCEPTS.revision.Parse() with serverless_operations.Connect(conn_context) as client: wrapped_revision = client.GetRevision(revision_ref) if not wrapped_revision: raise flags.ArgumentError( 'Cannot find revision [{}]'.format(revision_ref.revisionsId)) return wrapped_revision
def Register(parser): """Register this custom printer with the given parser.""" resource_printer.RegisterFormatter(_PRINTER_FORMAT, ApplicationStatusPrinter, hidden=True) parser.display_info.AddFormat(_PRINTER_FORMAT)
def Register(parser): """Register this custom printer with the given parser.""" resource_printer.RegisterFormatter(ASSET_QUERY_PRINTER_FORMAT, AssetQueryPrinter, hidden=True) parser.display_info.AddFormat(ASSET_QUERY_PRINTER_FORMAT)