feluelle commented on a change in pull request #5305: [AIRFLOW-986] HiveCliHook
ignores 'proxy_user' value in a connection's extra parameter
URL: https://github.com/apache/airflow/pull/5305#discussion_r286425571
##########
File path: airflow/hooks/hive_hooks.py
##########
@@ -122,11 +122,13 @@ def _prepare_cli_cmd(self):
template = utils.replace_hostname_pattern(
utils.get_components(template))
- proxy_user = "" # noqa
- if conn.extra_dejson.get('proxy_user') == "login" and
conn.login:
+ proxy_user = conn.extra_dejson.get('proxy_user', "") # noqa
Review comment:
actually.. sorry but what do you think of a _factory_ for the `proxy_user`
like:
```
def _get_proxy_user(self):
proxy_user_value = conn.extra_dejson.get('proxy_user', "")
if proxy_user_value == "login" and conn.login:
return "hive.server2.proxy.user={login}".format(login=conn.login)
if proxy_user_value == "owner" and self.run_as:
return "hive.server2.proxy.user={run_as}".format(run_as=self.run_as)
if proxy_user_value != "": # There is a custom proxy user
return
"hive.server2.proxy.user={proxy_user_value}".format(proxy_user_value=proxy_user_value)
return proxy_user_value # The default proxy user (undefined)
```
and then call `proxy_user = self._get_proxy_user()`
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services