dstandish commented on a change in pull request #19695:
URL: https://github.com/apache/airflow/pull/19695#discussion_r760578615
##########
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:
unfortunately the `or None` is meaningful and needed.
apparently when you create a connection in the UI, and when that conn type
has these form customizations (which i am really not a huge fan of fwiw), then
it creates an empty string value e.g. `extra__kubernetes__in_cluster: ""` in
the extra.
so, we need to get rid of that empty string and replace it with None, and
that's what this is doing.
--
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]