mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
s3: respect credentialpath/configpath (#5973)
This commit is contained in:
@@ -124,6 +124,14 @@ class BaseS3FileSystem(FSSpecWrapper):
|
||||
login_info["profile"]
|
||||
)
|
||||
|
||||
shared_creds = config.get("credentialpath")
|
||||
if shared_creds:
|
||||
os.environ.setdefault("AWS_SHARED_CREDENTIALS_FILE", shared_creds)
|
||||
|
||||
config_path = config.get("configpath")
|
||||
if config_path:
|
||||
os.environ.setdefault("AWS_CONFIG_FILE", config_path)
|
||||
|
||||
return unflatten(
|
||||
{
|
||||
key: value
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
import textwrap
|
||||
|
||||
@@ -41,6 +42,31 @@ def test_verify_ssl_default_param(dvc):
|
||||
assert fs.fs_args["client_kwargs"]["verify"]
|
||||
|
||||
|
||||
def test_s3_config_credentialpath(dvc, monkeypatch):
|
||||
environment = {}
|
||||
monkeypatch.setattr(os, "environ", environment)
|
||||
|
||||
config = {"url": url, "credentialpath": "somewhere"}
|
||||
S3FileSystem(dvc, config)
|
||||
assert environment["AWS_SHARED_CREDENTIALS_FILE"] == "somewhere"
|
||||
environment.clear()
|
||||
|
||||
config = {"url": url, "configpath": "somewhere"}
|
||||
S3FileSystem(dvc, config)
|
||||
assert environment["AWS_CONFIG_FILE"] == "somewhere"
|
||||
environment.clear()
|
||||
|
||||
config = {
|
||||
"url": url,
|
||||
"credentialpath": "somewhere",
|
||||
"configpath": "elsewhere",
|
||||
}
|
||||
S3FileSystem(dvc, config)
|
||||
assert environment["AWS_SHARED_CREDENTIALS_FILE"] == "somewhere"
|
||||
assert environment["AWS_CONFIG_FILE"] == "elsewhere"
|
||||
environment.clear()
|
||||
|
||||
|
||||
def test_ssl_verify_bool_param(dvc):
|
||||
config = {"url": url, "ssl_verify": False}
|
||||
fs = S3FileSystem(dvc, config)
|
||||
|
||||
Reference in New Issue
Block a user