Skip to content

Commit 39664a4

Browse files
authored
calculate PROPOSED and PLANNED project stages (#192)
Adds code to the ack-discover utility that calculates whether an AWS service is in the PROPOSED or PLANNED project stage. To determine the PROPOSED services, we look for a Github Issue with the "Service Controller" label and a title matching either the abbreviated or full service name. To determine the PLANNED services, we check to see if the Github Issue for a PROPOSED service is in the "Planned" Github ProjectColumn of the "Service Controller Release Roadmap" Github Project in the community repo. Signed-off-by: Jay Pipes <[email protected]> By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 8d82203 commit 39664a4

File tree

1 file changed

+97
-7
lines changed

1 file changed

+97
-7
lines changed

tools/ack-discover/controller.py

Lines changed: 97 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@
2121
import project_stages
2222
import service
2323

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+
2432

2533
@dataclasses.dataclass
2634
class Release:
@@ -39,36 +47,50 @@ class Controller:
3947
source_repo_url: str = None
4048
image_repo: str = None
4149
chart_repo: str = None
50+
gh_issue_url: str = None
4251

4352

4453
def collect_all(writer, gh, ep_client, services):
4554
"""Returns a map, keyed by service package name, of ControllerInfo objects
4655
describing the ACK controllers.
4756
"""
48-
writer.debug("[collect_controllers] collecting ACK controller information ... ")
57+
writer.debug("[controller.collect_all] collecting ACK controller information ... ")
4958
ack_org = gh.get_organization("aws-controllers-k8s")
5059
result= {}
5160

5261
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+
5477
try:
5578
repo = ack_org.get_repo(service_package_name+"-controller")
5679
except github.UnknownObjectException:
5780
controller = Controller(
5881
service=service,
5982
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,
6285
source_repo_url=None,
6386
image_repo=None,
6487
chart_repo=None,
88+
gh_issue_url=gh_issue_url,
6589
)
6690
result[service_package_name] = controller
6791
continue
6892

6993
latest_release = Release()
70-
project_stage = project_stages.NONE
71-
maintenance_phase = maintenance_phases.NONE
7294

7395
image_repo_url = f"{ecrpublic.BASE_ECR_URL}/{service_package_name}-controller"
7496
image_repo_latest_version = None
@@ -105,6 +127,7 @@ def collect_all(writer, gh, ep_client, services):
105127
source_repo_url=repo.url,
106128
image_repo=image_repo,
107129
chart_repo=chart_repo,
130+
gh_issue_url=gh_issue_url,
108131
)
109132
result[service_package_name] = controller
110133
return result
@@ -115,7 +138,7 @@ def get_runtime_and_aws_sdk_version(writer, repo, image_version):
115138
controller's go.mod file at the specified image version (which is a Git tag
116139
on the repo...).
117140
"""
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)
119142
runtime_version = None
120143
aws_sdk_version = None
121144
try:
@@ -133,3 +156,70 @@ def get_runtime_and_aws_sdk_version(writer, repo, image_version):
133156
# proper Git tags for releases...
134157
pass
135158
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

Comments
 (0)