mik-laj commented on a change in pull request #7130: [AIRFLOW-6533] Add cli
commands to manage config
URL: https://github.com/apache/airflow/pull/7130#discussion_r365514487
##########
File path: airflow/cli/commands/config_command.py
##########
@@ -17,11 +17,54 @@
"""Config sub-commands"""
import io
-from airflow.configuration import conf
+from configupdater import ConfigUpdater, NoSectionError
+
+from airflow.configuration import AIRFLOW_CONFIG, AirflowConfigException, conf
def show_config(args):
"""Show current application configuration"""
with io.StringIO() as output:
- conf.write(output)
+ if args.section:
+ section = args.section
+ if conf.has_section(section):
+ conf._write_section( # pylint: disable=protected-access
+ fp=output,
+ section_name=section,
+ section_items=conf.getsection(section).items(),
+ delimiter=" = "
+ )
+ else:
+ raise AirflowConfigException(f"No section '{section}'")
+ else:
+ conf.write(output)
print(output.getvalue())
+
+
+def set_config_option(args):
+ """Set option in config"""
+ print(f"Making change in {AIRFLOW_CONFIG}")
+
+ if args.executor:
+ section, key, value = "core", "executor", args.executor
+ elif args.dagdir:
+ section, key, value = "core", "dags_folders", args.dagdir
Review comment:
```
airflow ocnfig set core executor MyAwesomeScheduler
```
vs
```
airflow config set --executor MyAwesomeExecutor
airflow config set --section core --option executor --value MyAwesomeExecutor
```
If we simplify, all options will be short enough that they will not require
simplification
----------------------------------------------------------------
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