d6d0bb640a
allow streaming from gzipped tarball config
28 lines
891 B
Python
28 lines
891 B
Python
import tarfile
|
|
|
|
from flask import request, make_response
|
|
|
|
from data.database import configure
|
|
|
|
from config_app.c_app import app, config_provider
|
|
from config_app.config_endpoints.api import resource, ApiResource, nickname
|
|
|
|
@resource('/v1/configapp/tarconfig')
|
|
class TarConfigLoader(ApiResource):
|
|
""" Resource for validating a block of configuration against an external service. """
|
|
|
|
@nickname('uploadTarballConfig')
|
|
def put(self):
|
|
""" Loads tarball config into the config provider """
|
|
input_stream = request.stream
|
|
tar_stream = tarfile.open(mode="r|gz", fileobj=input_stream)
|
|
|
|
config_provider.load_from_tar_stream(tar_stream)
|
|
|
|
# now try to connect to the db provided in their config
|
|
combined = dict(**app.config)
|
|
combined.update(config_provider.get_config())
|
|
|
|
configure(combined)
|
|
|
|
return make_response('OK')
|