Skip to content

refactor: Use /apis JSON endpoint instead of parsing oc api-resources text output #2668

@myakove

Description

@myakove

Problem

identify_missing_resources() and build_dynamic_resource_to_api_mapping() in class_generator/core/schema.py parse the text output of oc api-resources --no-headers, which is fragile due to shifting column positions (e.g., when SHORTNAMES is empty).

Suggested Improvement

Use oc get --raw /apis to get structured JSON of all API groups, then per-group calls (oc get --raw /apis/<group>/<version>) to get resource kinds. This is more reliable than text parsing.

Suggested by @rnetser in #2667 (comment)

Scope

  • Refactor identify_missing_resources() to use JSON API discovery
  • Refactor build_dynamic_resource_to_api_mapping() similarly
  • Update tests accordingly

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions