Hard-code super user name and email (#22296)
This commit is contained in:
Родитель
5282668cc4
Коммит
2bbb6ff52c
|
@ -100,10 +100,11 @@ initialize_db: ## create a new database
|
|||
$(PYTHON_COMMAND) manage.py migrate --noinput
|
||||
$(PYTHON_COMMAND) manage.py loaddata initial.json
|
||||
$(PYTHON_COMMAND) manage.py import_prod_versions
|
||||
# The superuser needs to have a mozilla.com address for admin tools access
|
||||
$(PYTHON_COMMAND) manage.py createsuperuser \
|
||||
--no-input \
|
||||
--username "$(SUPERUSER_USERNAME)" \
|
||||
--email $(SUPERUSER_EMAIL)
|
||||
--username "local_admin" \
|
||||
--email "local_admin@mozilla.com"
|
||||
$(PYTHON_COMMAND) manage.py loaddata zadmin/users
|
||||
|
||||
.PHONY: reindex_data
|
||||
|
|
|
@ -21,8 +21,6 @@ x-env-mapping: &env
|
|||
- HISTCONTROL=erasedups
|
||||
- CIRCLECI
|
||||
- HOST_UID
|
||||
- SUPERUSER_EMAIL
|
||||
- SUPERUSER_USERNAME
|
||||
|
||||
services:
|
||||
worker: &worker
|
||||
|
|
|
@ -5,13 +5,6 @@ import os
|
|||
import subprocess
|
||||
|
||||
|
||||
def git_config(key, default):
|
||||
try:
|
||||
return subprocess.check_output(['git', 'config', key]).decode().strip()
|
||||
except subprocess.CalledProcessError:
|
||||
return default
|
||||
|
||||
|
||||
def set_env_file(values):
|
||||
with open('.env', 'w') as f:
|
||||
print('Environment:')
|
||||
|
@ -100,12 +93,6 @@ set_env_file(
|
|||
'DOCKER_TAG': docker_tag,
|
||||
'DOCKER_TARGET': get_value('DOCKER_TARGET', 'development'),
|
||||
'HOST_UID': get_value('HOST_UID', os.getuid()),
|
||||
'SUPERUSER_EMAIL': get_value(
|
||||
'SUPERUSER_EMAIL', git_config('user.email', 'admin@mozilla.com')
|
||||
),
|
||||
'SUPERUSER_USERNAME': get_value(
|
||||
'SUPERUSER_USERNAME', git_config('user.name', 'admin')
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -39,8 +39,6 @@ test('map docker compose config', () => {
|
|||
const values = {
|
||||
DOCKER_VERSION: 'version',
|
||||
HOST_UID: 'uid',
|
||||
SUPERUSER_EMAIL: 'email',
|
||||
SUPERUSER_USERNAME: 'name',
|
||||
};
|
||||
|
||||
fs.writeFileSync(envPath, '');
|
||||
|
@ -60,30 +58,11 @@ test('map docker compose config', () => {
|
|||
);
|
||||
expect(web.platform).toStrictEqual('linux/amd64');
|
||||
expect(web.environment.HOST_UID).toStrictEqual(values.HOST_UID);
|
||||
expect(web.environment.SUPERUSER_EMAIL).toStrictEqual(values.SUPERUSER_EMAIL);
|
||||
expect(web.environment.SUPERUSER_USERNAME).toStrictEqual(
|
||||
values.SUPERUSER_USERNAME,
|
||||
);
|
||||
expect(config.volumes.data_mysqld.name).toStrictEqual(
|
||||
'addons-server_data_mysqld',
|
||||
);
|
||||
});
|
||||
|
||||
function gitConfigUserEmail() {
|
||||
const { stdout: value } = spawnSync('git', ['config', 'user.email'], {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
|
||||
return value.trim() || 'admin@mozilla.com';
|
||||
}
|
||||
|
||||
function gitConfigUserName() {
|
||||
const { stdout: value } = spawnSync('git', ['config', 'user.name'], {
|
||||
encoding: 'utf-8',
|
||||
});
|
||||
return value.trim() || 'admin';
|
||||
}
|
||||
|
||||
function standardPermutations(name, defaultValue) {
|
||||
return [
|
||||
{
|
||||
|
@ -168,8 +147,6 @@ const testCases = [
|
|||
...standardPermutations('DOCKER_TAG', 'mozilla/addons-server:local'),
|
||||
...standardPermutations('DOCKER_TARGET', 'development'),
|
||||
...standardPermutations('HOST_UID', process.getuid().toString()),
|
||||
...standardPermutations('SUPERUSER_EMAIL', gitConfigUserEmail()),
|
||||
...standardPermutations('SUPERUSER_USERNAME', gitConfigUserName()),
|
||||
...standardPermutations('COMPOSE_FILE', 'docker-compose.yml'),
|
||||
];
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче