Skip to content
Merged
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
33 changes: 33 additions & 0 deletions manifests/07-downloads-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ spec:

signal.signal(signal.SIGTERM, lambda signum, frame: sys.exit(0))

def write_index(path, message):
with open(path, 'wb') as f:
f.write('\n'.join([
'<!doctype html>',
'<html lang="en">',
'<head>',
' <meta charset="utf-8">',
'</head>',
'<body>',
' {}'.format(message),
'</body>',
'</html>',
'',
]).encode('utf-8'))

# Launch multiple listeners as threads
class Thread(threading.Thread):
def __init__(self, i, socket):
Expand Down Expand Up @@ -93,6 +108,7 @@ spec:
os.mkdir(arch)
for operating_system in ['linux']:
os.mkdir(os.path.join(arch, operating_system))
content = ['<a href="oc-license">license</a>']
os.symlink('/usr/share/openshift/LICENSE', 'oc-license')

for arch, operating_system, path in [
Expand All @@ -112,6 +128,23 @@ spec:
tar.add(path, basename)
with zipfile.ZipFile('{}.zip'.format(archive_path_root), 'w') as zip:
zip.write(path, basename)
content.append('<a href="{0}">oc ({1} {2})</a> (<a href="{0}.tar">tar</a> <a href="{0}.zip">zip</a>)'.format(target_path, arch, operating_system))

for root, directories, filenames in os.walk(temp_dir):
root_link = os.path.relpath(temp_dir, os.path.join(root, 'child')).replace(os.path.sep, '/')
for directory in directories:
write_index(
path=os.path.join(root, directory, 'index.html'),
message='<p>Directory listings are disabled. See <a href="">here</a> for available content.</p>'.format(root_link),
)
write_index(
path=os.path.join(root, 'index.html'),
message='\n'.join(
['<ul>'] +
[' <li>{}</li>'.format(entry) for entry in content] +
['</ul>']
),
)

# Create socket
# IPv6 should handle IPv4 passively so long as it is not bound to a
Expand Down