Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
bfb66773
Commit
bfb66773
authored
9 years ago
by
Erik Johnston
Browse files
Options
Downloads
Patches
Plain Diff
Allow specifying directories as config files
parent
747535f2
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/config/_base.py
+24
-6
24 additions, 6 deletions
synapse/config/_base.py
with
24 additions
and
6 deletions
synapse/config/_base.py
+
24
−
6
View file @
bfb66773
...
...
@@ -131,7 +131,8 @@ class Config(object):
"
-c
"
,
"
--config-path
"
,
action
=
"
append
"
,
metavar
=
"
CONFIG_FILE
"
,
help
=
"
Specify config file
"
help
=
"
Specify config file. Can be given multiple times and
"
"
may specify directories containing *.yaml files.
"
)
config_parser
.
add_argument
(
"
--generate-config
"
,
...
...
@@ -151,14 +152,31 @@ class Config(object):
generate_keys
=
config_args
.
generate_keys
config_files
=
[]
if
config_args
.
config_path
:
for
config_path
in
config_args
.
config_path
:
if
os
.
path
.
isdir
(
config_path
):
# We accept specifying directories as config paths, we search
# inside that directory for all files matching *.yaml, and then
# we apply them in *sorted* order.
config_files
.
extend
(
sorted
(
os
.
path
.
join
(
config_path
,
entry
)
for
entry
in
os
.
listdir
(
config_path
)
if
entry
.
endswith
(
"
.yaml
"
)
and
os
.
path
.
isfile
(
os
.
path
.
join
(
config_path
,
entry
)
)
))
else
:
config_files
.
append
(
config_path
)
if
config_args
.
generate_config
:
if
not
config_
args
.
config_path
:
if
not
config_
files
:
config_parser
.
error
(
"
Must supply a config file.
\n
A config file can be automatically
"
"
generated using
\"
--generate-config -H SERVER_NAME
"
"
-c CONFIG-FILE
\"
"
)
(
config_path
,)
=
config_
args
.
config_path
(
config_path
,)
=
config_
files
if
not
os
.
path
.
exists
(
config_path
):
config_dir_path
=
os
.
path
.
dirname
(
config_path
)
config_dir_path
=
os
.
path
.
abspath
(
config_dir_path
)
...
...
@@ -202,7 +220,7 @@ class Config(object):
obj
.
invoke_all
(
"
add_arguments
"
,
parser
)
args
=
parser
.
parse_args
(
remaining_args
)
if
not
config_
args
.
config_path
:
if
not
config_
files
:
config_parser
.
error
(
"
Must supply a config file.
\n
A config file can be automatically
"
"
generated using
\"
--generate-config -H SERVER_NAME
"
...
...
@@ -213,8 +231,8 @@ class Config(object):
config_dir_path
=
os
.
path
.
abspath
(
config_dir_path
)
specified_config
=
{}
for
config_
path
in
config_
args
.
config_path
:
yaml_config
=
cls
.
read_config_file
(
config_
path
)
for
config_
file
in
config_
files
:
yaml_config
=
cls
.
read_config_file
(
config_
file
)
specified_config
.
update
(
yaml_config
)
server_name
=
specified_config
[
"
server_name
"
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment