Skip to content

Commit

Permalink
fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
rnetser committed Jul 25, 2024
1 parent a96bbe3 commit 5645749
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions scripts/resource/class_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,24 @@ def parse_explain(

LOGGER.debug(f"\n{yaml.dump(resource_dict)}")

if (api_group_real_name := resource_dict.get("GROUP")) or (
api_group_real_name := resource_dict["VERSION"].split("/")[0]
):
api_group_real_name = resource_dict.get("GROUP")
# If API Group is not present in resource, try to get it from VERSION
if not api_group_real_name and (api_group_match := re.match(r"(\w+)/", resource_dict["VERSION"])):
api_group_real_name = api_group_match.group(1) # noqa FCN001

if api_group_real_name:
api_group_for_resource_api_group = api_group_real_name.upper().replace(".", "_")
resource_dict["GROUP"] = api_group_for_resource_api_group
missing_api_group_in_resource: bool = not hasattr(Resource.ApiGroup, api_group_for_resource_api_group)

if missing_api_group_in_resource:
LOGGER.warning(
f"Missing API Group in Resource\n"
f"Please add `Resource.ApiGroup.{api_group_real_name} = {api_group_real_name}` "
f"Please add `Resource.ApiGroup.{api_group_for_resource_api_group} = {api_group_real_name}` "
"manually into ocp_resources/resource.py under Resource class > ApiGroup class."
)

if not api_group_real_name:
else:
api_version_for_resource_api_version = resource_dict["VERSION"].upper()
missing_api_version_in_resource: bool = not hasattr(Resource.ApiVersion, api_version_for_resource_api_version)

Expand Down

0 comments on commit 5645749

Please sign in to comment.