Skip to content

Commit

Permalink
Also pre-fill the list of ports to expose
Browse files Browse the repository at this point in the history
  • Loading branch information
remram44 committed Aug 22, 2023
1 parent b40f810 commit 0f7895e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion reproserver/web/templates/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h3>Parameters</h3>
<h3>Expose ports</h3>
<div class="mb-3">
<label for="ports" class="form-label">Space-separated list of ports to expose:</label>
<input type="text" class="form-control" id="ports" name="ports" value="">
<input type="text" class="form-control" id="ports" name="ports" value="{{ expose_ports }}">
</div>

{% if input_files %}
Expand Down
18 changes: 15 additions & 3 deletions reproserver/web/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,23 @@ def reproduce(self, upload, repo_name=None, repo_url=None):
.filter(database.Path.is_input)).all()

# Check whether web archive file is present
extensions = [
extension.name
extensions = {
extension.name: extension.data
for extension in upload.experiment.extensions
]
}
wacz_present = 'web1' in extensions

# Add the port to the list of ports to expose, if one is specified in
# the web1 extension config
ports = set()
if 'web1' in extensions:
web1 = json.loads(extensions['web1'])
try:
hosts = web1['config']['hosts']
except KeyError:
pass
ports.update(host['port'] for host in hosts.values())

return self.render(
'setup.html',
filename=filename,
Expand All @@ -249,6 +260,7 @@ def reproduce(self, upload, repo_name=None, repo_url=None):
upload_short_id=upload.short_id,
experiment_url=experiment_url,
repo_name=repo_name, repo_url=repo_url,
expose_ports=' '.join(str(port) for port in sorted(ports)),
)


Expand Down

0 comments on commit 0f7895e

Please sign in to comment.