Better config defaults and remove some unneeded code
This commit is contained in:
parent
40d2b1748f
commit
219730c341
6 changed files with 657 additions and 649 deletions
|
@ -67,11 +67,15 @@ class SuperUserGetConfig(ApiResource):
|
||||||
'type': 'object',
|
'type': 'object',
|
||||||
'description': 'Updates the YAML config file',
|
'description': 'Updates the YAML config file',
|
||||||
'required': [
|
'required': [
|
||||||
'config'
|
'config',
|
||||||
|
'hostname'
|
||||||
],
|
],
|
||||||
'properties': {
|
'properties': {
|
||||||
'config': {
|
'config': {
|
||||||
'type': 'object'
|
'type': 'object'
|
||||||
|
},
|
||||||
|
'hostname': {
|
||||||
|
'type': 'string'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -102,9 +106,10 @@ class SuperUserGetConfig(ApiResource):
|
||||||
# so we also allow it to be called if there is no valid registry configuration setup.
|
# so we also allow it to be called if there is no valid registry configuration setup.
|
||||||
if not os.path.exists(OVERRIDE_CONFIG_YAML_FILENAME) or SuperUserPermission().can():
|
if not os.path.exists(OVERRIDE_CONFIG_YAML_FILENAME) or SuperUserPermission().can():
|
||||||
config_object = request.get_json()['config']
|
config_object = request.get_json()['config']
|
||||||
|
hostname = request.get_json()['hostname']
|
||||||
|
|
||||||
# Add any enterprise defaults missing from the config.
|
# Add any enterprise defaults missing from the config.
|
||||||
add_enterprise_config_defaults(config_object, app.config['SECRET_KEY'])
|
add_enterprise_config_defaults(config_object, app.config['SECRET_KEY'], hostname)
|
||||||
|
|
||||||
# Write the configuration changes to the YAML file.
|
# Write the configuration changes to the YAML file.
|
||||||
export_yaml(config_object, OVERRIDE_CONFIG_YAML_FILENAME)
|
export_yaml(config_object, OVERRIDE_CONFIG_YAML_FILENAME)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -3118,7 +3118,8 @@ function SuperUserAdminCtrl($scope, $timeout, ApiService, Features, UserService,
|
||||||
var data = {
|
var data = {
|
||||||
'config': {
|
'config': {
|
||||||
'DB_URI': $scope.databaseUri
|
'DB_URI': $scope.databaseUri
|
||||||
}
|
},
|
||||||
|
'hostname': window.location.host
|
||||||
};
|
};
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
|
|
|
@ -7,25 +7,10 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
||||||
transclude: true,
|
transclude: true,
|
||||||
restrict: 'C',
|
restrict: 'C',
|
||||||
scope: {
|
scope: {
|
||||||
|
'isActive': '=isActive'
|
||||||
},
|
},
|
||||||
controller: function($rootScope, $scope, $element, $timeout) {
|
controller: function($rootScope, $scope, $element, $timeout, ApiService) {
|
||||||
$scope.config = {
|
$scope.config = null;
|
||||||
'DB_URI': 'mysql+pymysql://jschorr:somepassword@mymysql.server.somewhere:768/mydb',
|
|
||||||
'PREFERRED_URL_SCHEME': 'https',
|
|
||||||
'FEATURE_USER_CREATION': true,
|
|
||||||
'DISTRIBUTED_STORAGE_CONFIG': {'local': ['LocalStorage', {'storage_path': '/datastorage/registry'}]},
|
|
||||||
'AUTHENTICATION_TYPE': 'Database'
|
|
||||||
}
|
|
||||||
|
|
||||||
$scope.generateKey = function() {
|
|
||||||
var d = new Date().getTime();
|
|
||||||
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
||||||
var r = (d + Math.random()*16)%16 | 0;
|
|
||||||
d = Math.floor(d/16);
|
|
||||||
return (c=='x' ? r : (r&0x3|0x8)).toString(16);
|
|
||||||
});
|
|
||||||
$scope.config['SECRET_KEY'] = uuid;
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.parseDbUri = function(value) {
|
$scope.parseDbUri = function(value) {
|
||||||
if (!value) { return null; }
|
if (!value) { return null; }
|
||||||
|
@ -55,6 +40,14 @@ angular.module("core-config-setup", ['angularFileUpload'])
|
||||||
uri = uri && uri.toString();
|
uri = uri && uri.toString();
|
||||||
return uri;
|
return uri;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.$watch('isActive', function(value) {
|
||||||
|
if (!value) { return; }
|
||||||
|
|
||||||
|
ApiService.scGetConfig().then(function(resp) {
|
||||||
|
$scope.config = resp['config'];
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<div class="cor-tab-content">
|
<div class="cor-tab-content">
|
||||||
<!-- Setup tab -->
|
<!-- Setup tab -->
|
||||||
<div id="setup" class="tab-pane active">
|
<div id="setup" class="tab-pane active">
|
||||||
<div class="config-setup-tool"></div>
|
<div class="config-setup-tool" is-active="configStatus.ready"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Debugging tab -->
|
<!-- Debugging tab -->
|
||||||
|
|
|
@ -36,7 +36,7 @@ def set_config_value(config_file, config_key, value):
|
||||||
export_yaml(config_obj, config_file)
|
export_yaml(config_obj, config_file)
|
||||||
|
|
||||||
|
|
||||||
def add_enterprise_config_defaults(config_obj, current_secret_key):
|
def add_enterprise_config_defaults(config_obj, current_secret_key, hostname):
|
||||||
""" Adds/Sets the config defaults for enterprise registry config. """
|
""" Adds/Sets the config defaults for enterprise registry config. """
|
||||||
# These have to be false.
|
# These have to be false.
|
||||||
config_obj['TESTING'] = False
|
config_obj['TESTING'] = False
|
||||||
|
@ -50,6 +50,10 @@ def add_enterprise_config_defaults(config_obj, current_secret_key):
|
||||||
config_obj['FEATURE_MAILING'] = config_obj.get('FEATURE_MAILING', False)
|
config_obj['FEATURE_MAILING'] = config_obj.get('FEATURE_MAILING', False)
|
||||||
config_obj['FEATURE_BUILD_SUPPORT'] = config_obj.get('FEATURE_BUILD_SUPPORT', False)
|
config_obj['FEATURE_BUILD_SUPPORT'] = config_obj.get('FEATURE_BUILD_SUPPORT', False)
|
||||||
|
|
||||||
|
# Default auth type.
|
||||||
|
if not 'AUTHENTICATION_TYPE' in config_obj:
|
||||||
|
config_obj['AUTHENTICATION_TYPE'] = 'Database'
|
||||||
|
|
||||||
# Default secret key.
|
# Default secret key.
|
||||||
if not 'SECRET_KEY' in config_obj:
|
if not 'SECRET_KEY' in config_obj:
|
||||||
config_obj['SECRET_KEY'] = current_secret_key
|
config_obj['SECRET_KEY'] = current_secret_key
|
||||||
|
@ -58,12 +62,15 @@ def add_enterprise_config_defaults(config_obj, current_secret_key):
|
||||||
if not 'DISTRIBUTED_STORAGE_CONFIG' in config_obj:
|
if not 'DISTRIBUTED_STORAGE_CONFIG' in config_obj:
|
||||||
config_obj['DISTRIBUTED_STORAGE_PREFERENCE'] = ['local']
|
config_obj['DISTRIBUTED_STORAGE_PREFERENCE'] = ['local']
|
||||||
config_obj['DISTRIBUTED_STORAGE_CONFIG'] = {
|
config_obj['DISTRIBUTED_STORAGE_CONFIG'] = {
|
||||||
'local': ['LocalStorage', { 'storage_path': '/datastorage/registry' }]
|
'local': ['LocalStorage', {'storage_path': '/datastorage/registry'}]
|
||||||
}
|
}
|
||||||
|
|
||||||
config_obj['USERFILES_LOCATION'] = 'local'
|
config_obj['USERFILES_LOCATION'] = 'local'
|
||||||
config_obj['USERFILES_PATH'] = 'userfiles/'
|
config_obj['USERFILES_PATH'] = 'userfiles/'
|
||||||
|
|
||||||
|
if not 'SERVER_HOSTNAME' in config_obj:
|
||||||
|
config_obj['SERVER_HOSTNAME'] = hostname
|
||||||
|
|
||||||
# Misc configuration.
|
# Misc configuration.
|
||||||
config_obj['PREFERRED_URL_SCHEME'] = config_obj.get('PREFERRED_URL_SCHEME', 'http')
|
config_obj['PREFERRED_URL_SCHEME'] = config_obj.get('PREFERRED_URL_SCHEME', 'http')
|
||||||
config_obj['ENTERPRISE_LOGO_URL'] = config_obj.get('ENTERPRISE_LOGO_URL',
|
config_obj['ENTERPRISE_LOGO_URL'] = config_obj.get('ENTERPRISE_LOGO_URL',
|
||||||
|
|
Reference in a new issue