You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/12/01 21:04:42 UTC
[GitHub] [airflow] dstandish commented on a change in pull request #19695: Add config and context params to KubernetesHook
dstandish commented on a change in pull request #19695:
URL: https://github.com/apache/airflow/pull/19695#discussion_r760569205
##########
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:
hmm it's a good question but no i think you if the hook is passed a non-default, i.e. a non-None, e.g. a `False`, then we should definitely respect that.
example is, the Connection object has `True` but in our usage we want to override it with `False`. we should support that and apply the `hook params trumps connection` rule
--
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: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org