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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Renaud Boyer
swh-vault
Commits
4ce54699
Commit
4ce54699
authored
1 year ago
by
Nicolas Dandrimont
Browse files
Options
Downloads
Patches
Plain Diff
cookers: ensure objstorage configuration is taken into account
parent
737570ce
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
swh/vault/cookers/__init__.py
+10
-5
10 additions, 5 deletions
swh/vault/cookers/__init__.py
swh/vault/tests/test_init_cookers.py
+5
-0
5 additions, 0 deletions
swh/vault/tests/test_init_cookers.py
with
15 additions
and
5 deletions
swh/vault/cookers/__init__.py
+
10
−
5
View file @
4ce54699
...
...
@@ -11,6 +11,7 @@ from typing import Any, Dict, List, Type
from
swh.core.config
import
load_named_config
from
swh.core.config
import
read
as
read_config
from
swh.model.swhids
import
CoreSWHID
,
ObjectType
from
swh.objstorage.factory
import
get_objstorage
from
swh.storage
import
get_storage
from
swh.vault.cookers.base
import
DEFAULT_CONFIG
,
DEFAULT_CONFIG_PATH
,
BaseVaultCooker
from
swh.vault.cookers.directory
import
DirectoryCooker
...
...
@@ -72,12 +73,10 @@ def check_config(cfg: Dict[str, Any]) -> Dict[str, Any]:
"
This vault backend can only be a
'
remote
'
configuration
"
)
# TODO: Soft-deprecation of args key. Remove when ready.
vcfg
.
update
(
vcfg
.
get
(
"
args
"
,
{}))
# Default to top-level value if any
if
"
storage
"
not
in
vcfg
:
vcfg
[
"
storage
"
]
=
cfg
.
get
(
"
storage
"
)
for
key
in
(
"
storage
"
,
"
objstorage
"
):
if
key
not
in
vcfg
and
key
in
cfg
:
vcfg
[
key
]
=
cfg
[
key
]
if
not
vcfg
.
get
(
"
storage
"
):
raise
ValueError
(
"
invalid configuration: missing
'
storage
'
config entry.
"
)
...
...
@@ -123,6 +122,11 @@ def get_cooker(bundle_type: str, swhid: CoreSWHID):
else
:
graph
=
None
if
vcfg
.
get
(
"
objstorage
"
):
objstorage
=
get_objstorage
(
**
vcfg
[
"
objstorage
"
])
else
:
objstorage
=
None
kwargs
=
{
k
:
v
for
(
k
,
v
)
in
cfg
.
items
()
if
k
in
(
"
max_bundle_size
"
,
"
thread_pool_size
"
)
}
...
...
@@ -131,6 +135,7 @@ def get_cooker(bundle_type: str, swhid: CoreSWHID):
swhid
,
backend
=
backend
,
storage
=
storage
,
objstorage
=
objstorage
,
graph
=
graph
,
**
kwargs
,
)
This diff is collapsed.
Click to expand it.
swh/vault/tests/test_init_cookers.py
+
5
−
0
View file @
4ce54699
...
...
@@ -96,6 +96,7 @@ def test_get_cooker_config_ko(
"
url
"
:
"
mock://vault-backend
"
,
},
"
storage
"
:
{
"
cls
"
:
"
remote
"
,
"
url
"
:
"
mock://storage-url
"
},
"
objstorage
"
:
{
"
cls
"
:
"
memory
"
},
},
],
)
...
...
@@ -108,3 +109,7 @@ def test_get_cooker_nominal(config_ok, tmp_path, monkeypatch):
assert
cooker
is
not
None
assert
isinstance
(
cooker
,
tuple
(
COOKER_TYPES
[
cooker_type
]))
if
config_ok
.
get
(
"
objstorage
"
)
or
config_ok
[
"
vault
"
].
get
(
"
objstorage
"
):
assert
cooker
.
objstorage
is
not
None
else
:
assert
cooker
.
objstorage
is
None
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