Skip to content
This repository was archived by the owner on Jun 4, 2021. It is now read-only.

Commit 72fedc6

Browse files
committed
Export from mono-repo
1 parent b67fd7a commit 72fedc6

4 files changed

Lines changed: 109 additions & 82 deletions

File tree

WORKSPACE

Lines changed: 2 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -13,80 +13,6 @@
1313
# limitations under the License.
1414
workspace(name = "containerregistry")
1515

16-
new_http_archive(
17-
name = "httplib2",
18-
url = "https://codeload.github.com/httplib2/httplib2/tar.gz/v0.10.3",
19-
sha256 = "d1bee28a68cc665c451c83d315e3afdbeb5391f08971dcc91e060d5ba16986f1",
20-
strip_prefix = "httplib2-0.10.3/python2/httplib2/",
21-
type = "tar.gz",
22-
build_file_content = """
23-
py_library(
24-
name = "httplib2",
25-
srcs = glob(["**/*.py"]),
26-
data = ["cacerts.txt"],
27-
visibility = ["//visibility:public"]
28-
)""",
29-
)
16+
load(":def.bzl", "repositories")
3017

31-
# Used by oauth2client
32-
new_http_archive(
33-
name = "six",
34-
url = "https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz",
35-
sha256 = "e24052411fc4fbd1f672635537c3fc2330d9481b18c0317695b46259512c91d5",
36-
strip_prefix = "six-1.9.0/",
37-
type = "tar.gz",
38-
build_file_content = """
39-
# Rename six.py to __init__.py
40-
genrule(
41-
name = "rename",
42-
srcs = ["six.py"],
43-
outs = ["__init__.py"],
44-
cmd = "cat $< >$@",
45-
)
46-
py_library(
47-
name = "six",
48-
srcs = [":__init__.py"],
49-
visibility = ["//visibility:public"],
50-
)"""
51-
)
52-
53-
# Used for authentication in containerregistry
54-
new_http_archive(
55-
name = "oauth2client",
56-
url = "https://codeload.github.com/google/oauth2client/tar.gz/v4.0.0",
57-
sha256 = "7230f52f7f1d4566a3f9c3aeb5ffe2ed80302843ce5605853bee1f08098ede46",
58-
strip_prefix = "oauth2client-4.0.0/oauth2client/",
59-
type = "tar.gz",
60-
build_file_content = """
61-
py_library(
62-
name = "oauth2client",
63-
srcs = glob(["**/*.py"]),
64-
visibility = ["//visibility:public"],
65-
deps = [
66-
"@httplib2//:httplib2",
67-
"@six//:six",
68-
]
69-
)"""
70-
)
71-
72-
# Used for parallel execution in containerregistry
73-
new_http_archive(
74-
name = "concurrent",
75-
url = "https://codeload.github.com/agronholm/pythonfutures/tar.gz/3.0.5",
76-
sha256 = "a7086ddf3c36203da7816f7e903ce43d042831f41a9705bc6b4206c574fcb765",
77-
strip_prefix = "pythonfutures-3.0.5/concurrent/",
78-
type = "tar.gz",
79-
build_file_content = """
80-
py_library(
81-
name = "concurrent",
82-
srcs = glob(["**/*.py"]),
83-
visibility = ["//visibility:public"]
84-
)"""
85-
)
86-
87-
# For packaging python tools.
88-
git_repository(
89-
name = "subpar",
90-
remote = "https://github.com/google/subpar",
91-
commit = "7e12cc130eb8f09c8cb02c3585a91a4043753c56",
92-
)
18+
repositories()

client/v2_2/docker_image_list_.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,15 @@ def images(self):
270270
digest = entry['digest']
271271
name = docker_name.Digest('{base}@{digest}'.format(
272272
base=self._name.as_repository(), digest=digest))
273+
media_type = entry['mediaType']
273274

274-
if entry['mediaType'] in docker_http.MANIFEST_LIST_MIMES:
275+
if media_type in docker_http.MANIFEST_LIST_MIMES:
275276
image = FromRegistry(name, self._creds, self._original_transport)
276-
elif entry['mediaType'] == docker_http.MANIFEST_SCHEMA2_MIME:
277+
elif media_type in docker_http.SUPPORTED_MANIFEST_MIMES:
277278
image = v2_2_image.FromRegistry(name, self._creds,
278-
self._original_transport)
279+
self._original_transport, [media_type])
279280
else:
280-
raise InvalidMediaTypeError('Invalid media type: ' + entry['mediaType'])
281+
raise InvalidMediaTypeError('Invalid media type: ' + media_type)
281282

282283
platform = Platform(entry['platform']) if 'platform' in entry else None
283284
results.append((name, platform, image))

def.bzl

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Copyright 2017 Google Inc. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
def repositories():
16+
native.new_http_archive(
17+
name = "httplib2",
18+
url = "https://codeload.github.com/httplib2/httplib2/tar.gz/v0.10.3",
19+
sha256 = "d1bee28a68cc665c451c83d315e3afdbeb5391f08971dcc91e060d5ba16986f1",
20+
strip_prefix = "httplib2-0.10.3/python2/httplib2/",
21+
type = "tar.gz",
22+
build_file_content = """
23+
py_library(
24+
name = "httplib2",
25+
srcs = glob(["**/*.py"]),
26+
data = ["cacerts.txt"],
27+
visibility = ["//visibility:public"]
28+
)""",
29+
)
30+
31+
# Used by oauth2client
32+
native.new_http_archive(
33+
name = "six",
34+
url = "https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz",
35+
sha256 = "e24052411fc4fbd1f672635537c3fc2330d9481b18c0317695b46259512c91d5",
36+
strip_prefix = "six-1.9.0/",
37+
type = "tar.gz",
38+
build_file_content = """
39+
# Rename six.py to __init__.py
40+
genrule(
41+
name = "rename",
42+
srcs = ["six.py"],
43+
outs = ["__init__.py"],
44+
cmd = "cat $< >$@",
45+
)
46+
py_library(
47+
name = "six",
48+
srcs = [":__init__.py"],
49+
visibility = ["//visibility:public"],
50+
)"""
51+
)
52+
53+
# Used for authentication in containerregistry
54+
native.new_http_archive(
55+
name = "oauth2client",
56+
url = "https://codeload.github.com/google/oauth2client/tar.gz/v4.0.0",
57+
sha256 = "7230f52f7f1d4566a3f9c3aeb5ffe2ed80302843ce5605853bee1f08098ede46",
58+
strip_prefix = "oauth2client-4.0.0/oauth2client/",
59+
type = "tar.gz",
60+
build_file_content = """
61+
py_library(
62+
name = "oauth2client",
63+
srcs = glob(["**/*.py"]),
64+
visibility = ["//visibility:public"],
65+
deps = [
66+
"@httplib2//:httplib2",
67+
"@six//:six",
68+
]
69+
)"""
70+
)
71+
72+
# Used for parallel execution in containerregistry
73+
native.new_http_archive(
74+
name = "concurrent",
75+
url = "https://codeload.github.com/agronholm/pythonfutures/tar.gz/3.0.5",
76+
sha256 = "a7086ddf3c36203da7816f7e903ce43d042831f41a9705bc6b4206c574fcb765",
77+
strip_prefix = "pythonfutures-3.0.5/concurrent/",
78+
type = "tar.gz",
79+
build_file_content = """
80+
py_library(
81+
name = "concurrent",
82+
srcs = glob(["**/*.py"]),
83+
visibility = ["//visibility:public"]
84+
)"""
85+
)
86+
87+
# For packaging python tools.
88+
native.git_repository(
89+
name = "subpar",
90+
remote = "https://github.com/google/subpar",
91+
commit = "7e12cc130eb8f09c8cb02c3585a91a4043753c56",
92+
)

tools/fast_importer_.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@
3333
help=('The tarball containing the docker image to rewrite '
3434
'into our fast on-disk format.'))
3535

36+
parser.add_argument('--format', action='store', default='tar',
37+
choices=['tar', 'tar.gz'],
38+
help='The form in which to save layers.')
39+
3640
parser.add_argument('--directory', action='store',
3741
help='Where to save the image\'s files.')
3842

39-
_THREADS = 8
43+
_THREADS = 32
4044

4145

4246
def main():
@@ -47,9 +51,13 @@ def main():
4751
if not args.tarball or not args.directory:
4852
raise Exception('--tarball and --directory are required arguments.')
4953

54+
method = save.uncompressed
55+
if args.format == 'tar.gz':
56+
method = save.fast
57+
5058
logging.info('Reading v2.2 image from tarball %r', args.tarball)
5159
with v2_2_image.FromTarball(args.tarball) as v2_2_img:
52-
save.uncompressed(v2_2_img, args.directory, threads=_THREADS)
60+
method(v2_2_img, args.directory, threads=_THREADS)
5361

5462

5563
if __name__ == '__main__':

0 commit comments

Comments
 (0)