Read tarball into in-memory config provider
This commit is contained in:
		
							parent
							
								
									8aa18a29a8
								
							
						
					
					
						commit
						bb2b28cd11
					
				
					 5 changed files with 83 additions and 9 deletions
				
			
		|  | @ -1,4 +1,6 @@ | |||
| import logging | ||||
| import tarfile | ||||
| import cStringIO | ||||
| 
 | ||||
| from flask import request, make_response | ||||
| 
 | ||||
|  | @ -17,9 +19,10 @@ class TarConfigLoader(ApiResource): | |||
|         input_stream = request.stream | ||||
| 
 | ||||
|         # since we're working with a tar file, shouldn't be larger than ~20KB, so just read the whole thing into mem | ||||
|         buf = input_stream.read(-1) | ||||
|         buf = input_stream.read() | ||||
|         config = tarfile.open(mode="r:gz", fileobj=cStringIO.StringIO(buf)) | ||||
| 
 | ||||
|         # TODO(sam): refactor config provider to accept a stream write to avoid loading into memory | ||||
|         config_provider.write_volume_file('test_tar.tar.gz', buf) | ||||
|         config_provider.load_from_tarball(config) | ||||
| 
 | ||||
|         return make_response('OK') | ||||
|  |  | |||
		Reference in a new issue