amoghrajesh commented on code in PR #65212:
URL: https://github.com/apache/airflow/pull/65212#discussion_r3084656865
##########
providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/hooks/kubernetes.py:
##########
@@ -818,6 +818,31 @@ def __init__(
self._event_polling_fallback = False
self._config_loaded = False
+ def _uses_exec_auth(self, kubeconfig_data: dict, context: str | None =
None) -> bool:
+ """
+ Detect if the active kubeconfig context uses exec-based authentication.
+
+ Exec plugins return short-lived tokens (EKS, GKE, etc). Only the user
+ tied to the active context is checked.
+ """
+ active_context = context or kubeconfig_data.get("current-context")
+
+ active_user: str | None = None
+ for ctx in kubeconfig_data.get("contexts", []):
+ if ctx.get("name") == active_context:
+ active_user = ctx.get("context", {}).get("user")
+ break
+
+ users = kubeconfig_data.get("users", [])
+ if active_user is not None:
+ for user in users:
+ if user.get("name") == active_user:
+ return "exec" in user.get("user", {})
+ return False
+
+ # fallback to check all users if active context user cannot be
resolved; this is a safe fallback since it errs on the side of not caching
+ return any("exec" in u.get("user", {}) for u in users)
+
async def _load_config(self):
"""Load Kubernetes configuration once per hook instance."""
Review Comment:
Valid, made the change.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]