BasPH commented on a change in pull request #14641:
URL: https://github.com/apache/airflow/pull/14641#discussion_r588993911
##########
File path: airflow/www/views.py
##########
@@ -2653,42 +2653,39 @@ class ConfigurationView(AirflowBaseView):
)
def conf(self):
"""Shows configuration."""
- raw = request.args.get('raw') == "true"
title = "Airflow Configuration"
- subtitle = AIRFLOW_CONFIG
- # Don't show config when expose_config variable is False in airflow
config
+
if conf.getboolean("webserver", "expose_config"):
- with open(AIRFLOW_CONFIG) as file:
- config = file.read()
table = [
(section, key, value, source)
for section, parameters in conf.as_dict(True, True).items()
for key, (value, source) in parameters.items()
]
- else:
- config = (
- "# Your Airflow administrator chose not to expose the "
- "configuration, most likely for security reasons."
+
+ if request.args.get('raw') == "true":
+ return Response(response=json.dumps(table), status=200,
mimetype="application/json")
Review comment:
To be consistent, I figured the `raw=true` argument should also return
the rendered configuration. The airflow.cfg content was loaded as lines of
text, but the rendered configuration is loaded as a list of tuples. So, I had
to decide on an output format and figured JSON would make sense.
Thinking about it, the new REST API does exactly what we want (content
negotiation,
(https://github.com/apache/airflow/blob/master/airflow/api_connexion/endpoints/config_endpoint.py#L66-L87).
We could also simply remove the `raw=true` argument and tell people to use the
REST API, instead of maintaining this? I've never seen anybody using it?
----------------------------------------------------------------
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]