feat: change config file format to yaml
- docs: add link to yaml.org BREAKING: The `ini` configuration file format changed to `yml`. Please rewrite your configuration file using the yaml format.
This commit is contained in:
parent
5d902ef962
commit
e4439390fe
|
@ -10,9 +10,9 @@ def config_filepath(tmp_path: Path):
|
||||||
filepath = tmp_path / "airtime.conf"
|
filepath = tmp_path / "airtime.conf"
|
||||||
filepath.write_text(
|
filepath.write_text(
|
||||||
"""
|
"""
|
||||||
[general]
|
general:
|
||||||
public_url = http://localhost/test
|
public_url: http://localhost/test
|
||||||
api_key = TEST_KEY
|
api_key: TEST_KEY
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
return filepath
|
return filepath
|
||||||
|
|
|
@ -60,7 +60,7 @@ set up beforehand.
|
||||||
You can configure everything pertaining to how LibreTime accesses LDAP in
|
You can configure everything pertaining to how LibreTime accesses LDAP in
|
||||||
`/etc/airtime/airtime.conf`. The default file has the following values you need to change.
|
`/etc/airtime/airtime.conf`. The default file has the following values you need to change.
|
||||||
|
|
||||||
```ini
|
```yml
|
||||||
#
|
#
|
||||||
# ----------------------------------------------------------------------
|
# ----------------------------------------------------------------------
|
||||||
# L D A P
|
# L D A P
|
||||||
|
@ -83,27 +83,27 @@ You can configure everything pertaining to how LibreTime accesses LDAP in
|
||||||
# Lets LibreTime assign user types based on the
|
# Lets LibreTime assign user types based on the
|
||||||
# group a given user is in.
|
# group a given user is in.
|
||||||
#
|
#
|
||||||
[ldap]
|
ldap:
|
||||||
hostname = ldap.example.org
|
hostname: ldap.example.org
|
||||||
binddn = 'uid=libretime,cn=sysaccounts,cn=etc,dc=int,dc=example,dc=org'
|
binddn: "uid=libretime,cn=sysaccounts,cn=etc,dc=int,dc=example,dc=org"
|
||||||
password = hackme
|
password: hackme
|
||||||
account_domain = INT.EXAMPLE.ORG
|
account_domain: INT.EXAMPLE.ORG
|
||||||
basedn = 'cn=users,cn=accounts,dc=int,dc=example,dc=org'
|
basedn: "cn=users,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
filter_field = uid
|
filter_field: uid
|
||||||
groupmap_guest = 'cn=guest,cn=groups,cn=accounts,dc=int,dc=example,dc=org'
|
groupmap_guest: "cn=guest,cn=groups,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
groupmap_host = 'cn=host,cn=groups,cn=accounts,dc=int,dc=example,dc=org'
|
groupmap_host: "cn=host,cn=groups,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
groupmap_program_manager = 'cn=program_manager,cn=groups,cn=accounts,dc=int,dc=example,dc=org'
|
groupmap_program_manager: "cn=program_manager,cn=groups,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
groupmap_admin = 'cn=admins,cn=groups,cn=accounts,dc=int,dc=example,dc=org'
|
groupmap_admin: "cn=admins,cn=groups,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
groupmap_superadmin = 'cn=superadmin,cn=groups,cn=accounts,dc=int,dc=example,dc=org'
|
groupmap_superadmin: "cn=superadmin,cn=groups,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Enable FreeIPA authentication
|
### Enable FreeIPA authentication
|
||||||
|
|
||||||
After everything is set up properly you can enable FreeIPA auth in `airtime.conf`:
|
After everything is set up properly you can enable FreeIPA auth in `airtime.conf`:
|
||||||
|
|
||||||
```
|
```yml
|
||||||
[general]
|
general:
|
||||||
auth = LibreTime_Auth_Adaptor_FreeIpa
|
auth: LibreTime_Auth_Adaptor_FreeIpa
|
||||||
```
|
```
|
||||||
|
|
||||||
You should now be able to use your FreeIPA credentials to log in to LibreTime.
|
You should now be able to use your FreeIPA credentials to log in to LibreTime.
|
||||||
|
|
|
@ -9,19 +9,19 @@ To configure LibreTime, you need to edit the `/etc/airtime/airtime.conf` file. T
|
||||||
|
|
||||||
The `general` section configure anything related to the legacy and API services.
|
The `general` section configure anything related to the legacy and API services.
|
||||||
|
|
||||||
```ini
|
```yml
|
||||||
[general]
|
general:
|
||||||
# The public url. This field is REQUIRED
|
# The public url. This field is REQUIRED
|
||||||
public_url = https://example.com
|
public_url: https://example.com
|
||||||
# The internal API authentication key, this field is REQUIRED
|
# The internal API authentication key, this field is REQUIRED
|
||||||
api_key = some_random_generated_secret!
|
api_key: some_random_generated_secret!
|
||||||
|
|
||||||
# How many hours ahead Playout should cache scheduled media files, default is 1
|
# How many hours ahead Playout should cache scheduled media files, default is 1
|
||||||
cache_ahead_hours = 1
|
cache_ahead_hours: 1
|
||||||
|
|
||||||
# Authentication adaptor to use for the legacy service, default is local
|
# Authentication adaptor to use for the legacy service, default is local
|
||||||
# Specify a class like LibreTime_Auth_Adaptor_FreeIpa to replace the built-in adaptor
|
# Specify a class like LibreTime_Auth_Adaptor_FreeIpa to replace the built-in adaptor
|
||||||
auth = local
|
auth: local
|
||||||
```
|
```
|
||||||
|
|
||||||
In order to apply the changes made in this section, please restart the following services:
|
In order to apply the changes made in this section, please restart the following services:
|
||||||
|
@ -45,18 +45,18 @@ Before editing this section be sure to update the PostgreSQL server with the des
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
```ini
|
```yml
|
||||||
[database]
|
database:
|
||||||
# The hostname of the PostgreSQL server, default is localhost
|
# The hostname of the PostgreSQL server, default is localhost
|
||||||
host = localhost
|
host: localhost
|
||||||
# The port of the PostgreSQL server, default is 5432
|
# The port of the PostgreSQL server, default is 5432
|
||||||
port = 5432
|
port: 5432
|
||||||
# The name of the PostgreSQL database, default is libretime
|
# The name of the PostgreSQL database, default is libretime
|
||||||
name = libretime
|
name: libretime
|
||||||
# The username of the PostgreSQL user, default is libretime
|
# The username of the PostgreSQL user, default is libretime
|
||||||
user = libretime
|
user: libretime
|
||||||
# The password of the PostgreSQL user, default is libretime
|
# The password of the PostgreSQL user, default is libretime
|
||||||
password = some_random_generated_secret!
|
password: some_random_generated_secret!
|
||||||
```
|
```
|
||||||
|
|
||||||
In order to apply the changes made in this section, please restart the following services:
|
In order to apply the changes made in this section, please restart the following services:
|
||||||
|
@ -77,18 +77,18 @@ Before editing this section be sure to update the RabbitMQ server with the desir
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
```ini
|
```yml
|
||||||
[rabbitmq]
|
rabbitmq:
|
||||||
# The hostname of the RabbitMQ server, default is localhost
|
# The hostname of the RabbitMQ server, default is localhost
|
||||||
host = localhost
|
host: localhost
|
||||||
# The port of the RabbitMQ server, default is 5672
|
# The port of the RabbitMQ server, default is 5672
|
||||||
port = 5672
|
port: 5672
|
||||||
# The virtual host of RabbitMQ server, default is /libretime
|
# The virtual host of RabbitMQ server, default is /libretime
|
||||||
vhost = /libretime
|
vhost: /libretime
|
||||||
# The username of the RabbitMQ user, default is libretime
|
# The username of the RabbitMQ user, default is libretime
|
||||||
user = libretime
|
user: libretime
|
||||||
# The password of the RabbitMQ user, default is libretime
|
# The password of the RabbitMQ user, default is libretime
|
||||||
password = some_random_generated_secret!
|
password: some_random_generated_secret!
|
||||||
```
|
```
|
||||||
|
|
||||||
In order to apply the changes made in this section, please restart the following services:
|
In order to apply the changes made in this section, please restart the following services:
|
||||||
|
@ -104,23 +104,23 @@ libretime-playout
|
||||||
|
|
||||||
The `playout` section configure anything related to the playout service.
|
The `playout` section configure anything related to the playout service.
|
||||||
|
|
||||||
```ini
|
```yml
|
||||||
[playout]
|
playout:
|
||||||
# Liquidsoap connection host, default is localhost
|
# Liquidsoap connection host, default is localhost
|
||||||
liquidsoap_host = localhost
|
liquidsoap_host: localhost
|
||||||
# Liquidsoap connection port, default is 1234
|
# Liquidsoap connection port, default is 1234
|
||||||
liquidsoap_port = 1234
|
liquidsoap_port: 1234
|
||||||
|
|
||||||
# The format for recordings, allowed values are ogg,mp3, default is ogg
|
# The format for recordings, allowed values are ogg,mp3, default is ogg
|
||||||
record_file_format = ogg
|
record_file_format: ogg
|
||||||
# The bitrate for recordings, default is 256
|
# The bitrate for recordings, default is 256
|
||||||
record_bitrate = 256
|
record_bitrate: 256
|
||||||
# The samplerate for recordings, default is 44100
|
# The samplerate for recordings, default is 44100
|
||||||
record_samplerate = 44100
|
record_samplerate: 44100
|
||||||
# The number of channels for recordings, default is 2
|
# The number of channels for recordings, default is 2
|
||||||
record_channels = 2
|
record_channels: 2
|
||||||
# The sample size for recordings, default is 16
|
# The sample size for recordings, default is 16
|
||||||
record_sample_size = 16
|
record_sample_size: 16
|
||||||
```
|
```
|
||||||
|
|
||||||
In order to apply the changes made in this section, please restart the following services:
|
In order to apply the changes made in this section, please restart the following services:
|
||||||
|
@ -133,26 +133,26 @@ libretime-playout
|
||||||
|
|
||||||
The `ldap` section provide additional configuration for the authentication mechanism defined in `general.auth`, please see the [custom authentication documentation](../custom-authentication.md) for more details.
|
The `ldap` section provide additional configuration for the authentication mechanism defined in `general.auth`, please see the [custom authentication documentation](../custom-authentication.md) for more details.
|
||||||
|
|
||||||
```ini
|
```yml
|
||||||
[ldap]
|
ldap:
|
||||||
# Hostname of LDAP server
|
# Hostname of LDAP server
|
||||||
hostname = ldap.example.org
|
hostname: ldap.example.org
|
||||||
# Complete DN of user used to bind to LDAP
|
# Complete DN of user used to bind to LDAP
|
||||||
binddn = 'uid=libretime,cn=sysaccounts,cn=etc,dc=int,dc=example,dc=org'
|
binddn: "uid=libretime,cn=sysaccounts,cn=etc,dc=int,dc=example,dc=org"
|
||||||
# Password for binddn user
|
# Password for binddn user
|
||||||
password = hackme
|
password: hackme
|
||||||
# Domain part of username
|
# Domain part of username
|
||||||
account_domain = INT.EXAMPLE.ORG
|
account_domain: INT.EXAMPLE.ORG
|
||||||
# Base search DN
|
# Base search DN
|
||||||
basedn = 'cn=users,cn=accounts,dc=int,dc=example,dc=org'
|
basedn: "cn=users,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
# Name of the uid field for searching. Usually uid, may be cn
|
# Name of the uid field for searching. Usually uid, may be cn
|
||||||
filter_field = uid
|
filter_field: uid
|
||||||
|
|
||||||
# Map user types to LDAP groups. Assign user types based on the group of a given user
|
# Map user types to LDAP groups. Assign user types based on the group of a given user
|
||||||
# Key format is groupmap_*
|
# Key format is groupmap_*
|
||||||
groupmap_superadmin = 'cn=superadmin,cn=groups,cn=accounts,dc=int,dc=example,dc=org'
|
groupmap_superadmin: "cn=superadmin,cn=groups,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
groupmap_admin = 'cn=admin,cn=groups,cn=accounts,dc=int,dc=example,dc=org'
|
groupmap_admin: "cn=admin,cn=groups,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
groupmap_program_manager = 'cn=program_manager,cn=groups,cn=accounts,dc=int,dc=example,dc=org'
|
groupmap_program_manager: "cn=program_manager,cn=groups,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
groupmap_host = 'cn=host,cn=groups,cn=accounts,dc=int,dc=example,dc=org'
|
groupmap_host: "cn=host,cn=groups,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
groupmap_guest = 'cn=guest,cn=groups,cn=accounts,dc=int,dc=example,dc=org'
|
groupmap_guest: "cn=guest,cn=groups,cn=accounts,dc=int,dc=example,dc=org"
|
||||||
```
|
```
|
||||||
|
|
|
@ -100,13 +100,12 @@ https://localhost
|
||||||
http://localhost
|
http://localhost
|
||||||
```
|
```
|
||||||
|
|
||||||
Finally, the configuration file needs updating. Under `[general]`, `force_ssl`
|
Finally, the configuration file needs updating. Under `general.force_ssl`
|
||||||
needs to be set to true:
|
needs to be set to true:
|
||||||
|
|
||||||
```ini
|
```yml
|
||||||
[general]
|
general:
|
||||||
...
|
force_ssl: true
|
||||||
force_ssl = true
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## SSL Configuration
|
## SSL Configuration
|
||||||
|
|
|
@ -18,6 +18,16 @@ The LibreTime project wants to thank the following contributors for authoring PR
|
||||||
|
|
||||||
## :arrow_up: Upgrading
|
## :arrow_up: Upgrading
|
||||||
|
|
||||||
|
### New configuration file
|
||||||
|
|
||||||
|
:::caution
|
||||||
|
|
||||||
|
Please run this **before the upgrade procedure**!
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
The configuration file format changed to `yml`. Please rewrite your [configuration file](../admin-manual/setup/configuration.md) using the [yaml format](https://yaml.org/).
|
||||||
|
|
||||||
### Apache and PHP configuration files
|
### Apache and PHP configuration files
|
||||||
|
|
||||||
:::caution
|
:::caution
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Config
|
||||||
public static function loadConfig()
|
public static function loadConfig()
|
||||||
{
|
{
|
||||||
$filename = $_SERVER['LIBRETIME_CONFIG_FILEPATH'] ?? LIBRETIME_CONFIG_FILEPATH;
|
$filename = $_SERVER['LIBRETIME_CONFIG_FILEPATH'] ?? LIBRETIME_CONFIG_FILEPATH;
|
||||||
$values = parse_ini_file($filename, true);
|
$values = yaml_parse_file($filename);
|
||||||
|
|
||||||
$CC_CONFIG = [];
|
$CC_CONFIG = [];
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class Config
|
||||||
// Explode public_url into multiple component with possible defaults for required fields
|
// Explode public_url into multiple component with possible defaults for required fields
|
||||||
try {
|
try {
|
||||||
$public_url = Uri::createFromString($values['general']['public_url']);
|
$public_url = Uri::createFromString($values['general']['public_url']);
|
||||||
} catch (UriException $e) {
|
} catch (UriException|TypeError $e) {
|
||||||
echo 'could not parse configuration field general.public_url: ' . $e->getMessage();
|
echo 'could not parse configuration field general.public_url: ' . $e->getMessage();
|
||||||
|
|
||||||
exit;
|
exit;
|
||||||
|
|
|
@ -29,6 +29,7 @@ php7.2-gd = bionic
|
||||||
php7.2-mbstring = bionic
|
php7.2-mbstring = bionic
|
||||||
php7.2-pgsql = bionic
|
php7.2-pgsql = bionic
|
||||||
php7.2-xml = bionic
|
php7.2-xml = bionic
|
||||||
|
php7.2-yaml = bionic
|
||||||
|
|
||||||
# Buster
|
# Buster
|
||||||
[php7.3]
|
[php7.3]
|
||||||
|
@ -44,6 +45,7 @@ php7.3-gd = buster
|
||||||
php7.3-mbstring = buster
|
php7.3-mbstring = buster
|
||||||
php7.3-pgsql = buster
|
php7.3-pgsql = buster
|
||||||
php7.3-xml = buster
|
php7.3-xml = buster
|
||||||
|
php7.3-yaml = buster
|
||||||
|
|
||||||
# Bullseye, Focal
|
# Bullseye, Focal
|
||||||
[php7.4]
|
[php7.4]
|
||||||
|
@ -59,3 +61,4 @@ php7.4-gd = bullseye, focal
|
||||||
php7.4-mbstring = bullseye, focal
|
php7.4-mbstring = bullseye, focal
|
||||||
php7.4-pgsql = bullseye, focal
|
php7.4-pgsql = bullseye, focal
|
||||||
php7.4-xml = bullseye, focal
|
php7.4-xml = bullseye, focal
|
||||||
|
php7.4-yaml = bullseye, focal
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
[general]
|
|
||||||
dev_env = testing
|
|
||||||
public_url = http://localhost
|
|
||||||
api_key = H2NRICX6CM8F50CU123C
|
|
||||||
|
|
||||||
[database]
|
|
||||||
host = localhost
|
|
||||||
port = 5432
|
|
||||||
name = libretime_test
|
|
||||||
user = libretime
|
|
||||||
password = libretime
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
general:
|
||||||
|
dev_env: testing
|
||||||
|
public_url: http://localhost
|
||||||
|
api_key: H2NRICX6CM8F50CU123C
|
||||||
|
|
||||||
|
database:
|
||||||
|
host: localhost
|
||||||
|
port: 5432
|
||||||
|
name: libretime_test
|
||||||
|
user: libretime
|
||||||
|
password: libretime
|
|
@ -1,5 +1,4 @@
|
||||||
import sys
|
import sys
|
||||||
from configparser import ConfigParser
|
|
||||||
from os import environ
|
from os import environ
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Dict, List, Optional, Union
|
from typing import Any, Dict, List, Optional, Union
|
||||||
|
@ -96,13 +95,6 @@ class BaseConfig(BaseModel):
|
||||||
logger.warning(f"provided config filepath '{filepath}' is not a file")
|
logger.warning(f"provided config filepath '{filepath}' is not a file")
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
# pylint: disable=fixme
|
|
||||||
# TODO: Remove ability to load ini files once yaml if fully supported.
|
|
||||||
if filepath.suffix == ".conf":
|
|
||||||
config = ConfigParser()
|
|
||||||
config.read_string(filepath.read_text(encoding="utf-8"))
|
|
||||||
return {s: dict(config.items(s)) for s in config.sections()}
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return safe_load(filepath.read_text(encoding="utf-8"))
|
return safe_load(filepath.read_text(encoding="utf-8"))
|
||||||
except YAMLError as error:
|
except YAMLError as error:
|
||||||
|
|
|
@ -134,28 +134,6 @@ def test_base_config_required_submodel(tmp_path: Path):
|
||||||
FixtureWithRequiredSubmodelConfig(filepath=None)
|
FixtureWithRequiredSubmodelConfig(filepath=None)
|
||||||
|
|
||||||
|
|
||||||
FIXTURE_CONFIG_RAW_INI = """
|
|
||||||
[database]
|
|
||||||
host = changed
|
|
||||||
port = 6666
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def test_base_config_ini(tmp_path: Path):
|
|
||||||
config_filepath = tmp_path / "config.conf"
|
|
||||||
config_filepath.write_text(FIXTURE_CONFIG_RAW_INI)
|
|
||||||
|
|
||||||
with mock.patch.dict(
|
|
||||||
environ,
|
|
||||||
{"LIBRETIME_API_KEY": "f3bf04fc"},
|
|
||||||
):
|
|
||||||
config = FixtureConfig(filepath=config_filepath)
|
|
||||||
|
|
||||||
assert config.api_key == "f3bf04fc"
|
|
||||||
assert config.database.host == "changed"
|
|
||||||
assert config.database.port == 6666
|
|
||||||
|
|
||||||
|
|
||||||
FIXTURE_CONFIG_RAW_MISSING = """
|
FIXTURE_CONFIG_RAW_MISSING = """
|
||||||
database:
|
database:
|
||||||
host: "localhost"
|
host: "localhost"
|
||||||
|
|
Loading…
Reference in New Issue