* feat: 🩺 allow customized health check endpoint
Get the liveness endpoint from the environment variable `HEALTH_ENDPOINT` and verify it. If the customized endpoint is invalied, it will fallback to the DEFAULT_HEALTH_ENDPOINT.
* test: ✅ Test customized endpoint feature
* fix: 🚨 fix check
* feat: Use CLI interface to set health endpoint
* style: 💄 fix black format
* Separate 'build app' and 'add routes'
https://github.com/pypiserver/pypiserver/pull/442#discussion_r973771421
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
* keep DEFAULTS in config.py
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
* style alignment
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
* make CLI arg description more clear
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
* style: 🎨 style alignment
* refactor: ✅ SRP, add routes after app created, instead of patching in app_from_config
* style: 🎨 format CLI help
* test: ✅ add test_setup_routes_from_config
* fix: 🐛 test name doesn't work as expected because of using the wrong ids generator.
* test: 🧪 add config error cases for health endpoint
* test: ✅ fix health_endpoint_arg tests
* fix: ✅ Do not fallback to default silently, should raise error
* test: 🧪 add test_health_endpoint in test_main
* test: ✅ setup routes in main
* docs: 📝 Update the help command output in the Quickstart
* docs: 🐛 missing space
* docs: 📝 Add 'Custom Health Check Endpoint' to 'Recipes'
* docs: 📝 refine README
* revert: ⏪ revert auto isoft
* build: 💚 fix mypy, missing return types
* Update README.rst
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
* Update README.rst
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
* Update pypiserver/config.py
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
* Update README.rst
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
* style: 💄 black format
* Update README.rst
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
Co-authored-by: Dmitrii Orlov <dmtree.dev@yahoo.com>
* Docker improvements
This addresses much of what was brought up in #359. Specifically, it:
- Significantly improves testing for the Docker image, adding a
`docker/test_docker.py` file using the regular pytest machinery to
set up and run docker images for testing
- Hopefully addresses a variety of permissions issues, by being explicit
about what access pypiserver needs and asking for it, only erroring
if that access is not available
- Requires RX permissions on `/data` (R to read files, X to list files
and to be able to cd into the directory. This is important since
`/data` is the `WORKDIR`)
- Requires RWX permissions on `/data/packages`, so that we can list
packages, write packages, and read packages.
- When running in the default configuration (as root on Linux or
as the pypiserver-named rootish user on Mac), with no volumes
mounted, these requirements are all satisfied
- Volume mounts still must be readable by the pypiserver user (UID
9898) in order for the container to run. However, we now error early
if this is not the case, and direct users to a useful issue.
- If the container is run as a non-root, non-pypiserver user (e.g.
because someone ran `docker run --user=<user_id>`, we try to run
pypiserver as that user). Provided that user has access to the
necessary directories, it should run fine.
- Fixes issues with running help and similar commands
- Updates the Docker image to use `PYPISERVER_PORT` for port
specification, while still falling back to `PORT` for backwards
compatibility
- Moves some docker-related things into a `/docker` directory
- Adds a `Makefile` for building a test fixture package sdist and wheel,
so that test code can call `make mypkg` and not need to worry about it
potentially building multiple times
The only issue #359 raises that's not addressed here is the one of
running pypiserver in the Docker container using some non-default server
for performance. I would like to do some benchmarking before deciding on
what to do there.
This PR is a pretty substantial refactor of the entrypoints of pypiserver (`__main__` and `__init__`) to use the argparse-based config added in #339.
- Updated `RunConfig` and `UpdateConfig` classes to have exclusive init kwargs, instead of taking an namespace. This turned out to be much easier when working with the library-style app initialization in `__init__`, both for direct instantiation and via paste config
- Added an `iter_packages()` method to the `RunConfig` to iterate over packages specified by the configuration (note @elfjes, I think that replacing this with e.g. a `backend` reference will be a nice way to tie in #348)
- Added a general-purpose method to map legacy keyword arguments to the `app()` and `paste_app_factory()` functions to updated forms
- Refactored the `paste_app_factory()` to not mutate the incoming dictionary
- Removed all argument-parsing and config-related code from `__main__` and `core`
- Moved `_logwrite` from `__init__` to `__main__`, since that was the only place it was being used after the updates to `core`
- Updated `digest_file` to use `hashlib.new(algo)` instead of `getattr(hashlib, algo)`, because the former supports more algorithms
- Updated `setup.py` to, instead of calling `eval()` on the entirety of `__init__`, to instead just evaluate the line that defines the version
- Assigned the config to a `._pypiserver_config` attribute on the `Bottle` instance to reduce hacky test workarounds
- Fixed the tox config, which I broke in #339
* Config: add auth & absolute path resolution
* Config: check pkg dirs on config creation
* Instantiate config with kwargs, not namespace
* WIP: still pulling the threads
* Init seems to be working
* tests passing locally, still need to update cache
* Fix tox command
* unused import
* Fix typing
* Be more selective in exec() in setup.py
* Require accurate casing for hash algos
* Remove old comment
* Comments, minor updates and simplifications
* move _logwrite to a more reasonable place
* Update config to work with cache
* Type cachemanager listdir in core
* Update config module docstring, rename method
* Add more comments re: paste config
* Add comments to main, remove unneded check
* Remove commented code
* Use {posargs} instead of [] for clarity in tox
* Add dupe check for kwarg updater
* Remove unused references on app instance
* Fix typo
* Remove redundancy in log level parsing
* run black on codebase
* add black check to travis ci
* add pyproject.toml, revert black on bottle.py
Co-authored-by: Pelle Koster <pelle.koster@nginfra.nl>
The ability to propagate configuration values from a paste config
file was introduced in #156. However, as pointed out in #125
by @redbaron4, the string strip method introduced in #156 was
problematic in Python 2.
This resolves that issue while also creating a test that fails
on the current master and passes with updates, demonstrating the
issue.