1
- from typing import TypedDict
2
-
3
1
from minio import Minio
4
2
from requests import ConnectionError , Response , get
5
3
6
4
from testcontainers .core .container import DockerContainer
7
5
from testcontainers .core .waiting_utils import wait_container_is_ready
8
6
9
7
10
- class MinioConfig (TypedDict ):
11
- endpoint : str
12
- access_key : str
13
- secret_key : str
14
-
15
-
16
8
class MinioContainer (DockerContainer ):
17
9
def __init__ (
18
10
self ,
@@ -37,25 +29,28 @@ def get_client(self, **kwargs) -> Minio:
37
29
38
30
Returns:
39
31
Minio: Python Minio Client according to
40
- https://min.io/docs/minio/linux/developers/python/API.html
32
+ https://min.io/docs/minio/linux/developers/python/API.html
41
33
"""
34
+ host_ip = self .get_container_host_ip ()
35
+ exposed_port = self .get_exposed_port (self .port_to_expose )
42
36
return Minio (
43
- f"{ self . get_container_host_ip () } :{ self . get_exposed_port ( self . port_to_expose ) } " ,
37
+ f"{ host_ip } :{ exposed_port } " ,
44
38
access_key = self .access_key ,
45
39
secret_key = self .secret_key ,
46
40
secure = False ,
47
41
** kwargs ,
48
42
)
49
43
50
- def get_config (self ) -> MinioConfig :
44
+ def get_config (self ) -> dict :
51
45
"""Returns the configuration of the Minio container.
52
46
53
47
Returns:
54
48
MinioConfig: Dictionary with the endpoint, access_key and secret_key.
55
49
"""
50
+ host_ip = self .get_container_host_ip ()
51
+ exposed_port = self .get_exposed_port (self .port_to_expose )
56
52
return {
57
- "endpoint" : f"{ self .get_container_host_ip ()} " +
58
- f":{ self .get_exposed_port (self .port_to_expose )} " ,
53
+ "endpoint" : f"{ host_ip } :{ exposed_port } " ,
59
54
"access_key" : self .access_key ,
60
55
"secret_key" : self .secret_key ,
61
56
}
0 commit comments