Fix error case in uploading tar, more comments
This commit is contained in:
parent
d6d0bb640a
commit
872be8605a
6 changed files with 37 additions and 17 deletions
|
@ -335,4 +335,3 @@ class SuperUserConfigFile(ApiResource):
|
|||
return {
|
||||
'status': True
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import logging
|
||||
import pathvalidate
|
||||
import os
|
||||
|
||||
from flask import request, jsonify
|
||||
|
||||
from config_app.config_endpoints.exception import InvalidRequest
|
||||
from config_app.config_endpoints.api import resource, ApiResource, nickname
|
||||
from config_app.config_util.ssl import load_certificate, CertInvalidException
|
||||
from config_app.c_app import config_provider
|
||||
from config_app.c_app import app, config_provider
|
||||
|
||||
from config_app.config_endpoints.api.superuser_models_pre_oci import pre_oci_model
|
||||
|
||||
|
@ -45,6 +47,15 @@ class SuperUserCustomCertificate(ApiResource):
|
|||
logger.exception('Got IO error for cert %s', certpath)
|
||||
return '', 204
|
||||
|
||||
# TODO(QUAY-991): properly install the custom certs provided by user
|
||||
# Call the update script to install the certificate immediately.
|
||||
# if not app.config['TESTING']:
|
||||
# logger.debug('Calling certs_install.sh')
|
||||
# if os.system('/conf/init/certs_install.sh') != 0:
|
||||
# raise Exception('Could not install certificates')
|
||||
#
|
||||
# logger.debug('certs_install.sh completed')
|
||||
|
||||
return '', 204
|
||||
|
||||
@nickname('deleteCustomCertificate')
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import logging
|
||||
import yaml
|
||||
import io
|
||||
import os
|
||||
|
||||
from config_app.config_util.config.baseprovider import BaseProvider
|
||||
|
||||
|
@ -36,7 +37,7 @@ class InMemoryProvider(BaseProvider):
|
|||
return True
|
||||
|
||||
def volume_file_exists(self, filename):
|
||||
return any([ name.startswith(filename) for name in self.files ])
|
||||
return any([name.startswith(filename) for name in self.files])
|
||||
|
||||
def get_volume_file(self, filename, mode='r'):
|
||||
return io.BytesIO(self.files[filename])
|
||||
|
@ -53,7 +54,7 @@ class InMemoryProvider(BaseProvider):
|
|||
return string[string.rfind('/') + 1:]
|
||||
return string
|
||||
|
||||
return [ strip_directory(name) for name in self.files if name.startswith(path) ]
|
||||
return [strip_directory(name) for name in self.files if name.startswith(path)]
|
||||
|
||||
def save_volume_file(self, filename, flask_file):
|
||||
self.files[filename] = flask_file.read()
|
||||
|
@ -62,11 +63,7 @@ class InMemoryProvider(BaseProvider):
|
|||
raise Exception('Not implemented yet')
|
||||
|
||||
def get_volume_path(self, directory, filename):
|
||||
# Here we can just access the filename since we're storing the tarball files with their full path
|
||||
if directory.endswith('/'):
|
||||
return directory + filename
|
||||
else:
|
||||
return directory + '/' + filename
|
||||
return os.path.join(directory, filename)
|
||||
|
||||
def load_from_tarball(self, tarfile):
|
||||
for tarinfo in tarfile.getmembers():
|
||||
|
|
|
@ -2,6 +2,8 @@ import {Component, EventEmitter, Inject, Output} from 'ng-metadata/core';
|
|||
const templateUrl = require('./load-config.html');
|
||||
const styleUrl = require('./load-config.css');
|
||||
|
||||
declare var bootbox: any;
|
||||
|
||||
@Component({
|
||||
selector: 'load-config',
|
||||
templateUrl,
|
||||
|
@ -29,9 +31,17 @@ export class LoadConfigComponent {
|
|||
if (success) {
|
||||
this.configLoaded.emit({});
|
||||
} else {
|
||||
this.apiService.errorDisplay('Error loading configuration',
|
||||
'Could not upload configuration. Please reload the page and try again.\n' +
|
||||
'If this problem persists, please contact support')();
|
||||
bootbox.dialog({
|
||||
"message": 'Could not upload configuration. Please check you have provided a valid tar file' +
|
||||
'If this problem persists, please contact support',
|
||||
"title": 'Error Loading Configuration',
|
||||
"buttons": {
|
||||
"close": {
|
||||
"label": "Close",
|
||||
"className": "btn-primary"
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -31,10 +31,9 @@ const templateUrl = require('./setup.html');
|
|||
$scope.HOSTNAME_REGEX = '^[a-zA-Z-0-9_\.\-]+(:[0-9]+)?$';
|
||||
|
||||
$scope.validateHostname = function(hostname) {
|
||||
// TODO(sam): maybe revert?
|
||||
// if (hostname.indexOf('127.0.0.1') == 0 || hostname.indexOf('localhost') == 0) {
|
||||
// return 'Please specify a non-localhost hostname. "localhost" will refer to the container, not your machine.'
|
||||
// }
|
||||
if (hostname.indexOf('127.0.0.1') == 0 || hostname.indexOf('localhost') == 0) {
|
||||
return 'Please specify a non-localhost hostname. "localhost" will refer to the container, not your machine.'
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
|
|
@ -21,8 +21,12 @@ from util.morecollections import AttrDict
|
|||
config = context.config
|
||||
DB_URI = config.get_main_option('db_uri', 'sqlite:///test/data/test.db')
|
||||
|
||||
|
||||
# This option exists because alembic needs the db proxy to be configured in order
|
||||
# to perform migrations. The app import does the init of the proxy, but we don't
|
||||
# want that in the case of the config app, as we are explicitly connecting to a
|
||||
# db that the user has passed in, and we can't have import dependency on app
|
||||
if config.get_main_option('alembic_setup_app', 'True') == 'True':
|
||||
# needed for db connections
|
||||
from app import app
|
||||
DB_URI = app.config['DB_URI']
|
||||
|
||||
|
|
Reference in a new issue