third_party/metadata_envoy: Modify license file (#2224)

Change to update the approach to add license files to the
third_party/metadata_envoy docker image. This update moves from the
model of downloading the license files in each build to downloading it
locally to a license.txt file, checking the file in and using it to
store in the docker image.
This commit is contained in:
dushyanthsc 2019-09-26 17:21:36 -07:00 committed by Kubernetes Prow Robot
parent 389b585de1
commit fbb008f593
5 changed files with 3946 additions and 31 deletions

View File

@ -15,18 +15,13 @@
FROM envoyproxy/envoy:latest FROM envoyproxy/envoy:latest
RUN apt-get update -y && \ RUN apt-get update -y && \
apt-get install --no-install-recommends -y -q python python-pip python-setuptools gettext apt-get install --no-install-recommends -y -q gettext
RUN pip install wget
COPY third_party/metadata_envoy/envoy.yaml /etc/envoy.yaml COPY third_party/metadata_envoy/envoy.yaml /etc/envoy.yaml
# Copy license files. # Copy license files.
ADD third_party/metadata_envoy /scratch #RUN mkdir -p /third_party
RUN python /scratch/dependency_helper.py /scratch/dependencies.json COPY third_party/metadata_envoy/license.txt /third_party/license.txt
RUN rm -rf /scratch
RUN pip uninstall --yes wget
RUN apt-get remove --yes --purge python-setuptools python-pip python
ENTRYPOINT ["/usr/local/bin/envoy", "-c"] ENTRYPOINT ["/usr/local/bin/envoy", "-c"]
CMD ["/etc/envoy.yaml"] CMD ["/etc/envoy.yaml"]

View File

@ -7,7 +7,12 @@ that contains license files for all the third party libraries used in envoy.
# Adding new library dependency # Adding new library dependency
To add license file for a new library introduce in OSS envoy just update [dependencies.json](./dependencies.json) To add license file for a new library introduce in OSS envoy just update [dependencies.json](./dependencies.json)
file with the entry for the library and its corresponding license url path. file with the entry for the library and its corresponding license url path and
the run the python script:
```bash
python dependency_helper.py dependencies.json
```
# Building image # Building image

View File

@ -1,6 +1,9 @@
{ {
"target_path": "/third_party",
"libraries": [ "libraries": [
{
"library": "envoy-proxy",
"license_url": "https://raw.githubusercontent.com/envoyproxy/envoy/master/LICENSE"
},
{ {
"library": "protoc-gen-validate", "library": "protoc-gen-validate",
"license_url": "https://raw.githubusercontent.com/envoyproxy/protoc-gen-validate/master/LICENSE" "license_url": "https://raw.githubusercontent.com/envoyproxy/protoc-gen-validate/master/LICENSE"

View File

@ -22,16 +22,7 @@ file.
import json import json
import os import os
import sys import sys
from urlparse import urlparse import requests
import wget
def _create_local_directory(path):
try:
os.mkdir(path)
except OSError as err:
print("OS error: {}".format(err))
sys.exit(1)
def copy_third_party_licenses(dependency_spec): def copy_third_party_licenses(dependency_spec):
if not os.path.isfile(dependency_spec): if not os.path.isfile(dependency_spec):
@ -40,16 +31,12 @@ def copy_third_party_licenses(dependency_spec):
with open(dependency_spec, 'r') as f: with open(dependency_spec, 'r') as f:
dependencies = json.load(f) dependencies = json.load(f)
if not dependencies['target_path']: with open('license.txt', 'w') as l:
print("Invalid dependency spec. 'target_path' expected")
_create_local_directory(dependencies['target_path'])
for dependency in dependencies['libraries']: for dependency in dependencies['libraries']:
license_dest = '{}/{}'.format(dependencies['target_path'], dependency['library']) print('Downloading License for library : {}'.format(dependency['library']))
license_url = dependency['license_url'] l.write('Library: {}\n\n'.format(dependency['library']))
_create_local_directory(license_dest) l.write(requests.get(dependency['license_url']).text.encode("utf-8"))
wget.download(license_url, '{}/{}'.format(license_dest, os.path.split(urlparse(license_url).path)[-1])) l.write('\n\n')
if __name__ == '__main__': if __name__ == '__main__':
if len(sys.argv) < 2: if len(sys.argv) < 2:

3925
third_party/metadata_envoy/license.txt vendored Normal file

File diff suppressed because it is too large Load Diff