Skip to content

Commit 9b80fca

Browse files
authored
Skip status update if OCP state has not changed (#26)
1 parent a90142a commit 9b80fca

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

generate-status/write_status.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import datetime
3+
from os import path
34

45
subject = context["repositories"]
56

@@ -21,10 +22,23 @@
2122
with open(f"../../{subject['directory']}/engagement.json", "r") as read_file:
2223
engagement = json.load(read_file)
2324

25+
if path.exists(f"../../{subject['directory']}/status.json"):
26+
with open(f"../../{subject['directory']}/status.json", "r") as read_file:
27+
existing_status = json.load(read_file)
28+
else:
29+
existing_status = False
30+
2431
if "current_state" not in subject["anarchy_subject"]["spec"]["vars"] or "desired_state" not in subject["anarchy_subject"]["spec"]["vars"]:
2532
print(f"Skipping {subject['directory']} - state information not found in the Anarchy subject")
2633
return
2734

35+
if existing_status:
36+
existing_ocp_subsystem = [subsystem for subsystem in existing_status["subsystems"] if subsystem["name"] == "OpenShift"]
37+
if len(existing_ocp_subsystem) > 0:
38+
if subject["anarchy_subject"]["spec"]["vars"]["current_state"] == existing_ocp_subsystem[0]["state"]:
39+
print(f"Skipping {subject['directory']} - state has not changed since last update")
40+
return
41+
2842
current_state = subject["anarchy_subject"]["spec"]["vars"]["current_state"]
2943
desired_state = subject["anarchy_subject"]["spec"]["vars"]["desired_state"]
3044

0 commit comments

Comments
 (0)