def Run(self, args):
    all_configs = named_configs.ConfigurationStore.AllConfigs(
        include_none_config=True)
    config = all_configs.get(args.configuration_name, None)
    if not config:
      raise named_configs.NamedConfigError(
          'The configuration [{0}] does not exist.'
          .format(args.configuration_name))

    return {
        'name': config.name,
        'is_active': config.is_active,
        'properties': properties.VALUES.AllValues(
            list_unset=args.all,
            properties_file=properties_file.PropertiesFile([config.file_path]),
            only_file_contents=True),
    }
Beispiel #2
0
    def Run(self, args):
        # Fail the delete operation when we're attempting to delete the
        # active config.
        active_config = named_configs.ConfigurationStore.ActiveConfig()
        if active_config.name in args.configuration_names:
            raise named_configs.NamedConfigError(
                'Deleting named configuration failed because configuration '
                '[{0}] is set as active.  Use `gcloud config configurations '
                'activate` to change the active configuration.'.format(
                    active_config.name))

        fmt = 'list[title="The following configurations will be deleted:"]'
        resource_printer.Print(args.configuration_names, fmt, out=log.status)
        console_io.PromptContinue(default=True, cancel_on_no=True)

        for configuration_name in args.configuration_names:
            named_configs.ConfigurationStore.DeleteConfig(configuration_name)
            log.DeletedResource(configuration_name)