Skip to content

Commit e35b095

Browse files
committed
Update to support Minio endpoints secured by TLS
1 parent 3b75f41 commit e35b095

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"SXPASS",
1919
"SXTYPE",
2020
"SXUSER",
21+
"SXTOKEN",
2122
"Servivce",
2223
"Topo",
2324
"accesskey",

servicex/minio_adaptor.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,19 @@ class MinioAdaptor:
4444
# uses blocking http requests, so we can't use asyncio to interleave them.
4545
_download_executor = ThreadPoolExecutor(max_workers=5)
4646

47-
def __init__(self, mino_endpoint: str,
47+
def __init__(self, minio_endpoint: str,
48+
secured: bool = False,
4849
access_key: str = 'miniouser',
4950
secretkey: str = 'leftfoot1'):
50-
self._endpoint = mino_endpoint
51+
self._endpoint = minio_endpoint
52+
self._secured = secured
5153
self._access_key = access_key
5254
self._secretkey = secretkey
5355

5456
self._client = Minio(self._endpoint,
5557
access_key=self._access_key,
5658
secret_key=self._secretkey,
57-
secure=False)
59+
secure=self._secured)
5860

5961
@on_exception(backoff.constant, ResponseError, interval=0.1)
6062
def get_files(self, request_id):
@@ -118,7 +120,7 @@ def __init__(self, c: Optional[ConfigView] = None,
118120
if self._always is None and c is not None:
119121
self._config_adaptor = self._from_config(c)
120122

121-
def from_best(self, transation_info: Optional[Dict[str, str]] = None) -> MinioAdaptor:
123+
def from_best(self, transaction_info: Optional[Dict[str, str]] = None) -> MinioAdaptor:
122124
'''Using the information we have, create the proper Minio Adaptor with the correct
123125
endpoint and login information. Order of adaptor generation:
124126
@@ -136,14 +138,14 @@ def from_best(self, transation_info: Optional[Dict[str, str]] = None) -> MinioAd
136138
if self._always is not None:
137139
logging.getLogger(__name__).debug('Using the pre-defined minio_adaptor')
138140
return self._always
139-
if transation_info is not None:
140-
if 'minio-endpoint' in transation_info \
141-
and 'minio-access-key' in transation_info \
142-
and 'minio-secret-key' in transation_info:
141+
if transaction_info is not None:
142+
keys = ['minio-endpoint', 'minio-secured', 'minio-access-key', 'minio-secret-key']
143+
if all(k in transaction_info for k in keys):
143144
logging.getLogger(__name__).debug('Using the request-specific minio_adaptor')
144-
return MinioAdaptor(transation_info['minio-endpoint'],
145-
transation_info['minio-access-key'],
146-
transation_info['minio-secret-key'])
145+
return MinioAdaptor(transaction_info['minio-endpoint'],
146+
transaction_info['minio-secured'],
147+
transaction_info['minio-access-key'],
148+
transaction_info['minio-secret-key'])
147149
if self._config_adaptor is not None:
148150
logging.getLogger(__name__).debug('Using the config-file minio_adaptor')
149151
return self._config_adaptor

tests/test_minio_adaptor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,12 @@ def test_factory_from_request():
231231
info = {
232232
'minio-access-key': 'miniouser',
233233
'minio-endpoint': 'minio.servicex.com:9000',
234+
'minio-secured': False,
234235
'minio-secret-key': 'leftfoot1',
235236
}
236237
m = MinioAdaptorFactory().from_best(info)
237238
assert m._endpoint == 'minio.servicex.com:9000'
239+
assert not m._secured
238240
assert m._access_key == "miniouser"
239241
assert m._secretkey == "leftfoot1"
240242

0 commit comments

Comments
 (0)