Skip to content

Commit 5ecb426

Browse files
author
Sergio García Prado
committed
Merge remote-tracking branch 'origin/issue-367-add-database-client' into issue-371-add-database-operation
2 parents b831356 + e38d947 commit 5ecb426

24 files changed

+1974
-2
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: "Publish: minos-discovery-kong"
2+
3+
on:
4+
push:
5+
branches:
6+
- '*.*.x'
7+
paths:
8+
- 'packages/plugins/minos-discovery-kong/**'
9+
10+
jobs:
11+
deploy:
12+
runs-on: ubuntu-latest
13+
container: python:3.9-buster
14+
defaults:
15+
run:
16+
working-directory: packages/plugins/minos-discovery-kong
17+
18+
steps:
19+
20+
- name: Check out repository code
21+
uses: actions/checkout@v2
22+
23+
- name: Install Poetry
24+
uses: snok/install-poetry@v1
25+
26+
- name: Install dependencies
27+
run: make install
28+
29+
- name: Publish package
30+
run: make release
31+
env:
32+
POETRY_HTTP_BASIC_PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
33+
POETRY_HTTP_BASIC_PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: "Test: minos-discovery-kong"
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- '*.*.x'
8+
pull_request:
9+
paths:
10+
- 'packages/plugins/minos-discovery-kong/**'
11+
- 'packages/core/minos-microservice-networks/**'
12+
- 'packages/core/minos-microservice-common/**'
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
container: python:3.9-buster
18+
services:
19+
postgres:
20+
image: postgres:9.5
21+
env:
22+
POSTGRES_DB: kong
23+
POSTGRES_USER: kong
24+
POSTGRES_PASSWORD: kong
25+
ports:
26+
# Maps tcp port 5432 on service container to the host
27+
- 5432:5432
28+
defaults:
29+
run:
30+
working-directory: packages/plugins/minos-discovery-kong
31+
32+
steps:
33+
- name: Check out repository code
34+
uses: actions/checkout@v2
35+
36+
- name: Install dependencies
37+
run: apt install -y curl apt-transport-https
38+
39+
- name: Update apt list
40+
run: echo "deb [trusted=yes] https://download.konghq.com/gateway-2.x-debian-buster/ default all" | tee /etc/apt/sources.list.d/kong.list
41+
42+
- name: Install kong
43+
run: apt-get update && apt install -y kong-enterprise-edition=2.8.0.0
44+
45+
- name: Set env variables
46+
run: |
47+
echo "KONG_DATABASE=postgres" >> $GITHUB_ENV
48+
echo "KONG_PG_DATABASE=kong" >> $GITHUB_ENV
49+
echo "KONG_PG_HOST=postgres" >> $GITHUB_ENV
50+
echo "KONG_PG_USER=kong" >> $GITHUB_ENV
51+
echo "KONG_PG_PASSWORD=kong" >> $GITHUB_ENV
52+
echo "KONG_ADMIN_ACCESS_LOG=/dev/stdout" >> $GITHUB_ENV
53+
echo "KONG_ADMIN_ERROR_LOG=/dev/stderr" >> $GITHUB_ENV
54+
echo "KONG_PROXY_LISTEN=0.0.0.0:8000" >> $GITHUB_ENV
55+
echo "KONG_ADMIN_LISTEN=0.0.0.0:8001" >> $GITHUB_ENV
56+
echo "KONG_PROXY_ACCESS_LOG=/dev/stdout" >> $GITHUB_ENV
57+
echo "KONG_PROXY_ERROR_LOG=/dev/stderr" >> $GITHUB_ENV
58+
echo "KONG_LOG_LEVEL=debug" >> $GITHUB_ENV
59+
60+
- name: Kong Migration
61+
run: kong migrations bootstrap && kong migrations up && kong migrations finish
62+
63+
- name: Kong Start
64+
run: kong start
65+
66+
- name: Install Poetry
67+
uses: snok/install-poetry@v1
68+
69+
- name: Install dependencies
70+
run: make install
71+
72+
- name: Lint package
73+
run: make lint
74+
75+
- name: Test package with coverage
76+
run: make coverage
77+
78+
- name: Publish coverage
79+
uses: codecov/codecov-action@v2
80+
with:
81+
token: ${{ secrets.CODECOV_TOKEN }}
82+
files: ./packages/plugins/minos-discovery-kong/coverage.xml
83+
fail_ci_if_error: true
84+
85+
- name: Generate build
86+
run: make dist

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ repos:
5151
files: ^packages/plugins/minos-discovery-minos/
5252
language: system
5353

54+
- id: minos-discovery-kong-check
55+
pass_filenames: false
56+
entry: make --directory=packages/plugins/minos-discovery-kong check
57+
name: Check minos-discovery-kong
58+
files: ^packages/plugins/minos-discovery-kong/
59+
language: system
60+
5461
- id: minos-http-aiohttp-check
5562
pass_filenames: false
5663
entry: make --directory=packages/plugins/minos-http-aiohttp check

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Minos is a framework which helps you create [reactive](https://www.reactivemanif
3232
minos.plugins.kafka
3333
minos.plugins.rabbitmq
3434
minos.plugins.minos_discovery
35+
minos.plugins.kong
3536
minos.plugins.aiohttp
3637
minos.plugins.graphql
3738

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Credits
2+
3+
## Development Lead
4+
5+
* Andrea Mucci <[email protected]>
6+
7+
## Core Devs
8+
9+
* Sergio Garcia Prado <[email protected]>
10+
* Vladyslav Fenchak <[email protected]>
11+
* Alberto Amigo Alonso <[email protected]>
12+
13+
## Contributors
14+
15+
None yet. Why not be the first?
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# History
2+
3+
## 0.1.0a0 (2022-03-31)
4+
5+
* First Alpha release
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Clariteia
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.PHONY: dist
2+
3+
lint:
4+
poetry run flake8
5+
6+
test:
7+
poetry run pytest
8+
9+
coverage:
10+
poetry run coverage run -m pytest
11+
poetry run coverage report -m
12+
poetry run coverage xml
13+
14+
reformat:
15+
poetry run black --line-length 120 minos tests
16+
poetry run isort minos tests
17+
18+
release:
19+
$(MAKE) dist
20+
poetry publish
21+
22+
dist:
23+
poetry build
24+
ls -l dist
25+
26+
install:
27+
poetry install
28+
29+
update:
30+
poetry update
31+
32+
check:
33+
$(MAKE) install
34+
$(MAKE) reformat
35+
$(MAKE) lint
36+
$(MAKE) test
37+
$(MAKE) dist
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
<p align="center">
2+
<a href="https://minos.run" target="_blank"><img src="https://raw.githubusercontent.com/minos-framework/.github/main/images/logo.png" alt="Minos logo"></a>
3+
</p>
4+
5+
## minos-kong
6+
7+
[![PyPI Latest Release](https://img.shields.io/pypi/v/minos-kong.svg)](https://pypi.org/project/minos-kong/)
8+
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/minos-framework/minos-python/pages%20build%20and%20deployment?label=docs)](https://minos-framework.github.io/minos-python)
9+
[![License](https://img.shields.io/github/license/minos-framework/minos-python.svg)](https://github.com/minos-framework/minos-python/blob/main/LICENSE)
10+
[![Coverage](https://codecov.io/github/minos-framework/minos-python/coverage.svg?branch=main)](https://codecov.io/gh/minos-framework/minos-python)
11+
[![Stack Overflow](https://img.shields.io/badge/Stack%20Overflow-Ask%20a%20question-green)](https://stackoverflow.com/questions/tagged/minos)
12+
13+
## Summary
14+
Pre-Alpha release, use at your own risk
15+
Minos Kong is a plugin that integrate minos micorservices with Kong API Gateway
16+
17+
## Installation
18+
19+
Install the dependency:
20+
21+
```shell
22+
pip install minos-discovery-kong
23+
```
24+
25+
Modify `config.yml` file:
26+
27+
```yaml
28+
...
29+
discovery:
30+
connector: minos.networks.DiscoveryConnector
31+
client: minos.plugins.kong.KongDiscoveryClient
32+
host: localhost
33+
port: 8001
34+
...
35+
```
36+
37+
## How to
38+
The above configuration is sufficient for the microservice to subscribe on startup and unsubscribe on shutdown.
39+
Therefore, all you would have to do would be to make your requests against:
40+
41+
`http://localhost:8000/your_endpoint`
42+
43+
## Kong official documentation
44+
### Official docs
45+
You can get read the official docs [here](https://docs.konghq.com/gateway/2.8.x/admin-api/).
46+
47+
### Postman
48+
49+
You can get the official postman collection for postman [here](https://documenter.getpostman.com/view/10587735/SzS7QS2c#intro).
50+
51+
## Konga - Administrative interface
52+
For development purposes you can add open-source administrative section by using next docker service:
53+
```yaml
54+
services:
55+
...
56+
konga:
57+
image: pantsel/konga
58+
ports:
59+
- 1337:1337
60+
links:
61+
- kong:kong
62+
container_name: konga
63+
environment:
64+
- NODE_ENV=production
65+
```
66+
67+
You can get read the official docs [here](https://pantsel.github.io/konga/).
68+
## Documentation
69+
70+
The official API Reference is publicly available at the [GitHub Pages](https://minos-framework.github.io/minos-python).
71+
72+
## Source Code
73+
74+
The source code of this project is hosted at the [GitHub Repository](https://github.com/minos-framework/minos-python).
75+
76+
## Getting Help
77+
78+
For usage questions, the best place to go to is [StackOverflow](https://stackoverflow.com/questions/tagged/minos).
79+
80+
## Discussion and Development
81+
82+
Most development discussions take place over the [GitHub Issues](https://github.com/minos-framework/minos-python/issues). In addition, a [Gitter channel](https://gitter.im/minos-framework/community) is available for development-related questions.
83+
84+
## License
85+
86+
This project is distributed under the [MIT](https://raw.githubusercontent.com/minos-framework/minos-python/main/LICENSE) license.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Run the tests
2+
3+
In order to run the tests, please make sure you have the `Docker Engine <https://docs.docker.com/engine/install/>`_
4+
and `Docker Compose <https://docs.docker.com/compose/install/>`_ installed.
5+
6+
Move into tests/ directory
7+
8+
`cd tests/`
9+
10+
Run service dependencies:
11+
12+
`docker-compose up -d`
13+
14+
Install library dependencies:
15+
16+
`make install`
17+
18+
Run tests:
19+
20+
`make test`

0 commit comments

Comments
 (0)