Exemple #1
0
def RunDeployCloudTasks(args):
    """Perform a deployment using Cloud Tasks API based on the given args.

  Args:
    args: argparse.Namespace, An object that contains the values for the
        arguments specified in the ArgsDeploy() function.

  Returns:
    A list of config file identifiers, see yaml_parsing.ConfigYamlInfo.
  """
    paths = [os.path.abspath(x) for x in args.deployables]
    configs = []
    for path in paths:
        if not os.path.exists(path):
            raise exceptions.FileNotFoundError(path)
        config = yaml_parsing.ConfigYamlInfo.FromFile(path)
        if config:
            configs.append(config)
    if configs:
        # TODO(b/169069379): Confirm the same metric name can be used twice in the
        # same run.
        metrics.CustomTimedEvent(metric_names.UPDATE_CONFIG_START)
        # TODO(b/169069379): Upgrade to use GA once the relevant code is promoted
        tasks_api = tasks.GetApiAdapter(base.ReleaseTrack.BETA)
        queues_data = app_deploy_migration_util.FetchCurrrentQueuesData(
            tasks_api)
        for config in configs:
            app_deploy_migration_util.ValidateYamlFileConfig(config)
            app_deploy_migration_util.DeployQueuesYamlFile(
                tasks_api, config, queues_data)
        metrics.CustomTimedEvent(metric_names.UPDATE_CONFIG)
    return [c.name for c in configs]
def RunDeployCloudTasks(config):
    """Perform a deployment using Cloud Tasks API based on the given args.

  Args:
    config: A yaml_parsing.ConfigYamlInfo object for the parsed YAML file we are
      going to process.

  Returns:
    A list of config file identifiers, see yaml_parsing.ConfigYamlInfo.
  """
    # TODO(b/169069379): Upgrade to use GA once the relevant code is promoted
    tasks_api = tasks.GetApiAdapter(base.ReleaseTrack.BETA)
    queues_data = app_deploy_migration_util.FetchCurrentQueuesData(tasks_api)
    app_deploy_migration_util.ValidateQueueYamlFileConfig(config)
    app_deploy_migration_util.DeployQueuesYamlFile(tasks_api, config,
                                                   queues_data)