Skip to content

Commit 5cd4cb9

Browse files
authored
Merge pull request #157 from bcgov/feature/kong3-compatibility
Support Kong 3 configuration (regex paths), warn and downgrade
2 parents a0e1302 + 10cf41b commit 5cd4cb9

File tree

26 files changed

+1896
-8
lines changed

26 files changed

+1896
-8
lines changed

.github/workflows/dev.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,16 @@ jobs:
6060
poetry run coverage run --branch -m pytest -s -v
6161
poetry run coverage xml
6262
63+
- name: Test coverage for Compatibility API
64+
run: |
65+
export PATH=/root/.local/bin:$PATH
66+
cd microservices/compatibilityApi
67+
poetry install --no-root
68+
poetry run coverage run --branch -m pytest -s -v
69+
poetry run coverage xml
70+
6371
- name: SonarCloud Scan
64-
uses: sonarsource/sonarcloud-github-action@master
72+
uses: sonarsource/sonarqube-scan-action@master
6573
env:
6674
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6775
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
@@ -164,3 +172,22 @@ jobs:
164172
tag_with_sha: false
165173
add_git_labels: true
166174
push: true
175+
176+
gwa-compatibility-api:
177+
needs: sonar-scan
178+
name: Docker Image for gwa-compatibility-api
179+
runs-on: ubuntu-latest
180+
steps:
181+
- uses: actions/checkout@v2
182+
- uses: docker/build-push-action@v1
183+
with:
184+
registry: docker.pkg.github.com
185+
username: $GITHUB_ACTOR
186+
password: ${{ secrets.GITHUB_TOKEN }}
187+
repository: bcgov/gwa-api/gwa-compatibility-api
188+
path: microservices/compatibilityApi
189+
dockerfile: microservices/compatibilityApi/Dockerfile
190+
tag_with_ref: true
191+
tag_with_sha: false
192+
add_git_labels: true
193+
push: true
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
# General Ignore
2+
#bin/
3+
.idea
4+
.DS_Store
5+
6+
# Golang Ignore
7+
8+
# Binaries for programs and plugins
9+
*.exe
10+
*.exe~
11+
*.dll
12+
*.so
13+
*.dylib
14+
15+
# Test binary, build with `go test -c`
16+
*.test
17+
18+
# Output of the go coverage tool, specifically when used with LiteIDE
19+
*.out
20+
21+
22+
# Node Ignore
23+
24+
# Logs
25+
logs
26+
*.log
27+
npm-debug.log*
28+
yarn-debug.log*
29+
yarn-error.log*
30+
31+
# Runtime data
32+
pids
33+
*.pid
34+
*.seed
35+
*.pid.lock
36+
37+
# Directory for instrumented libs generated by jscoverage/JSCover
38+
lib-cov
39+
40+
# Coverage directory used by tools like istanbul
41+
coverage
42+
43+
# nyc test coverage
44+
.nyc_output
45+
46+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
47+
.grunt
48+
49+
# Bower dependency directory (https://bower.io/)
50+
bower_components
51+
52+
# node-waf configuration
53+
.lock-wscript
54+
55+
# Compiled binary addons (https://nodejs.org/api/addons.html)
56+
build/Release
57+
58+
# Dependency directories
59+
node_modules/
60+
jspm_packages/
61+
62+
# TypeScript v1 declaration files
63+
typings/
64+
65+
# Optional npm cache directory
66+
.npm
67+
68+
# Optional eslint cache
69+
.eslintcache
70+
71+
# Optional REPL history
72+
.node_repl_history
73+
74+
# Output of 'npm pack'
75+
*.tgz
76+
77+
# Yarn Integrity file
78+
.yarn-integrity
79+
80+
# dotenv environment variables file
81+
.env
82+
83+
# parcel-bundler cache (https://parceljs.org/)
84+
.cache
85+
86+
# next.js build output
87+
.next
88+
89+
# nuxt.js build output
90+
.nuxt
91+
92+
# vuepress build output
93+
.vuepress/dist
94+
95+
# Serverless directories
96+
.serverless
97+
98+
99+
# Python Ignore
100+
101+
# Byte-compiled / optimized / DLL files
102+
__pycache__/
103+
*.py[cod]
104+
*$py.class
105+
106+
# C extensions
107+
*.so
108+
109+
# Distribution / packaging
110+
.Python
111+
build/
112+
develop-eggs/
113+
dist/
114+
downloads/
115+
eggs/
116+
.eggs/
117+
lib/
118+
lib64/
119+
parts/
120+
sdist/
121+
var/
122+
wheels/
123+
*.egg-info/
124+
.installed.cfg
125+
*.egg
126+
MANIFEST
127+
128+
# PyInstaller
129+
# Usually these files are written by a python script from a template
130+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
131+
*.manifest
132+
*.spec
133+
134+
# Installer logs
135+
pip-log.txt
136+
pip-delete-this-directory.txt
137+
138+
# Unit test / coverage reports
139+
htmlcov/
140+
.tox/
141+
.coverage
142+
.coverage.*
143+
.cache
144+
nosetests.xml
145+
coverage.xml
146+
*.cover
147+
.hypothesis/
148+
.pytest_cache/
149+
150+
# Translations
151+
*.mo
152+
*.pot
153+
154+
# Django stuff:
155+
*.log
156+
local_settings.py
157+
db.sqlite3
158+
159+
# Flask stuff:
160+
instance/
161+
.webassets-cache
162+
163+
# Scrapy stuff:
164+
.scrapy
165+
166+
# Sphinx documentation
167+
docs/_build/
168+
169+
# PyBuilder
170+
target/
171+
172+
# Jupyter Notebook
173+
.ipynb_checkpoints
174+
175+
# pyenv
176+
.python-version
177+
178+
# celery beat schedule file
179+
celerybeat-schedule
180+
181+
# SageMath parsed files
182+
*.sage.py
183+
184+
# Environments
185+
.env
186+
.venv
187+
env/
188+
venv/
189+
ENV/
190+
env.bak/
191+
venv.bak/
192+
193+
# Spyder project settings
194+
.spyderproject
195+
.spyproject
196+
197+
# Rope project settings
198+
.ropeproject
199+
200+
# mkdocs documentation
201+
/site
202+
203+
# mypy
204+
.mypy_cache/
205+
206+
config/default.json
207+
208+
LOCAL.md
209+
_tmp
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM python:3.12.9-alpine3.21
2+
3+
WORKDIR /app
4+
5+
RUN apk add build-base libffi-dev openssl curl
6+
7+
# Install deck
8+
RUN curl -sL https://github.com/kong/deck/releases/download/v1.35.0/deck_1.35.0_linux_amd64.tar.gz -o deck.tar.gz && \
9+
tar -xf deck.tar.gz -C /tmp && \
10+
mv /tmp/deck /usr/local/bin/ && \
11+
rm deck.tar.gz
12+
13+
RUN python -m pip install --upgrade pip
14+
15+
RUN cd /tmp && \
16+
curl -sSL https://install.python-poetry.org > get-poetry.py && \
17+
POETRY_HOME=/opt/poetry python get-poetry.py --version 1.8.2 && \
18+
cd /usr/local/bin && \
19+
ln -s /opt/poetry/bin/poetry && \
20+
poetry config virtualenvs.create false
21+
22+
COPY pyproject.toml /tmp/
23+
24+
COPY poetry.lock /tmp/
25+
26+
RUN cd /tmp && poetry install --no-root --no-dev
27+
28+
COPY . /app
29+
30+
RUN chmod +x /app/entrypoint.sh
31+
32+
EXPOSE 8080
33+
34+
ENTRYPOINT ["./entrypoint.sh"]
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# GWA Compatibility API
2+
3+
## Description
4+
5+
This API validates Kong Gateway configuration files.
6+
7+
## Getting Started
8+
9+
### Dependencies
10+
11+
- Docker
12+
- Python 3.12
13+
14+
### Installation
15+
16+
#### Poetry
17+
18+
```bash
19+
brew update
20+
brew install pyenv
21+
pyenv install 3.12
22+
pyenv global 3.12
23+
curl -sSL https://install.python-poetry.org | python3 -
24+
```
25+
26+
#### Requirements
27+
28+
```bash
29+
poetry env use 3.12 # (optional)
30+
poetry install
31+
```
32+
33+
#### Docker
34+
35+
```bash
36+
docker build --tag compatibilityapi .
37+
38+
docker run -ti --rm \
39+
-p 8080:8080 \
40+
-e LOG_LEVEL=DEBUG \
41+
compatibilityapi
42+
```
43+
44+
### Development
45+
46+
Locally running:
47+
48+
```sh
49+
poetry run uvicorn main:app --host 0.0.0.0 --port 8080 --reload
50+
```
51+
52+
Testing:
53+
54+
```sh
55+
poetry run coverage run --branch -m pytest -s
56+
poetry run coverage xml
57+
```
58+
59+
Test with a local file:
60+
61+
```sh
62+
curl -X POST http://localhost:8080/configs \
63+
-H "Content-Type: application/json" \
64+
-d "$(cat test.yaml | python3 -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin)))')"
65+
```
66+
67+
Test with json content:
68+
69+
```sh
70+
curl -X POST http://localhost:8080/configs \
71+
-H "Content-Type: application/json" \
72+
-d '{
73+
"services": [
74+
{
75+
"name": "example-service",
76+
"url": "http://example.com"
77+
}
78+
]
79+
}'
80+
```

0 commit comments

Comments
 (0)