Skip to content

Commit

Permalink
Remove hard coded repo owner from index html
Browse files Browse the repository at this point in the history
Replace hard coded value with owner of the monitored freeipa repo.

Remove unnecessary functions used to build template's data dictionary.

Signed-off-by: Armando Neto <abiagion@redhat.com>
  • Loading branch information
netoarmando committed Feb 18, 2020
1 parent eeecfb6 commit 3c1636d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 29 deletions.
2 changes: 1 addition & 1 deletion tasks/index_template.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<a href="{{ cloud_jobs_url }}"><img src="{{ cloud_url }}prci.png"></a>
<h4 class="text-center"> {{ obj_data.hostname }} </h4>
<h4 class="text-center"> {{ obj_data.uuid }} </h4>
<h4 class="text-center"> <a href="https://github.com/freeipa/freeipa/pull/{{ obj_data.pr_number }}"> PR#{{ obj_data.pr_number }} </a> - {{ obj_data.task_name }}
<h4 class="text-center"> <a href="https://github.com/{{ obj_data.repo_owner }}/freeipa/pull/{{ obj_data.pr_number }}"> PR#{{ obj_data.pr_number }} </a> - {{ obj_data.task_name }}
{% if obj_data.returncode == '0' %}
<i class="fas fa-check" style="color:#28A745"></i> {% else %}
<i class="fas fa-times" style="color:#CB2431"></i>
Expand Down
50 changes: 22 additions & 28 deletions tasks/remote_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,28 +74,8 @@ def make_object(root, obj):
}


def make_objects(root, objects):
"""
Go through subdirs and files in order to gather "object" data.
"""
for f in objects:
yield make_object(root, f)


def make_aws_data(remote_path, uuid, pr_number, pr_author, task_name,
returncode, hostname, objects):
"""
Create AWS data for Jinja.
"""
return {
"remote_path": remote_path, "uuid": uuid, "pr_number": pr_number,
"pr_author": pr_author, "task_name": task_name,
"returncode": returncode, "hostname": hostname,"objects": objects
}


def create_local_indeces(uuid, pr_number, pr_author, task_name, returncode,
hostname):
hostname, repo_owner):
"""
Go through whole job result directory structure and gather all files with
metadata for every directory. Note: AWS S3 does not support classic web
Expand All @@ -108,11 +88,18 @@ def create_local_indeces(uuid, pr_number, pr_author, task_name, returncode,
job_path_start = job_dir.rfind(os.sep) + 1
for root, dirs, files in os.walk(job_dir):
remote_path = root[job_path_start:]
objects = list(make_objects(root, dirs + files))
data = make_aws_data(
remote_path, uuid, pr_number, pr_author,
task_name, returncode, hostname, objects
)
objects = [make_object(root, obj) for obj in dirs + files]
data = {
"remote_path": remote_path,
"uuid": uuid,
"pr_number": pr_number,
"pr_author": pr_author,
"task_name": task_name,
"returncode": returncode,
"hostname": hostname,
"repo_owner": repo_owner,
"objects": objects,
}
write_index(data, root)


Expand Down Expand Up @@ -204,8 +191,15 @@ def _run(self):
self.pr_number, self.pr_author,
self.task_name, self.returncode)

create_local_indeces(self.uuid, self.pr_number, self.pr_author,
self.task_name, self.returncode, self.hostname)
create_local_indeces(
uuid=self.uuid,
pr_number=self.pr_number,
pr_author=self.pr_author,
task_name=self.task_name,
returncode=self.returncode,
hostname=self.hostname,
repo_owner=self.repo_owner,
)

aws_sync_cmd = ['aws', 's3', 'sync', src, dest]
sync_all_except_gz = ['--include=*', '--exclude=*.gz']
Expand Down

0 comments on commit 3c1636d

Please sign in to comment.