Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-vault
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-vault
Commits
e5dfc237
Verified
Commit
e5dfc237
authored
2 years ago
by
Antoine R. Dumont
Browse files
Options
Downloads
Patches
Plain Diff
api/server: Allow 'postgresql' configuration key entry
'local' has been deprecated for a while.
parent
ceb26750
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!159
api/server: Allow 'postgresql' configuration key entry
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/vault/api/server.py
+6
-5
6 additions, 5 deletions
swh/vault/api/server.py
swh/vault/tests/test_server.py
+6
-3
6 additions, 3 deletions
swh/vault/tests/test_server.py
with
12 additions
and
8 deletions
swh/vault/api/server.py
+
6
−
5
View file @
e5dfc237
...
...
@@ -61,15 +61,16 @@ def index():
def
check_config
(
cfg
:
Dict
[
str
,
Any
])
->
Dict
[
str
,
Any
]:
"""
Ensure the configuration is ok to run a local vault server, and propagate defaults.
"""
Ensure the configuration is ok to run a postgresql vault server, and propagate
defaults.
Raises:
EnvironmentError if the configuration is not for
loca
l instance
EnvironmentError if the configuration is not for
postgresq
l instance
ValueError if one of the following keys is missing: vault, cache, storage,
scheduler
Returns:
New configuration dict to instantiate a
loca
l vault server instance.
New configuration dict to instantiate a
postgresq
l vault server instance.
"""
cfg
=
cfg
.
copy
()
...
...
@@ -78,9 +79,9 @@ def check_config(cfg: Dict[str, Any]) -> Dict[str, Any]:
raise
ValueError
(
"
missing
'
vault
'
configuration
"
)
vcfg
=
cfg
[
"
vault
"
]
if
vcfg
[
"
cls
"
]
!=
"
local
"
:
if
vcfg
[
"
cls
"
]
not
in
(
"
local
"
,
"
postgresql
"
)
:
raise
EnvironmentError
(
"
The vault backend can only be started with a
'
loca
l
'
configuration
"
,
"
The vault backend can only be started with a
'
postgresq
l
'
configuration
"
,
)
# TODO: Soft-deprecation of args key. Remove when ready.
...
...
This diff is collapsed.
Click to expand it.
swh/vault/tests/test_server.py
+
6
−
3
View file @
e5dfc237
...
...
@@ -22,7 +22,7 @@ def swh_vault_server_config(swh_vault_config: Dict[str, Any]) -> Dict[str, Any]:
"""
Returns a vault server configuration, with ``storage``, ``scheduler`` and
``cache`` set at the toplevel
"""
return
{
"
vault
"
:
{
"
cls
"
:
"
loca
l
"
,
"
db
"
:
swh_vault_config
[
"
db
"
]},
"
vault
"
:
{
"
cls
"
:
"
postgresq
l
"
,
"
db
"
:
swh_vault_config
[
"
db
"
]},
"
client_max_size
"
:
1024
**
3
,
**
{
k
:
v
for
k
,
v
in
swh_vault_config
.
items
()
if
k
!=
"
db
"
},
}
...
...
@@ -160,14 +160,17 @@ def test_check_config_missing_vault_configuration() -> None:
def
test_check_config_not_local
()
->
None
:
"""
Wrong configuration raises
"""
expected_error
=
(
"
The vault backend can only be started with a
'
loca
l
'
configuration
"
"
The vault backend can only be started with a
'
postgresq
l
'
configuration
"
)
with
pytest
.
raises
(
EnvironmentError
,
match
=
expected_error
):
check_config
({
"
vault
"
:
{
"
cls
"
:
"
remote
"
}})
def
test_check_config_ok
(
swh_vault_server_config
)
->
None
:
@pytest.mark.parametrize
(
"
clazz
"
,
[
"
local
"
,
"
postgresql
"
])
def
test_check_config_ok
(
swh_vault_server_config
,
clazz
)
->
None
:
"""
Check that the default config is accepted
"""
config
=
swh_vault_server_config
.
copy
()
config
[
"
vault
"
][
"
cls
"
]
=
clazz
assert
check_config
(
swh_vault_server_config
)
is
not
None
...
...
This diff is collapsed.
Click to expand it.
Phabricator Migration user
@phabricator-migration
mentioned in merge request
!160 (closed)
·
2 years ago
mentioned in merge request
!160 (closed)
mentioned in merge request !160
Toggle commit list
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