Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

third_party/metadata_envoy: Modify license file #2224

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions third_party/metadata_envoy/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,13 @@
FROM envoyproxy/envoy:latest

RUN apt-get update -y && \
apt-get install --no-install-recommends -y -q python python-pip python-setuptools gettext
RUN pip install wget
apt-get install --no-install-recommends -y -q gettext

COPY third_party/metadata_envoy/envoy.yaml /etc/envoy.yaml

# Copy license files.
ADD third_party/metadata_envoy /scratch
RUN python /scratch/dependency_helper.py /scratch/dependencies.json
RUN rm -rf /scratch

RUN pip uninstall --yes wget
RUN apt-get remove --yes --purge python-setuptools python-pip python
#RUN mkdir -p /third_party
COPY third_party/metadata_envoy/license.txt /third_party/license.txt

ENTRYPOINT ["/usr/local/bin/envoy", "-c"]
CMD ["/etc/envoy.yaml"]
7 changes: 6 additions & 1 deletion third_party/metadata_envoy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ that contains license files for all the third party libraries used in envoy.
# Adding new library dependency

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

Expand Down
7 changes: 5 additions & 2 deletions third_party/metadata_envoy/dependencies.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"target_path": "/third_party",
"libraries": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I think you should also include license for envoy itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the catch. Fixed it.

{
"library": "envoy-proxy",
"license_url": "https://raw.githubusercontent.com/envoyproxy/envoy/master/LICENSE"
},
{
"library": "protoc-gen-validate",
"license_url": "https://raw.githubusercontent.com/envoyproxy/protoc-gen-validate/master/LICENSE"
Expand Down Expand Up @@ -139,4 +142,4 @@
"license_url": "https://raw.githubusercontent.com/prometheus/client_model/master/LICENSE"
}
]
}
}
27 changes: 7 additions & 20 deletions third_party/metadata_envoy/dependency_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,7 @@
import json
import os
import sys
from urlparse import urlparse
import wget


def _create_local_directory(path):
try:
os.mkdir(path)
except OSError as err:
print("OS error: {}".format(err))
sys.exit(1)
import requests

def copy_third_party_licenses(dependency_spec):
if not os.path.isfile(dependency_spec):
Expand All @@ -40,16 +31,12 @@ def copy_third_party_licenses(dependency_spec):

with open(dependency_spec, 'r') as f:
dependencies = json.load(f)
if not dependencies['target_path']:
print("Invalid dependency spec. 'target_path' expected")

_create_local_directory(dependencies['target_path'])

for dependency in dependencies['libraries']:
license_dest = '{}/{}'.format(dependencies['target_path'], dependency['library'])
license_url = dependency['license_url']
_create_local_directory(license_dest)
wget.download(license_url, '{}/{}'.format(license_dest, os.path.split(urlparse(license_url).path)[-1]))
with open('license.txt', 'w') as l:
for dependency in dependencies['libraries']:
print('Downloading License for library : {}'.format(dependency['library']))
l.write('Library: {}\n\n'.format(dependency['library']))
l.write(requests.get(dependency['license_url']).text.encode("utf-8"))
l.write('\n\n')

if __name__ == '__main__':
if len(sys.argv) < 2:
Expand Down
Loading