@@ -121,9 +121,6 @@ class ConnectorRunner:
121
121
IN_CONTAINER_CONFIG_PATH = "/data/config.json"
122
122
IN_CONTAINER_CATALOG_PATH = "/data/catalog.json"
123
123
IN_CONTAINER_STATE_PATH = "/data/state.json"
124
- BASE_IN_CONTAINER_OUTPUT_DIRECTORY = "/tmp"
125
- IN_CONTAINER_OUTPUT_PATH = f"{ BASE_IN_CONTAINER_OUTPUT_DIRECTORY } /raw_output.txt"
126
- RELATIVE_ERRORS_PATH = "errors.txt"
127
124
MITMPROXY_IMAGE = "mitmproxy/mitmproxy:9.0.1"
128
125
HTTP_DUMP_FILE_NAME = "http_dump.mitm"
129
126
@@ -146,13 +143,13 @@ def __init__(
146
143
self .state = state
147
144
self .environment_variables = environment_variables if environment_variables else {}
148
145
self .enable_http_cache = enable_http_cache
149
- self .full_command : List [str ] = self .get_full_command (command )
146
+ self .full_command : List [str ] = self ._get_full_command (command )
150
147
151
148
@property
152
149
def _connector_under_test_container (self ) -> dagger .Container :
153
150
return self .connector_under_test .container
154
151
155
- def get_full_command (self , command : Command ):
152
+ def _get_full_command (self , command : Command ):
156
153
if command is Command .SPEC :
157
154
return ["spec" ]
158
155
elif command is Command .CHECK :
@@ -206,33 +203,33 @@ async def run(
206
203
if self .catalog :
207
204
container = container .with_new_file (self .IN_CONTAINER_CATALOG_PATH , contents = self .catalog .json ())
208
205
if self .enable_http_cache :
209
- container = await self .bind_connector_container_to_proxy (container )
206
+ container = await self ._bind_connector_container_to_proxy (container )
210
207
executed_container = await container .with_exec (self .full_command ).sync ()
211
208
212
209
return ExecutionResult (
213
210
stdout = await executed_container .stdout (),
214
211
stderr = await executed_container .stderr (),
215
212
executed_container = executed_container ,
216
- http_dump = await self .retrieve_http_dump () if self .enable_http_cache else None ,
213
+ http_dump = await self ._retrieve_http_dump () if self .enable_http_cache else None ,
217
214
)
218
215
219
- def get_http_dumps_cache_volume (self ) -> dagger .CacheVolume :
216
+ def _get_http_dumps_cache_volume (self ) -> dagger .CacheVolume :
220
217
config_data = self .config .data if self .config else None
221
218
proxy_cache_key = hashlib .md5 ((self .connector_under_test .name + str (config_data )).encode ("utf-8" )).hexdigest ()
222
219
return self .dagger_client .cache_volume (f"{ self .MITMPROXY_IMAGE } { proxy_cache_key } " )
223
220
224
- def get_mitmproxy_dir_cache (self ) -> dagger .CacheVolume :
221
+ def _get_mitmproxy_dir_cache (self ) -> dagger .CacheVolume :
225
222
return self .dagger_client .cache_volume (self .MITMPROXY_IMAGE )
226
223
227
- async def get_proxy_container (
224
+ async def _get_proxy_container (
228
225
self ,
229
226
) -> dagger .Container :
230
227
proxy_container = (
231
228
self .dagger_client .container ()
232
229
.from_ (self .MITMPROXY_IMAGE )
233
230
.with_exec (["mkdir" , "-p" , "/home/mitmproxy/.mitmproxy" ], skip_entrypoint = True )
234
- .with_mounted_cache ("/dumps" , self .get_http_dumps_cache_volume ())
235
- .with_mounted_cache ("/home/mitmproxy/.mitmproxy" , self .get_mitmproxy_dir_cache ())
231
+ .with_mounted_cache ("/dumps" , self ._get_http_dumps_cache_volume ())
232
+ .with_mounted_cache ("/home/mitmproxy/.mitmproxy" , self ._get_mitmproxy_dir_cache ())
236
233
)
237
234
previous_dump_files = (
238
235
await proxy_container .with_env_variable ("CACHEBUSTER" , str (uuid .uuid4 ()))
@@ -254,16 +251,16 @@ async def get_proxy_container(
254
251
255
252
return proxy_container .with_exec (command )
256
253
257
- async def bind_connector_container_to_proxy (self , container : dagger .Container ):
258
- proxy_srv = await self .get_proxy_container ()
254
+ async def _bind_connector_container_to_proxy (self , container : dagger .Container ):
255
+ proxy_srv = await self ._get_proxy_container ()
259
256
proxy_host , proxy_port = "proxy_server" , 8080
260
257
cert_path_in_volume = "/mitmproxy_dir/mitmproxy-ca.pem"
261
258
requests_cert_path = "/usr/local/lib/python3.9/site-packages/certifi/cacert.pem"
262
259
ca_certificate_path = "/usr/local/share/ca-certificates/mitmproxy.crt"
263
260
264
261
return (
265
262
container .with_service_binding (proxy_host , proxy_srv .with_exposed_port (proxy_port ).as_service ())
266
- .with_mounted_cache ("/mitmproxy_dir" , self .get_mitmproxy_dir_cache ())
263
+ .with_mounted_cache ("/mitmproxy_dir" , self ._get_mitmproxy_dir_cache ())
267
264
.with_exec (["cp" , cert_path_in_volume , requests_cert_path ], skip_entrypoint = True )
268
265
.with_exec (["cp" , cert_path_in_volume , ca_certificate_path ], skip_entrypoint = True )
269
266
.with_env_variable ("REQUESTS_CA_BUNDLE" , requests_cert_path )
@@ -272,11 +269,11 @@ async def bind_connector_container_to_proxy(self, container: dagger.Container):
272
269
.with_env_variable ("https_proxy" , f"{ proxy_host } :{ proxy_port } " )
273
270
)
274
271
275
- async def retrieve_http_dump (self ) -> dagger .File :
272
+ async def _retrieve_http_dump (self ) -> dagger .File :
276
273
return await (
277
274
self .dagger_client .container ()
278
275
.from_ ("alpine:latest" )
279
- .with_mounted_cache ("/dumps" , self .get_http_dumps_cache_volume ())
276
+ .with_mounted_cache ("/dumps" , self ._get_http_dumps_cache_volume ())
280
277
.with_exec (["mkdir" , "/to_export" ])
281
278
.with_exec (
282
279
[
0 commit comments