21
21
import project_stages
22
22
import service
23
23
24
+ # A cache of Github Issues for new service controllers
25
+ _sc_issues = None
26
+ # The Github Project for tracking service controllers
27
+ _sc_proj = None
28
+ # The project cards associated with the Planned column in the service
29
+ # controller Github Project
30
+ _sc_proj_planned_cards = None
31
+
24
32
25
33
@dataclasses .dataclass
26
34
class Release :
@@ -39,36 +47,50 @@ class Controller:
39
47
source_repo_url : str = None
40
48
image_repo : str = None
41
49
chart_repo : str = None
50
+ gh_issue_url : str = None
42
51
43
52
44
53
def collect_all (writer , gh , ep_client , services ):
45
54
"""Returns a map, keyed by service package name, of ControllerInfo objects
46
55
describing the ACK controllers.
47
56
"""
48
- writer .debug ("[collect_controllers ] collecting ACK controller information ... " )
57
+ writer .debug ("[controller.collect_all ] collecting ACK controller information ... " )
49
58
ack_org = gh .get_organization ("aws-controllers-k8s" )
50
59
result = {}
51
60
52
61
for service_package_name , service in services .items ():
53
- writer .debug (f"[collect_controllers] finding controller info for { service_package_name } ..." )
62
+ writer .debug (f"[controller.collect_all] finding controller info for { service_package_name } ..." )
63
+
64
+ project_stage = project_stages .NONE
65
+ maintenance_phase = maintenance_phases .NONE
66
+ # We check if there has been a GH issue created for the AWS service and
67
+ # if that GH issue has been placed in the Service Controller Github
68
+ # Project's "Planned" ProjectColumn.
69
+ gh_issue = get_controller_request_issue (writer , gh , service )
70
+ gh_issue_url = None
71
+ if gh_issue is not None :
72
+ gh_issue_url = gh_issue .html_url
73
+ project_stage = project_stages .PROPOSED
74
+ if is_planned (writer , gh , gh_issue ):
75
+ project_stage = project_stages .PLANNED
76
+
54
77
try :
55
78
repo = ack_org .get_repo (service_package_name + "-controller" )
56
79
except github .UnknownObjectException :
57
80
controller = Controller (
58
81
service = service ,
59
82
latest_release = None ,
60
- project_stage = project_stages . NONE ,
61
- maintenance_phase = maintenance_phases . NONE ,
83
+ project_stage = project_stage ,
84
+ maintenance_phase = maintenance_phase ,
62
85
source_repo_url = None ,
63
86
image_repo = None ,
64
87
chart_repo = None ,
88
+ gh_issue_url = gh_issue_url ,
65
89
)
66
90
result [service_package_name ] = controller
67
91
continue
68
92
69
93
latest_release = Release ()
70
- project_stage = project_stages .NONE
71
- maintenance_phase = maintenance_phases .NONE
72
94
73
95
image_repo_url = f"{ ecrpublic .BASE_ECR_URL } /{ service_package_name } -controller"
74
96
image_repo_latest_version = None
@@ -105,6 +127,7 @@ def collect_all(writer, gh, ep_client, services):
105
127
source_repo_url = repo .url ,
106
128
image_repo = image_repo ,
107
129
chart_repo = chart_repo ,
130
+ gh_issue_url = gh_issue_url ,
108
131
)
109
132
result [service_package_name ] = controller
110
133
return result
@@ -115,7 +138,7 @@ def get_runtime_and_aws_sdk_version(writer, repo, image_version):
115
138
controller's go.mod file at the specified image version (which is a Git tag
116
139
on the repo...).
117
140
"""
118
- writer .debug ("[get_runtime_and_aws_sdk_version] fetching go.mod for" , repo .name , "at Git tag" , image_version )
141
+ writer .debug ("[controller. get_runtime_and_aws_sdk_version] fetching go.mod for" , repo .name , "at Git tag" , image_version )
119
142
runtime_version = None
120
143
aws_sdk_version = None
121
144
try :
@@ -133,3 +156,70 @@ def get_runtime_and_aws_sdk_version(writer, repo, image_version):
133
156
# proper Git tags for releases...
134
157
pass
135
158
return runtime_version , aws_sdk_version
159
+
160
+
161
+ def get_controller_request_issue (writer , gh , service ):
162
+ """Returns the Github Issue for the service, or None if no such issue
163
+ exists.
164
+ """
165
+ global _sc_issues
166
+ ack_org = gh .get_organization ("aws-controllers-k8s" )
167
+ community_repo = ack_org .get_repo ("community" )
168
+ writer .debug (f"[controller.get_github_issue] finding Github Issue for { service .package_name } ..." )
169
+ if _sc_issues is None :
170
+ sc_label = community_repo .get_label (name = "Service Controller" )
171
+ _sc_issues = community_repo .get_issues (labels = [sc_label ])
172
+
173
+ for issue in _sc_issues :
174
+ # The GH issues with label "Service Controller" all have the same title
175
+ # pattern: "<Service Name> service controller"
176
+ issue_title = issue .title .lower ().replace ("service controller" , "" )
177
+ issue_title = issue_title .strip ()
178
+ if issue_title == service .package_name .lower ():
179
+ return issue
180
+ if service .full_name is not None :
181
+ full_name = service .full_name .lower ()
182
+ if issue_title == full_name :
183
+ return issue
184
+ if service .abbrev_name is not None :
185
+ abbrev_name = service .abbrev_name .lower ()
186
+ if issue_title == abbrev_name :
187
+ return issue
188
+ return None
189
+
190
+
191
+ def get_service_controller_project (writer , gh ):
192
+ """Returns the GH project for tracking service controllers.
193
+ """
194
+ global _sc_proj
195
+ ack_org = gh .get_organization ("aws-controllers-k8s" )
196
+ community_repo = ack_org .get_repo ("community" )
197
+ writer .debug (f"[controller.get_service_controller_project] finding service controller Github Project ..." )
198
+ if _sc_proj is None :
199
+ projs = community_repo .get_projects ()
200
+ for p in projs :
201
+ if p .name == "Service Controller Release Roadmap" :
202
+ _sc_proj = p
203
+ break
204
+ return _sc_proj
205
+
206
+
207
+ def is_planned (writer , gh , gh_issue ):
208
+ """Returns whether the supplied GH issue for a service controller appears
209
+ in the Planned board on our Service Controller Github Project.
210
+ """
211
+ global _sc_proj_planned_cards
212
+ ack_org = gh .get_organization ("aws-controllers-k8s" )
213
+ community_repo = ack_org .get_repo ("community" )
214
+ writer .debug (f"[controller.is_planned] looking up project card matching Github Issue { gh_issue .id } ..." )
215
+ if _sc_proj_planned_cards is None :
216
+ sc_proj = get_service_controller_project (writer , gh )
217
+ for pc in sc_proj .get_columns ():
218
+ if pc .name == "Planned" :
219
+ _sc_proj_planned_cards = pc .get_cards ()
220
+ break
221
+ for pc in _sc_proj_planned_cards :
222
+ if pc .content_url == gh_issue .url :
223
+ return True
224
+
225
+ return False
0 commit comments