Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: criteo/py-consul
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.3.0
Choose a base ref
...
head repository: criteo/py-consul
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Mar 15, 2024

  1. code-style & ci: update workflow

    Move from black/isort to ruff format and ruff linter "I" rules
    Use uv and tox-uv for faster dependencies installation
    Mathias Brulatout authored and mbrulatout committed Mar 15, 2024
    Copy the full SHA
    261e9e0 View commit details

Commits on Mar 18, 2024

  1. feat: Add an extra_checks param to service registration

    Without breaking compatibility, an optional extra_checks
    list of Checks allows us to register multiple checks during
    service registration.
    
    Note that this was still possible through check registration
    but requires multiple API calls.
    Mathias Brulatout authored and mbrulatout committed Mar 18, 2024
    Copy the full SHA
    52ccd85 View commit details
  2. ci: add python 3.12 support

    Mathias Brulatout authored and mbrulatout committed Mar 18, 2024
    Copy the full SHA
    a4bd129 View commit details
  3. docs: add readme badges with pypi version, python version, and mainta…

    …ined status
    Mathias Brulatout authored and mbrulatout committed Mar 18, 2024
    Copy the full SHA
    d1098ae View commit details
  4. ci: speedup ci with uv

    Mathias Brulatout authored and mbrulatout committed Mar 18, 2024
    Copy the full SHA
    2d71060 View commit details
  5. tests: multi version tests

    This commit introduces multi-version tests.
    Due to the fact that tests were running on consul 1.1.0,
    some tests have been temporarily disabled due to
    issues with newer API.
    
    Will be fixed other commits
    Mathias Brulatout authored and mbrulatout committed Mar 18, 2024
    Copy the full SHA
    45c8d6a View commit details
  6. ci: fix tagged_release workflow

    Mathias Brulatout authored and mbrulatout committed Mar 18, 2024
    Copy the full SHA
    a03af26 View commit details

Commits on Mar 20, 2024

  1. feat: remove consul 1.1 and OSX support

    Mathias Brulatout authored and mbrulatout committed Mar 20, 2024
    Copy the full SHA
    88981a7 View commit details
  2. code-style: use ruff isort autofix

    Mathias Brulatout authored and mbrulatout committed Mar 20, 2024
    Copy the full SHA
    009cbe4 View commit details
  3. tests: add test utils for cleaner API output expected assertion

    Mathias Brulatout authored and mbrulatout committed Mar 20, 2024
    Copy the full SHA
    72463de View commit details
  4. acl: re-implement some basic ACL endpoint

    Due to breaking changes within the ACL API, most endpoints
    had to be reimplemented.
    
    This commit introduces the following full implementation:
    - `acl list`
    - `acl read`
    - `acl delete`
    - `acl clone`
    
    `acl create` and `acl update` ared also introduced but
    currently have limitations since policies and roles aren't
    properly supported yet.
    Mathias Brulatout authored and mbrulatout committed Mar 20, 2024
    Copy the full SHA
    710e0e2 View commit details
  5. tests: fix multi check service registration

    2 PRs were merged in parallel and broke this test.
    Mathias Brulatout authored and mbrulatout committed Mar 20, 2024
    Copy the full SHA
    62c9ea2 View commit details
  6. tests: fix tests

    Moved and extended the should_skip function + fixed some tests
    Enable parallel execution which removes the need to cleanup things
    after a test.
    
    Moved the ACL tests in a specific file.
    Fixtures are now function scoped. This *truly* enables
    multi-version tests.
    Mathias Brulatout authored and mbrulatout committed Mar 20, 2024
    Copy the full SHA
    102167e View commit details
  7. tests: coverage on relevant files only

    Mathias Brulatout authored and mbrulatout committed Mar 20, 2024
    Copy the full SHA
    c8e2679 View commit details
  8. tests: add support for consul 1.17.3

    Mathias Brulatout authored and mbrulatout committed Mar 20, 2024
    Copy the full SHA
    45caf6f View commit details

Commits on Mar 27, 2024

  1. code-style: reorganize the repository

    While the diff is pretty large, this commit
    is just about splitting the base.py and its associated
    test file into various scope-restricted files.
    The api folder is also introduced.
    
    This will ease the development/reviews
    Mathias Brulatout authored and mbrulatout committed Mar 27, 2024
    Copy the full SHA
    37a5dd1 View commit details
  2. env: cleanup old references

    Mathias Brulatout authored and mbrulatout committed Mar 27, 2024
    Copy the full SHA
    83149e1 View commit details
  3. Release version 1.4.0

    Mathias Brulatout authored and mbrulatout committed Mar 27, 2024
    Copy the full SHA
    ec68f70 View commit details
  4. fix: fix package publishing due to conflicting content type

    README was in markdown while CHANGELOG was in reStructuredText.
    Move the CHANGELOG file to markdown format and specify content type
    during package build.
    
    Added package discovery to include sub folders and exclude test files
    Mathias Brulatout authored and mbrulatout committed Mar 27, 2024
    Copy the full SHA
    48b3908 View commit details
  5. ci: update GH actions versions

    Mathias Brulatout authored and mbrulatout committed Mar 27, 2024
    Copy the full SHA
    6ac8410 View commit details
  6. Release version 1.4.1

    Mathias Brulatout authored and mbrulatout committed Mar 27, 2024
    Copy the full SHA
    735a761 View commit details

Commits on Mar 29, 2024

  1. docs: update README following fork detach and project move

    Mathias Brulatout authored and mbrulatout committed Mar 29, 2024
    Copy the full SHA
    232dd9a View commit details

Commits on May 15, 2024

  1. Refactor acl_consul fixture (#72)

    This change is made in preparation for future releases, anticipating the likelihood of deploying multiple instances via Docker.
    cpaillet authored May 15, 2024
    Copy the full SHA
    7501962 View commit details
  2. Introduce policy list/read capabilities (#70)

    - ACL endpoint change, consul.acl is now consul.acl.token
    - add consul.acl.policy.list and acl.policy.read
    cpaillet authored May 15, 2024
    Copy the full SHA
    579a991 View commit details
  3. Copy the full SHA
    c81f7d2 View commit details
  4. ci: update github actions (#74)

    The main workflow now has an appropriate name and the
    fail-fast strategy is disabled, allowing linting and testing
    steps to continue on each python version.
    
    The tagged release workflow do not run linters and tets anymore.
    
    Co-authored-by: Mathias Brulatout <m.brulatout@criteo.com>
    mbrulatout and Mathias Brulatout authored May 15, 2024
    Copy the full SHA
    93df72e View commit details

Commits on May 23, 2024

  1. Enhance Token Creation with Policy Support (#76)

    - Implement creation of policies.
    - Integrate policy addition during token creation.
    cpaillet authored May 23, 2024
    Copy the full SHA
    4042528 View commit details
  2. Release version 1.5.1 (#77)

    cpaillet authored May 23, 2024
    Copy the full SHA
    32570c2 View commit details

Commits on Jul 2, 2024

  1. Copy the full SHA
    c1b120b View commit details

Commits on Jul 3, 2024

  1. Merge pull request #79 from zanloy/master

    Add token authorization to Agent.force_leave
    mbrulatout authored Jul 3, 2024
    Copy the full SHA
    98be675 View commit details

Commits on Aug 27, 2024

  1. Test using consul container instead of plain binaries stored in the r…

    …epo (#80)
    
    * remove deprecated setuptools test command
    
    * tests: replace consul binary execution with docker containers
    
    Drop support for 1.13 and 1.15 (partially for convenience as
    they're not in the hashicorp docker repo).
    We now also capture container logs and store them in a logs/
    folder. Each test will have its own consul log file.
    
    A few linter changes required due to a ruff upgrade.
    
    * tests: move conftest.py up a level to have logs for all tests
    
    * fix KO and flaky tests
    
    * fix(avoid) some more flakyness
    
    * revert fix + unset consul token on local env with an autouse fixture
    
    * split conftest.py to avoid some cyclic import
    
    * remove consistent hack
    
    ---------
    
    Co-authored-by: Mathias Brulatout <m.brulatout@criteo.com>
    mbrulatout and Mathias Brulatout authored Aug 27, 2024
    Copy the full SHA
    8e0e012 View commit details

Commits on Aug 28, 2024

  1. Replace deprecated token query param by X-Consul-Token header (#81)

    * tests: error handling (retry) of container startup
    
    * api: use X-Consul-Token instead of token query parameter
    
    The token parameter throws a warning. It should have been
    removed in Consul 1.17, but somehow it's still supported.
    
    ---------
    
    Co-authored-by: Mathias Brulatout <m.brulatout@criteo.com>
    mbrulatout and Mathias Brulatout authored Aug 28, 2024
    Copy the full SHA
    e2b1dbb View commit details

Commits on Sep 27, 2024

  1. feat: add replace_existing_checks option to Catalog.register() (#85)

    * feat: add replace_existing_checks option to Catalog.register()
    
    - Introduced `replace_existing_checks` parameter in the `register()` method to allow deletion of missing health checks from the request.
    - Ensures idempotent registration of services and their checks without needing manual deregistration of checks.
    cpaillet authored Sep 27, 2024
    Copy the full SHA
    2a59642 View commit details
  2. Release version 1.5.2 (#86)

    cpaillet authored Sep 27, 2024
    Copy the full SHA
    a435112 View commit details

Commits on Oct 1, 2024

  1. feat: add replace_existing_checks option to agent.service.register() (#…

    …87)
    
    * revert: add replace_existing_checks option to Catalog.register()
    
    this param is for agent.service.register
    
    * feat: add replace_existing_checks option to agent.service.register()
    
    - Introduced `replace_existing_checks` parameter in the `register()` method to allow deletion of missing health checks from the request.
    - Ensures idempotent registration of services and their checks without needing manual deregistration of checks.
    
    * Release version 1.5.3
    cpaillet authored Oct 1, 2024
    Copy the full SHA
    daac265 View commit details

Commits on Nov 7, 2024

  1. Partial typing annotation support + add mypy (#82)

    * cb: rename bool callback to boolean
    
    This avoids conflicting with bool type for further
    type annotations
    
    * code-style: add mypy
    
    * code-style: mypy: fix no-untyped-call
    
    * code-style: mypy: add simple types
    
    * mypy: exclude setup.py
    
    * mypy: fix 3.11/3.12 typing issue
    
    * mypy: move tox dir to avoid type issues
    
    * tests: increase min duration in reports
    
    * mypy: add setuptools types
    
    ---------
    
    Co-authored-by: Mathias Brulatout <m.brulatout@criteo.com>
    mbrulatout and Mathias Brulatout authored Nov 7, 2024
    Copy the full SHA
    abea3ff View commit details
  2. ci: add 3.13 and drop support for EOL 3.8 (#89)

    * ci: add 3.13 and drop support for EOL 3.8
    
    * ci:update tox envlist
    
    ---------
    
    Co-authored-by: Mathias Brulatout <m.brulatout@criteo.com>
    mbrulatout and Mathias Brulatout authored Nov 7, 2024
    Copy the full SHA
    7d93521 View commit details

Commits on Nov 25, 2024

  1. Add support for honoring additional arguments in consul.Consul() (#90)

    * Add support for honoring the host and port arguments in consul.Consul()
    
    * honor the scheme and verify arguments as well
    
    * fix lint
    
    * forgot to actually run tox after pulling in the linter suggestions
    
    ---------
    
    Co-authored-by: Emma May <emma.may@logicmonitor.com>
    starhawking and Emma May authored Nov 25, 2024
    Copy the full SHA
    c115896 View commit details

Commits on Jan 9, 2025

  1. Improve robustness of JSON decoding (#91)

    * code-style: update json CB
    
    To avoid too-many-branches in next review.
    
    * Improve robustness of JSON decoding
    
    If JSON decoding fails, if a field is missing, or if there are no fields, a ConsulException is returned.
    
    * Bump CHANGELOG.md
    cpaillet authored Jan 9, 2025
    Copy the full SHA
    3c0413f View commit details
Showing with 4,441 additions and 3,667 deletions.
  1. +7 −7 .github/workflows/main.yml
  2. +2 −2 .github/workflows/manual.yml
  3. +2 −2 .github/workflows/pythonpublish.yml
  4. +0 −4 .github/workflows/tagged_release.yml
  5. +13 −12 .pre-commit-config.yaml
  6. +108 −0 CHANGELOG.md
  7. +0 −68 CHANGELOG.rst
  8. +2 −2 MANIFEST.in
  9. +64 −0 README.md
  10. +0 −51 README.rst
  11. +196 −0 conftest.py
  12. +3 −2 consul/__init__.py
  13. +37 −18 consul/aio.py
  14. 0 consul/api/__init__.py
  15. +10 −0 consul/api/acl/__init__.py
  16. +55 −0 consul/api/acl/policy.py
  17. +120 −0 consul/api/acl/token.py
  18. +431 −0 consul/api/agent.py
  19. +389 −0 consul/api/catalog.py
  20. +26 −0 consul/api/connect.py
  21. +41 −0 consul/api/coordinates.py
  22. +104 −0 consul/api/event.py
  23. +206 −0 consul/api/health.py
  24. +204 −0 consul/api/kv.py
  25. +12 −0 consul/api/operator.py
  26. +233 −0 consul/api/query.py
  27. +206 −0 consul/api/session.py
  28. +25 −0 consul/api/status.py
  29. +37 −0 consul/api/txn.py
  30. +75 −2,304 consul/base.py
  31. +95 −0 consul/callback.py
  32. +116 −0 consul/check.py
  33. +26 −0 consul/exceptions.py
  34. +19 −12 consul/std.py
  35. +52 −23 pyproject.toml
  36. +8 −22 setup.py
  37. +6 −2 tests-requirements.txt
  38. 0 tests/api/__init__.py
  39. +256 −0 tests/api/test_acl.py
  40. +260 −0 tests/api/test_agent.py
  41. +63 −0 tests/api/test_catalog.py
  42. +6 −0 tests/api/test_coordinates.py
  43. +19 −0 tests/api/test_event.py
  44. +150 −0 tests/api/test_health.py
  45. +141 −0 tests/api/test_kv.py
  46. +22 −0 tests/api/test_operator.py
  47. +30 −0 tests/api/test_query.py
  48. +58 −0 tests/api/test_session.py
  49. +19 −0 tests/api/test_status.py
  50. +14 −0 tests/api/test_txn.py
  51. +11 −118 tests/conftest.py
  52. BIN tests/consul.linux64
  53. BIN tests/consul.osx
  54. +119 −86 tests/test_aio.py
  55. +154 −76 tests/test_base.py
  56. +50 −0 tests/test_callback.py
  57. +3 −854 tests/test_std.py
  58. +71 −0 tests/test_utils.py
  59. +60 −0 tests/utils.py
  60. +5 −2 tox.ini
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: Python package
name: Python lint and tests

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
max-parallel: 4
fail-fast: false
max-parallel: 5
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
python -m pip install --upgrade uv tox tox-uv
- name: Test with tox
run: tox -e py
- name: Run linters
4 changes: 2 additions & 2 deletions .github/workflows/manual.yml
Original file line number Diff line number Diff line change
@@ -10,9 +10,9 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
4 changes: 2 additions & 2 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
@@ -8,9 +8,9 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v1
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
4 changes: 0 additions & 4 deletions .github/workflows/tagged_release.yml
Original file line number Diff line number Diff line change
@@ -12,10 +12,6 @@ jobs:
runs-on: "ubuntu-latest"

steps:
# ...
- name: "Build & test"
run: tox -e py

- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
25 changes: 13 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -2,30 +2,31 @@ default_language_version:
python: python3.9
default_install_hook_types: [pre-commit,pre-push]
default_stages: [commit]
exclude: ^docs/

repos:
- repo: local
hooks:
- id: ruff
name: ruff
entry: ruff check
entry: ruff check -n
language: system
types_or: [python]
types_or: [ python ]

- id: black
name: black formatter
- id: ruff format
name: ruff format
entry: ruff format --check .
language: system
entry: black --check
types_or: [python]

- id: isort
name: isort
language: system
entry: isort --filter-files --check
types_or: [python]
types_or: [ python ]

- id: pylint
name: pylint static code analyzer
entry: pylint -rn -sn # Only display messages, don't display the score
language: system
types: [python]

- id: mypy
name: mypy
language: system
entry: mypy --non-interactive --install-types
types: [python]
108 changes: 108 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
# Change log

## 1.5.4

- **feature:** Improve robustness of JSON decoding
- **feature:** Add support for honoring additional arguments in consul.Consul()

## 1.5.3

- **feature:** add replace_existing_checks option to agent.service.register()
- **revert:** add replace_existing_checks option to Catalog.register()

## 1.5.2

- **feature:** add replace_existing_checks option to Catalog.register()

## 1.5.1

- **feature:** Implement creation of policies.
- **feature:** Integrate policy addition during token creation.

## 1.5.0

- **[Breaking]** ACL endpoint change, consul.acl is now consul.acl.token
- **feature:** add consul.acl.policy.list and acl.policy.read

## 1.4.1

- **ci:** fix package publishing and update GH actions versions

## 1.4.0 (unreleased)

- **[Breaking]** due to the re-implementation of the ACL endpoint and the drop of the support of OSX and consul 1.1.0.
- **feature:** re-implement some basic ACL endpoint
- **feature:** drop support of OSX and consul 1.1.0
- **feature:** support multi-check service registration (through extra_checks parameter)
- **env:** support python 3.12
- **tests:** multi consul version test (1.13.8, 1.15.4, 1.16.1, 1.17.3)
- **tests:** add test utils for cleaner API output expected assertion
- **code-style:** use ruff linter and formatter
- **code-style:** split files following the consul API logic
- **ci:** speedup ci with uv/tox-uv

## 1.3.0

- **feature:** drop tornado and twisted support
- **env:** support python 3.10 and 3.11
- **env:** drop support of EOL python versions 3.5, 3.6, and 3.7
- **code-style:** syntax modernization
- **code-style:** formatter and linter use
- **ci:** multiple python version test and linter enforcement

## 1.2.4

- **feature:** aio: allow setting timeout by request

## 1.2.3

- **feature:** base: ensure return format of json callback is more consistent

## 1.2.2

- **bugfix:** connect: fix wrong endpoints callbacks

## 1.2.1

- **feature:** Add support for context-managers
- **feature:** Add support for /agent/service/:service_id API
- **bugfix:** rename internal connect method

## 1.2.0

- **feature:** Support deregister field in Check.script
- **feature:** Introduce Consul Connect-related API wrappers
- **feature:** Add token support missing in multiple methods
- **bugfix:** aio: fix timeout type
- **feature:** allow multiple tags in service health query

## 1.1.5

- Dummy release to overcome a pypi release issue

## 1.1.4

- **bugfix:** fixed connection_timeout usage for aiohttp

## 1.1.3

- **bugfix:** fixed connection_limit usage for aiohttp

## 1.1.2

- add support for connection_limit and connection_timeout in aiohttp
- fix asyncio session close

## 1.1.1

- Add support for python 3.7 and 3.8
- Fix asyncio compatibility to support latest python version
- Remove six dependency
- Use new style of class declaration
- Get rid of py3.4 old compat
- Drop support of deprecated python2
- **base:** allow weights parameter in service register

# Base fork

Criteo starts forking this library from [https://github.com/cablehead/python-consul](https://github.com/cablehead/python-consul)
68 changes: 0 additions & 68 deletions CHANGELOG.rst

This file was deleted.

4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include requirements.txt
include README.rst
include CHANGELOG.rst
include README.md
include CHANGELOG.md
include LICENSE
64 changes: 64 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# py-consul [![PyPi version](https://img.shields.io/pypi/v/py-consul.svg)](https://pypi.python.org/pypi/py-consul/) [![Python version](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) ![Status](https://img.shields.io/badge/status-maintained-green.svg)

Status
-----------
This project is maintained and actively developed by Criteo.
We aim at converging towards a full compatibility with the official Consul API.

We're currently supporting consul 1.13 up to 1.17. Due to quite a few changes
since our development started (see section "A bit of history"), some endpoints are
still partially handled.

Therefore, we are open to contributions and suggestions.

Example
-------

```python
import consul

c = consul.Consul()

# poll a key for updates
index = None
while True:
index, data = c.kv.get('foo', index=index)
print data['Value']

# in another process
c.kv.put('foo', 'bar')
```

Installation
------------
```bash
pip install py-consul
```

**Note:** When using py-consul library in environment with proxy server,
setting of ``http_proxy``, ``https_proxy`` and ``no_proxy`` environment variables
can be required for proper functionality.

A bit of history
-----------

The origin project [python-consul](https://github.com/cablehead/python-consul) is not maintained
since 2018. As we were not able to get in touch with the maintainer (cablehead)
to merge and release our PRs, we've forked the project in order to continue the
maintenance of the project. We also renamed the project to be able to upload
on pypi; see [PyPI](https://pypi.org/project/py-consul/)

Following some major changes, we decided to detach this fork from the original project
and move from [criteo fork space](https://github.com/criteo-forks/)
to [criteo space](https://github.com/criteo/).

Contributing
------------

Please reach out if you're interested in being a maintainer as well. Otherwise,
open a PR or Issue we'll try and respond as quickly as possible.

When you create a PR please ensure:

- To add tests for your new features, if applicable
- To add docstrings for new API features you may add
Loading