Skip to content

Commit

Permalink
Add resource dispatcher debug messages (#376)
Browse files Browse the repository at this point in the history
* Add additional print statements for debugging

* Disable error handling

* Add check for empty repo

* Remove deliberate crash post testing and cleanup whitespace

* Update gitlab-to-argo.yml

* Update gitlab-to-argo.yml

* Update gitlab-to-argo.yml

* Update gitlab-to-argo.yml

* Update gitlab-to-argo.yml

* Update gitlab-to-argo.yml

* Update gitlab-to-argo.yml

* Update gitlab-to-argo.yml

* Update gitlab-to-argo.yml

Co-authored-by: Øystein Bedin <[email protected]>
  • Loading branch information
MAHDTech and oybed authored Nov 17, 2021
1 parent 9cf772c commit 74376da
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions bootstrap/core/tools/dispatcher/configs/gitlab-to-argo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,28 +39,35 @@ tasks:
import gitlab
import dateutil.parser
print("Checking projects from https://{{ ENV_GITLAB_BASE_URL }}" )
g = gitlab.Gitlab(
"https://{{ ENV_GITLAB_BASE_URL }}" ,
private_token="{{ ENV_GITLAB_PRIVATE_TOKEN | trim }}"
)
"https://{{ ENV_GITLAB_BASE_URL }}" ,
private_token="{{ ENV_GITLAB_PRIVATE_TOKEN | trim }}"
)
def should_process_project(project):
repository_tree = project.repository_tree(all=True)
try:
repository_tree = project.repository_tree(all=True)
except Exception as err:
print("Failed to walk repository file tree, are there any files in this repository?")
print(err)
return False
engagement_file = [f for f in repository_tree if f["path"] == 'engagement.json']
if not len(engagement_file) == 1:
# Engagement file doesn't exist
return False
engagement = json.loads(project.files.get('engagement.json', "master").decode())
print("Checking Engagement: %s - %s"
%(engagement.get('customer_name', 'Undefined'),
engagement.get('project_name', 'Undefined')))
%(engagement.get('customer_name', 'Undefined'),
engagement.get('project_name', 'Undefined')))
if not ("launch" in engagement and "launched_date_time" in engagement["launch"]):
# Engagement file doesn't have the correct launch data in it
return False
if "archive_date" in engagement:
try:
archive_date_ts = dateutil.parser.parse(engagement["archive_date"]).timestamp()
except ValueError:
print("Could not parse archive date: %s" %engagement["archive_date"])
return False
now_ts = datetime.utcnow().timestamp()
if now_ts > archive_date_ts:
Expand Down

0 comments on commit 74376da

Please sign in to comment.