Modify config field to use base api endpoint
allow streaming from gzipped tarball config
This commit is contained in:
parent
aff1a08a83
commit
d6d0bb640a
7 changed files with 40 additions and 33 deletions
|
@ -1,5 +1,4 @@
|
|||
import tarfile
|
||||
import cStringIO
|
||||
|
||||
from flask import request, make_response
|
||||
|
||||
|
@ -13,16 +12,12 @@ class TarConfigLoader(ApiResource):
|
|||
""" Resource for validating a block of configuration against an external service. """
|
||||
|
||||
@nickname('uploadTarballConfig')
|
||||
def post(self):
|
||||
def put(self):
|
||||
""" Loads tarball config into the config provider """
|
||||
input_stream = request.stream
|
||||
tar_stream = tarfile.open(mode="r|gz", fileobj=input_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()
|
||||
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.load_from_tarball(config)
|
||||
config_provider.load_from_tar_stream(tar_stream)
|
||||
|
||||
# now try to connect to the db provided in their config
|
||||
combined = dict(**app.config)
|
||||
|
|
Reference in a new issue