blag commented on code in PR #24679:
URL: https://github.com/apache/airflow/pull/24679#discussion_r907677204
##########
airflow/www/templates/airflow/connection_list.html:
##########
@@ -0,0 +1,34 @@
+{#
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ #}
+
+ {% extends 'appbuilder/general/model/list.html' %}
+ {% from 'airflow/_messages.html' import show_message %}
+
+ {% block content %}
+ {% if is_using_secrets_backend() %}
+ {% call show_message(category='warning') %}
+ <b>WARNING: </b>The Airflow UI will not display Connections or
Variables stored in an alternative secrets backend.
Review Comment:
Nit: It seems a little verbose to mention "connections or variables" when
the page is only dedicated to showing connections. I might just mention
connections here.
##########
airflow/cli/commands/connection_command.py:
##########
@@ -73,13 +85,22 @@ def connections_get(args):
@suppress_logs_and_warning
def connections_list(args):
"""Lists all connections at the command line"""
+ airflow_console = AirflowConsole()
+ if CUSTOM_BACKEND:
+ airflow_console.print(
+ (
+ "WARNING: The Airflow CLI will not return Connections or "
+ "Variables stored in an alternative secrets backend."
Review Comment:
Since this is the same warning message as `connections_get`, it might be
useful to store it in a variable and reference it everywhere it's used - in the
`connections` and `variables` commands.
Maybe put it in a new `airflow.cli.commands._warnings` module?
##########
airflow/cli/commands/connection_command.py:
##########
@@ -59,11 +62,20 @@ def _connection_mapper(conn: Connection) -> Dict[str, Any]:
@suppress_logs_and_warning
def connections_get(args):
"""Get a connection."""
+ airflow_console = AirflowConsole()
+ if CUSTOM_BACKEND:
+ airflow_console.print(
+ (
+ "WARNING: The Airflow CLI will not return Connections or "
+ "Variables stored in an alternative secrets backend."
Review Comment:
It might be helpful to include examples of what are considered "alternative"
backends. Really, just listing the backends that are distributed with Airflow,
but are ignored by this command.
##########
airflow/www/templates/airflow/variable_list.html:
##########
@@ -1,45 +1,52 @@
{#
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-#}
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ #}
-{% extends 'appbuilder/general/model/list.html' %}
+ {% extends 'appbuilder/general/model/list.html' %}
+ {% from 'airflow/_messages.html' import show_message %}
-{% block content %}
- {% if can_create_variable() %}
- <div class="well well-sm pull-left">
- <form class="form-inline" action="{{
url_for('VariableModelView.varimport') }}" method="post"
enctype="multipart/form-data">
- {% if csrf_token %}
- <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
- {% endif %}
- <div class="form-group">
- <input class="form-control-file" type="file" name="file">
- </div>
- <button type="submit" class="btn">
- <span class="material-icons">cloud_upload</span>
- Import Variables
- </button>
- </form>
- </div>
- <div class="clearfix"></div>
- {% endif %}
- {{ super() }}
- <style>
- td { white-space: nowrap; text-overflow: ellipsis; overflow: hidden;
max-width:1px;}
- th { resize: horizontal; overflow: auto;}
- </style>
-{% endblock %}
+ {% block content %}
+
+ {% if is_using_secrets_backend() %}
+ {% call show_message(category='warning') %}
+ <b>WARNING: </b>The Airflow UI will not display Connections or Variables
stored in an alternative secrets backend.
Review Comment:
List those alternative backends distributed with Airflow here too.
And if you want extra credit, maybe count the number of
connections/variables not shown, only show the warning if there are include
that number in the warning message:
```jinja
WARNING:
{% trans count=num_variables %}
The Airflow UI will not display the {{ num_variables }} variable stored
in alternative secrets backends (like EnvironmentVariablesBackend
and SecretsBackend).
{% pluralize %}
The Airflow UI will not display the {{ num_variables }} variables stored
in alternative secrets backends (like EnvironmentVariablesBackend
and SecretsBackend).
{% endtrans %}
```
--
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]