Skip to content

[MEDIUM] setup_kubearchive_client() missing docstring #122

Description

@geored

File

src/helpers/kubearchive_integration.py, line 31

Description

The public function setup_kubearchive_client() has no docstring. This is the entry point for initializing the KubeArchive client and manages a global singleton instance (ka_client). Without documentation, callers cannot easily understand:

  • What the parameters endpoint_discovery and k8s_core_api are expected to provide
  • That the function returns an Optional[KubeArchiveClient] (returning None when endpoint discovery fails)
  • That results are cached in a module-level global (ka_client), so subsequent calls skip initialization
  • Under what conditions the function may return None

Suggested Remediation

Add a docstring to setup_kubearchive_client() covering:

  1. Summary -- one-line description of what the function does (initializes and caches the KubeArchive client singleton).
  2. Args -- document endpoint_discovery (used to auto-discover the KubeArchive API endpoint) and k8s_core_api (Kubernetes CoreV1 API client for namespace listing / auth).
  3. Returns -- Optional[KubeArchiveClient]: the initialized client, or None if endpoint discovery fails.
  4. Caching behavior -- note that the client is stored in the module-level ka_client global and only initialized once; subsequent calls return the cached instance.

Example:

async def setup_kubearchive_client(
    endpoint_discovery: 'KubeArchiveEndpointDiscovery',
    k8s_core_api: client.CoreV1Api
) -> Optional['KubeArchiveClient']:
    """Initialize and cache the KubeArchive client singleton.

    Discovers the KubeArchive API endpoint and creates a client instance.
    The client is cached in a module-level global so subsequent calls
    return the same instance without re-discovery.

    Args:
        endpoint_discovery: Discovery helper used to locate the KubeArchive
            API endpoint in the cluster.
        k8s_core_api: Kubernetes CoreV1 API client, passed through to the
            KubeArchiveClient for namespace and resource queries.

    Returns:
        The initialized KubeArchiveClient, or None if endpoint discovery
        fails (e.g., KubeArchive is not deployed in the cluster).
    """

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions