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:
- Summary -- one-line description of what the function does (initializes and caches the KubeArchive client singleton).
- Args -- document
endpoint_discovery (used to auto-discover the KubeArchive API endpoint) and k8s_core_api (Kubernetes CoreV1 API client for namespace listing / auth).
- Returns --
Optional[KubeArchiveClient]: the initialized client, or None if endpoint discovery fails.
- 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).
"""
File
src/helpers/kubearchive_integration.py, line 31Description
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:endpoint_discoveryandk8s_core_apiare expected to provideOptional[KubeArchiveClient](returningNonewhen endpoint discovery fails)ka_client), so subsequent calls skip initializationNoneSuggested Remediation
Add a docstring to
setup_kubearchive_client()covering:endpoint_discovery(used to auto-discover the KubeArchive API endpoint) andk8s_core_api(Kubernetes CoreV1 API client for namespace listing / auth).Optional[KubeArchiveClient]: the initialized client, orNoneif endpoint discovery fails.ka_clientglobal and only initialized once; subsequent calls return the cached instance.Example: