jedcunningham commented on a change in pull request #19695:
URL: https://github.com/apache/airflow/pull/19695#discussion_r760574967



##########
File path: airflow/providers/cncf/kubernetes/hooks/kubernetes.py
##########
@@ -96,25 +99,49 @@ def get_ui_field_behaviour() -> Dict:
         }
 
     def __init__(
-        self, conn_id: str = default_conn_name, client_configuration: 
Optional[client.Configuration] = None
+        self,
+        conn_id: Optional[str] = default_conn_name,
+        client_configuration: Optional[client.Configuration] = None,
+        cluster_context: Optional[str] = None,
+        config_file: Optional[str] = None,
+        in_cluster: Optional[bool] = None,
     ) -> None:
         super().__init__()
         self.conn_id = conn_id
         self.client_configuration = client_configuration
+        self.cluster_context = cluster_context
+        self.config_file = config_file
+        self.in_cluster = in_cluster
+
+    @staticmethod
+    def _coalesce_param(*params):
+        for param in params:
+            if param is not None:
+                return param
 
     def get_conn(self) -> Any:
         """Returns kubernetes api session for use with requests"""
-        connection = self.get_connection(self.conn_id)
-        extras = connection.extra_dejson
-        in_cluster = extras.get("extra__kubernetes__in_cluster") or None
-        kubeconfig_path = extras.get("extra__kubernetes__kube_config_path") or 
None
+        if self.conn_id:
+            connection = self.get_connection(self.conn_id)
+            extras = connection.extra_dejson
+        else:
+            extras = {}
+        in_cluster = self._coalesce_param(
+            self.in_cluster, extras.get("extra__kubernetes__in_cluster") or 
None
+        )

Review comment:
       Oh, I completely overlooked this is a bool 🤦‍♂️. That said, the `or 
None` here isn't doing anything:
   
   ```suggestion
           in_cluster = self._coalesce_param(self.in_cluster, 
extras.get("extra__kubernetes__in_cluster"))
   ```
   
   Maybe short enough to be on a single line now too?




-- 
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]


Reply via email to