We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Enabling the flush endpoint through env vars does not seem to work
I'm running Kinto + postgres with docker-compose (using the example docker-compose.yml in the repo). 

Adding `KINTO_FLUSH_ENDPOINT_ENABLED` to the environment section in docker-compose.yml does not enable the flush endpoint for me. I instead had to add `kinto.flush_endpoint_enabled = true` to a custom ini file, that worked.

Can the flush endpoint be enabled through an env var like this?


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `kinto/__init__.py`
Content:
```
1 import pkg_resources
2 import logging
3 
4 import kinto.core
5 from pyramid.config import Configurator
6 from pyramid.settings import asbool
7 from pyramid.security import Authenticated
8 
9 from kinto.authorization import RouteFactory
10 
11 # Module version, as defined in PEP-0396.
12 __version__ = pkg_resources.get_distribution(__package__).version
13 
14 # Implemented HTTP API Version
15 HTTP_API_VERSION = '1.5'
16 
17 # Main kinto logger
18 logger = logging.getLogger(__name__)
19 
20 
21 DEFAULT_SETTINGS = {
22     'retry_after_seconds': 3,
23     'cache_backend': 'kinto.core.cache.memory',
24     'permission_backend': 'kinto.core.permission.memory',
25     'storage_backend': 'kinto.core.storage.memory',
26     'project_docs': 'https://kinto.readthedocs.io/',
27     'bucket_create_principals': Authenticated,
28     'multiauth.authorization_policy': (
29         'kinto.authorization.AuthorizationPolicy'),
30     'experimental_collection_schema_validation': 'False',
31     'http_api_version': HTTP_API_VERSION
32 }
33 
34 
35 def main(global_config, config=None, **settings):
36     if not config:
37         config = Configurator(settings=settings, root_factory=RouteFactory)
38 
39     # Force project name, since it determines settings prefix.
40     config.add_settings({'kinto.project_name': 'kinto'})
41 
42     kinto.core.initialize(config,
43                           version=__version__,
44                           default_settings=DEFAULT_SETTINGS)
45 
46     settings = config.get_settings()
47 
48     # Expose capability
49     schema_enabled = asbool(
50         settings['experimental_collection_schema_validation']
51     )
52     if schema_enabled:
53         config.add_api_capability(
54             "schema",
55             description="Validates collection records with JSON schemas.",
56             url="http://kinto.readthedocs.io/en/latest/api/1.x/"
57                 "collections.html#collection-json-schema")
58 
59     # Scan Kinto views.
60     kwargs = {}
61     flush_enabled = asbool(settings.get('flush_endpoint_enabled'))
62 
63     if flush_enabled:
64         config.add_api_capability(
65             "flush_endpoint",
66             description="The __flush__ endpoint can be used to remove all "
67                         "data from all backends.",
68             url="http://kinto.readthedocs.io/en/latest/configuration/"
69                 "settings.html#activating-the-flush-endpoint"
70         )
71     else:
72         kwargs['ignore'] = 'kinto.views.flush'
73     config.scan("kinto.views", **kwargs)
74 
75     app = config.make_wsgi_app()
76 
77     # Install middleware (idempotent if disabled)
78     return kinto.core.install_middlewares(app, settings)
79
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/kinto/__init__.py b/kinto/__init__.py
--- a/kinto/__init__.py
+++ b/kinto/__init__.py
@@ -19,6 +19,7 @@
 
 
 DEFAULT_SETTINGS = {
+    'flush_endpoint_enabled': False,
     'retry_after_seconds': 3,
     'cache_backend': 'kinto.core.cache.memory',
     'permission_backend': 'kinto.core.permission.memory',
@@ -58,18 +59,18 @@
 
     # Scan Kinto views.
     kwargs = {}
-    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))
 
+    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))
     if flush_enabled:
         config.add_api_capability(
             "flush_endpoint",
             description="The __flush__ endpoint can be used to remove all "
                         "data from all backends.",
             url="http://kinto.readthedocs.io/en/latest/configuration/"
-                "settings.html#activating-the-flush-endpoint"
-        )
+                "settings.html#activating-the-flush-endpoint")
     else:
         kwargs['ignore'] = 'kinto.views.flush'
+
     config.scan("kinto.views", **kwargs)
 
     app = config.make_wsgi_app()

{"golden_diff": "diff --git a/kinto/__init__.py b/kinto/__init__.py\n--- a/kinto/__init__.py\n+++ b/kinto/__init__.py\n@@ -19,6 +19,7 @@\n \n \n DEFAULT_SETTINGS = {\n+    'flush_endpoint_enabled': False,\n     'retry_after_seconds': 3,\n     'cache_backend': 'kinto.core.cache.memory',\n     'permission_backend': 'kinto.core.permission.memory',\n@@ -58,18 +59,18 @@\n \n     # Scan Kinto views.\n     kwargs = {}\n-    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))\n \n+    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))\n     if flush_enabled:\n         config.add_api_capability(\n             \"flush_endpoint\",\n             description=\"The __flush__ endpoint can be used to remove all \"\n                         \"data from all backends.\",\n             url=\"http://kinto.readthedocs.io/en/latest/configuration/\"\n-                \"settings.html#activating-the-flush-endpoint\"\n-        )\n+                \"settings.html#activating-the-flush-endpoint\")\n     else:\n         kwargs['ignore'] = 'kinto.views.flush'\n+\n     config.scan(\"kinto.views\", **kwargs)\n \n     app = config.make_wsgi_app()\n", "issue": "Enabling the flush endpoint through env vars does not seem to work\nI'm running Kinto + postgres with docker-compose (using the example docker-compose.yml in the repo). \n\nAdding `KINTO_FLUSH_ENDPOINT_ENABLED` to the environment section in docker-compose.yml does not enable the flush endpoint for me. I instead had to add `kinto.flush_endpoint_enabled = true` to a custom ini file, that worked.\n\nCan the flush endpoint be enabled through an env var like this?\n\n", "before_files": [{"content": "import pkg_resources\nimport logging\n\nimport kinto.core\nfrom pyramid.config import Configurator\nfrom pyramid.settings import asbool\nfrom pyramid.security import Authenticated\n\nfrom kinto.authorization import RouteFactory\n\n# Module version, as defined in PEP-0396.\n__version__ = pkg_resources.get_distribution(__package__).version\n\n# Implemented HTTP API Version\nHTTP_API_VERSION = '1.5'\n\n# Main kinto logger\nlogger = logging.getLogger(__name__)\n\n\nDEFAULT_SETTINGS = {\n    'retry_after_seconds': 3,\n    'cache_backend': 'kinto.core.cache.memory',\n    'permission_backend': 'kinto.core.permission.memory',\n    'storage_backend': 'kinto.core.storage.memory',\n    'project_docs': 'https://kinto.readthedocs.io/',\n    'bucket_create_principals': Authenticated,\n    'multiauth.authorization_policy': (\n        'kinto.authorization.AuthorizationPolicy'),\n    'experimental_collection_schema_validation': 'False',\n    'http_api_version': HTTP_API_VERSION\n}\n\n\ndef main(global_config, config=None, **settings):\n    if not config:\n        config = Configurator(settings=settings, root_factory=RouteFactory)\n\n    # Force project name, since it determines settings prefix.\n    config.add_settings({'kinto.project_name': 'kinto'})\n\n    kinto.core.initialize(config,\n                          version=__version__,\n                          default_settings=DEFAULT_SETTINGS)\n\n    settings = config.get_settings()\n\n    # Expose capability\n    schema_enabled = asbool(\n        settings['experimental_collection_schema_validation']\n    )\n    if schema_enabled:\n        config.add_api_capability(\n            \"schema\",\n            description=\"Validates collection records with JSON schemas.\",\n            url=\"http://kinto.readthedocs.io/en/latest/api/1.x/\"\n                \"collections.html#collection-json-schema\")\n\n    # Scan Kinto views.\n    kwargs = {}\n    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))\n\n    if flush_enabled:\n        config.add_api_capability(\n            \"flush_endpoint\",\n            description=\"The __flush__ endpoint can be used to remove all \"\n                        \"data from all backends.\",\n            url=\"http://kinto.readthedocs.io/en/latest/configuration/\"\n                \"settings.html#activating-the-flush-endpoint\"\n        )\n    else:\n        kwargs['ignore'] = 'kinto.views.flush'\n    config.scan(\"kinto.views\", **kwargs)\n\n    app = config.make_wsgi_app()\n\n    # Install middleware (idempotent if disabled)\n    return kinto.core.install_middlewares(app, settings)\n", "path": "kinto/__init__.py"}], "after_files": [{"content": "import pkg_resources\nimport logging\n\nimport kinto.core\nfrom pyramid.config import Configurator\nfrom pyramid.settings import asbool\nfrom pyramid.security import Authenticated\n\nfrom kinto.authorization import RouteFactory\n\n# Module version, as defined in PEP-0396.\n__version__ = pkg_resources.get_distribution(__package__).version\n\n# Implemented HTTP API Version\nHTTP_API_VERSION = '1.5'\n\n# Main kinto logger\nlogger = logging.getLogger(__name__)\n\n\nDEFAULT_SETTINGS = {\n    'flush_endpoint_enabled': False,\n    'retry_after_seconds': 3,\n    'cache_backend': 'kinto.core.cache.memory',\n    'permission_backend': 'kinto.core.permission.memory',\n    'storage_backend': 'kinto.core.storage.memory',\n    'project_docs': 'https://kinto.readthedocs.io/',\n    'bucket_create_principals': Authenticated,\n    'multiauth.authorization_policy': (\n        'kinto.authorization.AuthorizationPolicy'),\n    'experimental_collection_schema_validation': 'False',\n    'http_api_version': HTTP_API_VERSION\n}\n\n\ndef main(global_config, config=None, **settings):\n    if not config:\n        config = Configurator(settings=settings, root_factory=RouteFactory)\n\n    # Force project name, since it determines settings prefix.\n    config.add_settings({'kinto.project_name': 'kinto'})\n\n    kinto.core.initialize(config,\n                          version=__version__,\n                          default_settings=DEFAULT_SETTINGS)\n\n    settings = config.get_settings()\n\n    # Expose capability\n    schema_enabled = asbool(\n        settings['experimental_collection_schema_validation']\n    )\n    if schema_enabled:\n        config.add_api_capability(\n            \"schema\",\n            description=\"Validates collection records with JSON schemas.\",\n            url=\"http://kinto.readthedocs.io/en/latest/api/1.x/\"\n                \"collections.html#collection-json-schema\")\n\n    # Scan Kinto views.\n    kwargs = {}\n\n    flush_enabled = asbool(settings.get('flush_endpoint_enabled'))\n    if flush_enabled:\n        config.add_api_capability(\n            \"flush_endpoint\",\n            description=\"The __flush__ endpoint can be used to remove all \"\n                        \"data from all backends.\",\n            url=\"http://kinto.readthedocs.io/en/latest/configuration/\"\n                \"settings.html#activating-the-flush-endpoint\")\n    else:\n        kwargs['ignore'] = 'kinto.views.flush'\n\n    config.scan(\"kinto.views\", **kwargs)\n\n    app = config.make_wsgi_app()\n\n    # Install middleware (idempotent if disabled)\n    return kinto.core.install_middlewares(app, settings)\n", "path": "kinto/__init__.py"}]}