Exemplo n.º 1
0
def _write_version_file(project_name, latest_version):
    file_name = '{0}.version'.format(project_name)
    full_path = builder_util.RUNTIME_BUCKET_PREFIX + file_name

    logging.info(full_path)

    builder_util.write_to_gcs(full_path, latest_version)
Exemplo n.º 2
0
def _publish_to_gcs(builder_file_contents, builder_name, bucket):
    """
    Given a cloudbuild YAML config file, publish the file to a bucket in GCS.
    """
    file_name = '{0}-builder-{1}.yaml'.format(
        builder_name,
        datetime.now().strftime('%Y%m%d%H%M%S'))

    full_path = 'gs://{0}/{1}'.format(bucket, file_name)

    builder_util.write_to_gcs(full_path, builder_file_contents)

    return full_path
Exemplo n.º 3
0
def _publish_latest(builder_dir):
    for f in glob.glob(os.path.join(builder_dir, '*.yaml')):
        with open(f, 'r') as f:
            config = yaml.safe_load(f)

        latest = config['latest']
        project_name = config['project']

        parts = os.path.splitext(latest)
        prefix = builder_util.RUNTIME_BUCKET_PREFIX + project_name + '-'
        latest_file = parts[0].replace(prefix, '')
        file_name = '{0}.version'.format(project_name)
        full_path = builder_util.RUNTIME_BUCKET_PREFIX + file_name
        builder_util.write_to_gcs(full_path, latest_file)
Exemplo n.º 4
0
def _publish_latest(builder_dir):
    for f in glob.glob(os.path.join(builder_dir, '*.yaml')):
        with open(f, 'r') as f:
            config = yaml.safe_load(f)

        if 'latest' not in config or 'project' not in config:

            logging.error(
                'Config file {0} is missing a required field!'.format(f))
            continue

        latest = config['latest']
        project_name = config['project']

        parts = os.path.splitext(latest)
        prefix = builder_util.RUNTIME_BUCKET_PREFIX + project_name + '-'
        latest_file = parts[0].replace(prefix, '')
        file_name = '{0}.version'.format(project_name)
        full_path = builder_util.RUNTIME_BUCKET_PREFIX + file_name
        builder_util.write_to_gcs(full_path, latest_file)