-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
176 changed files
with
4,704 additions
and
2,954 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
*.pxd text diff=python | ||
*.py text diff=python | ||
*.py3 text diff=python | ||
*.pyw text diff=python | ||
*.pyx text diff=python | ||
*.pyz text diff=python | ||
*.pyi text diff=python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: ci | ||
|
||
on: [ push, pull_request ] | ||
|
||
jobs: | ||
tests: | ||
strategy: | ||
matrix: | ||
python-version: ['3.8', '3.9', '3.10', '3.11'] | ||
os: [ubuntu] | ||
fail-fast: true | ||
runs-on: ${{ matrix.os }}-latest | ||
timeout-minutes: 15 | ||
steps: | ||
- uses: actions/checkout@master | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
architecture: x64 | ||
- uses: actions/cache@v2 | ||
with: | ||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements-dev.txt') }} | ||
path: ~/.cache/pip | ||
restore-keys: | | ||
${{ runner.os }}-pip- | ||
- name: Install Python dependencies | ||
uses: py-actions/py-dependency-install@v2 | ||
with: | ||
path: "./requirements-dev.txt" | ||
- name: Run lint & tests | ||
run: | | ||
make ci SKIP_STYLE=true | ||
- name: Upload coverage to Codecov | ||
uses: codecov/codecov-action@v1 | ||
with: | ||
file: ./coverage.xml | ||
fail_ci_if_error: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
fail_fast: false | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: black | ||
name: black | ||
entry: black | ||
language: system | ||
types: [python] | ||
- id: isort | ||
name: isort | ||
entry: isort | ||
language: system | ||
types: [python] | ||
args: ["--profile", "black"] | ||
- id: flake8 | ||
name: flake8 | ||
entry: flake8 | ||
language: system | ||
types: [ python ] | ||
- id: mypy | ||
name: mypy | ||
entry: mypy | ||
language: system | ||
types: [ python ] | ||
- repo: https://github.com/Lucas-C/pre-commit-hooks | ||
rev: v1.3.0 | ||
hooks: | ||
- id: forbid-crlf | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: check-case-conflict | ||
- id: check-merge-conflict | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
.DEFAULT_GOAL := about | ||
VERSION := $(shell cat discovery/__version__.py | cut -d'"' -f2) | ||
DTYPE=server | ||
VERSION := $(shell cat discovery/__init__.py | grep version | cut -d'"' -f2) | ||
|
||
lint: | ||
ifeq ($(SKIP_STYLE), ) | ||
@echo "> running isort..." | ||
isort -rc discovery | ||
isort -rc tests | ||
isort discovery --profile black | ||
isort tests --profile black | ||
@echo "> running black..." | ||
black discovery | ||
black tests | ||
endif | ||
@echo "> running flake8..." | ||
flake8 discovery | ||
flake8 tests | ||
|
@@ -17,43 +18,45 @@ lint: | |
|
||
tests: | ||
@echo "> running tests" | ||
python -m pytest -v --cov-report xml --cov-report term --cov=discovery tests | ||
python -m pytest -vv --no-cov-on-fail --color=yes --cov-report xml --cov-report term --cov=discovery tests | ||
|
||
ci: lint tests | ||
ifeq ($(GITHUB_HEAD_REF), false) | ||
@echo "--- codecov report ---" | ||
codecov --file coverage.xml -t $$CODECOV_TOKEN | ||
@echo "--- codeclimate report ---" | ||
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | ||
chmod +x ./cc-test-reporter | ||
./cc-test-reporter format-coverage -t coverage.py -o codeclimate.json | ||
./cc-test-reporter upload-coverage -i codeclimate.json -r $$CC_TEST_REPORTER_ID | ||
endif | ||
|
||
docs: | ||
@echo "> generate project documentation..." | ||
portray $(DTYPE) | ||
@cp README.md docs/index.md | ||
mkdocs serve | ||
|
||
tox: | ||
@echo "> running tox..." | ||
tox -r -p all | ||
|
||
install-deps: | ||
@echo "> installing development dependencies..." | ||
@echo "> installing dependencies..." | ||
pip install -r requirements-dev.txt | ||
pre-commit install | ||
|
||
about: | ||
@echo "> discovery-client v$(VERSION)" | ||
@echo "> discovery-client $(VERSION)" | ||
@echo "" | ||
@echo "make lint - Runs: [isort > black > flake8 > mypy]" | ||
@echo "make tests - Execute tests" | ||
@echo "make tox - Runs tox" | ||
@echo "make docs - Generate project documentation [DTYPE=server]" | ||
@echo "make ci - Runs: [make lint > make tests]" | ||
@echo "make install-deps - Install development dependencies" | ||
@echo "make tox - Runs tox" | ||
@echo "make docs - Generate project documentation" | ||
@echo "make install-deps - Install development dependencies." | ||
@echo "" | ||
@echo "mailto: [email protected]" | ||
|
||
ci: lint tests | ||
ifeq ($(CI), true) | ||
@echo "--- download CI dependencies ---" | ||
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter | ||
chmod +x ./cc-test-reporter | ||
@echo "--- report upload ---" | ||
codecov --file coverage.xml -t $$CODECOV_TOKEN | ||
./cc-test-reporter format-coverage -t coverage.py -o codeclimate.json | ||
./cc-test-reporter upload-coverage -i codeclimate.json -r $$CC_TEST_REPORTER_ID | ||
endif | ||
|
||
tox: | ||
@echo "> running tox..." | ||
tox -r -p all | ||
|
||
all: install-deps ci docs | ||
all: ci tox | ||
|
||
.PHONY: lint tests docs about ci all | ||
.PHONY: lint tests ci tox docs all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,37 @@ | ||
[![Build Status](https://travis-ci.org/amenezes/discovery-client.svg?branch=master)](https://travis-ci.org/amenezes/discovery-client) | ||
[![Maintainability](https://api.codeclimate.com/v1/badges/fc7916aab464c8b7d742/maintainability)](https://codeclimate.com/github/amenezes/discovery-client/maintainability) | ||
[![ci](https://github.com/amenezes/discovery-client/workflows/ci/badge.svg)](https://github.com/amenezes/discovery-client/actions) | ||
[![codecov](https://codecov.io/gh/amenezes/discovery-client/branch/master/graph/badge.svg)](https://codecov.io/gh/amenezes/discovery-client) | ||
[![PyPI version](https://badge.fury.io/py/discovery-client.svg)](https://badge.fury.io/py/discovery-client) | ||
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/discovery-client) | ||
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) | ||
|
||
# discovery-client | ||
|
||
async client [consul](https://consul.io). | ||
Async Python client for [consul](https://consul.io). | ||
|
||
HTTP engine options available: | ||
|
||
- aiohttp `default`; | ||
- httpx. | ||
|
||
## Installing | ||
|
||
Install and update using pip: | ||
|
||
### default client | ||
|
||
````bash | ||
pip install -U discovery-client | ||
```` | ||
|
||
### httpx client | ||
|
||
````bash | ||
pip install -U 'discovery-client[httpx]' | ||
```` | ||
|
||
## Links | ||
|
||
- License: [Apache License](https://choosealicense.com/licenses/apache-2.0/) | ||
- Code: https://github.com/amenezes/discovery-client | ||
- Issue tracker: https://github.com/amenezes/discovery-client/issues | ||
- Docs: https://discovery-client.amenezes.net | ||
- Code: [https://github.com/amenezes/discovery-client](https://github.com/amenezes/discovery-client) | ||
- Issue tracker: [https://github.com/amenezes/discovery-client/issues](https://github.com/amenezes/discovery-client/issues) | ||
- Docs: [https://discovery-client.amenezes.net](https://discovery-client.amenezes.net) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,31 @@ | ||
import logging | ||
from . import checks, utils | ||
from ._logger import log | ||
from .api import ( | ||
Behavior, | ||
CheckStatus, | ||
HealthState, | ||
IntentionFilter, | ||
IntentionsAction, | ||
LogLevel, | ||
TokenLocality, | ||
TokenType, | ||
kind, | ||
) | ||
from .client import Consul | ||
|
||
from discovery.__version__ import __version__ | ||
|
||
log = logging.getLogger("discovery-client") | ||
log.addHandler(logging.NullHandler()) | ||
__version__ = "1.0.0" | ||
__all__ = [ | ||
"Consul", | ||
"HealthState", | ||
"LogLevel", | ||
"TokenType", | ||
"checks", | ||
"utils", | ||
"Kind", | ||
"TokenLocality", | ||
"IntentionsAction", | ||
"IntentionFilter", | ||
"IntentionBy", | ||
"CheckStatus", | ||
"Behavior", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,4 @@ | ||
from cleo import Application | ||
from dotenv import load_dotenv | ||
|
||
from discovery import __version__ | ||
from discovery.cli.commands import CatalogCommand | ||
|
||
load_dotenv() | ||
|
||
application = Application("discovery-client", f"{__version__}") | ||
application.add(CatalogCommand()) | ||
|
||
from discovery.cli import cli | ||
|
||
if __name__ == "__main__": | ||
application.run() | ||
cli() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import logging | ||
|
||
log = logging.getLogger("discovery-client") | ||
log.addHandler(logging.NullHandler()) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.