Пример #1
0
def GetExistingGCRBuckets(buckets, project):
    """Gets the list of GCR bucket names that exist in the project."""
    existing_buckets = []

    project_id_for_bucket = project
    if ":" in project:
        domain, project_id = project.split(":")
        project_id_for_bucket = "{}.{}.a".format(project_id, domain)
    for bucket in buckets:
        try:
            ar_requests.TestStorageIAMPermission(
                bucket["bucket"].format(project_id_for_bucket), project)
            existing_buckets.append(bucket)
        except apitools_exceptions.HttpNotFoundError:
            continue
    return existing_buckets
Пример #2
0
def GetGCRRepos(buckets, project):
    """Gets a list of GCR repositories given a list of GCR bucket names."""
    messages = ar_requests.GetMessages()
    repos = []

    project_id_for_bucket = project
    if ":" in project:
        domain, project_id = project.split(":")
        project_id_for_bucket = "{}.{}.a".format(project_id, domain)
    for bucket in buckets:
        try:
            ar_requests.TestStorageIAMPermission(
                bucket["bucket"].format(project_id_for_bucket), project)
            repo = messages.Repository(
                name="projects/{}/locations/{}/repositories/{}".format(
                    project, bucket["location"], bucket["repository"]),
                format=messages.Repository.FormatValueValuesEnum.DOCKER)
            repos.append(repo)
        except api_exceptions.HttpNotFoundError:
            continue
    return repos