Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion dvc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ def _load_paths(conf, filename):
def resolve(path):
if os.path.isabs(path) or re.match(r"\w+://", path):
return path

# on windows convert slashes to backslashes
# to have path compatible with abs_conf_dir
if os.path.sep == "\\" and "/" in path:
path = path.replace("/", "\\")

return RelPath(os.path.join(abs_conf_dir, path))

return Config._map_dirs(conf, resolve)
Expand All @@ -403,7 +409,15 @@ def _map_dirs(conf, func):
dirs_schema = {
"cache": {"dir": func},
"remote": {
str: {"url": func, "gdrive_user_credentials_file": func}
str: {
"url": func,
"gdrive_user_credentials_file": func,
"gdrive_service_account_p12_file_path": func,
"credentialpath": func,
"keyfile": func,
"cert_path": func,
"key_path": func,
}
},
}
return Schema(dirs_schema, extra=ALLOW_EXTRA)(conf)
Expand Down
55 changes: 0 additions & 55 deletions tests/func/remote/test_gdrive.py

This file was deleted.

33 changes: 33 additions & 0 deletions tests/func/test_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import configobj
import pytest

Expand Down Expand Up @@ -112,3 +114,34 @@ def test_merging_two_levels(dvc):
def test_config_loads_without_error_for_non_dvc_repo(tmp_dir):
# regression testing for https://github.com/iterative/dvc/issues/3328
Config(validate=True)


@pytest.mark.parametrize(
"field, remote_url",
[
("credentialpath", "s3://mybucket/my/path"),
("credentialpath", "gs://my-bucket/path"),
("keyfile", "ssh://user@example.com:1234/path/to/dir"),
("cert_path", "webdavs://example.com/files/USERNAME/"),
("key_path", "webdavs://example.com/files/USERNAME/"),
("gdrive_service_account_p12_file_path", "gdrive://root/test"),
("gdrive_user_credentials_file", "gdrive://root/test"),
],
)
def test_load_relative_paths(dvc, field, remote_url):
# set field to test
with dvc.config.edit() as conf:
conf["remote"]["test"] = {"url": remote_url, field: "file.txt"}

# check if written paths are correct
dvc_dir = dvc.config.dvc_dir
assert dvc.config["remote"]["test"][field] == os.path.join(
dvc_dir, "..", "file.txt"
)

# load config and check that it contains what we expect
# (relative paths are evaluated correctly)
cfg = Config(dvc_dir)
assert cfg["remote"]["test"][field] == os.path.join(
dvc_dir, "..", "file.txt"
)