*.local
local
+# Version files
src/osm_ngsa/_version.py
+osm_webhook_translator/src/osm_webhook_translator/_version.py
# limitations under the License.
#
+set -ex
+
rm -rf dist deb_dist osm*.tar.gz *.egg-info .eggs
-tox -e dist
+for p in "osm_webhook_translator"; do
+ rm -rf $p/dist $p/deb_dist $p/osm*.tar.gz $p/*.egg-info $p/.eggs
+done
+
+mkdir -p deb_dist
+mkdir -p osm_webhook_translator/deb_dist
+
+PACKAGES="
+dist_ng_sa
+dist_webhook_translator"
+
+TOX_ENV_LIST="$(echo $PACKAGES | sed "s/ /,/g")"
+
+tox -e $TOX_ENV_LIST
+
+# Copying packages
+# Webhook Translator
+cp osm_webhook_translator/deb_dist/python3-osm-webhook-translator_*.deb deb_dist/
+
--- /dev/null
+..
+ #######################################################################################
+ # Copyright ETSI Contributors and Others.
+ #
+ # Licensed under the Apache License, Version 2.0 (the "License");
+ # you may not use this file except in compliance with the License.
+ # You may obtain a copy of the License at
+ #
+ # http://www.apache.org/licenses/LICENSE-2.0
+ #
+ # Unless required by applicable law or agreed to in writing, software
+ # distributed under the License is distributed on an "AS IS" BASIS,
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ # implied.
+ # See the License for the specific language governing permissions and
+ # limitations under the License.
+ #######################################################################################
+
+==================
+webhook-translator
+==================
+
+webhook-translator is a component in the Service Assurance architecture for OSM.
+
+Its role is to receive alerts from entities such as Prometheus AlertManager or external systems, and to translate them to a format that can be consumed by Airflow DAGs. It basically receives HTTP POST messages and forwards them to an Airflow webhook
+
+The main characteristics are:
+
+* Lightweight: a very small number of lines of code does the work.
+* Stateless. It only translates HTTP requests. No state for those translations. When running as a Kubernetes deployment, native scaling is achieved by means of Kubernetes services.
+* Simple. Based on `FastAPI <https://fastapi.tiangolo.com/>`
+* Independent from the source of the alert. No maintenance is required to incorporate new alert sources.
+
--- /dev/null
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+stdeb
+setuptools-scm
+setuptools<60
--- /dev/null
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+packaging==23.0
+ # via setuptools-scm
+setuptools-scm==7.1.0
+ # via -r osm_webhook_translator/requirements-dist.in
+stdeb==0.10.0
+ # via -r osm_webhook_translator/requirements-dist.in
+tomli==2.0.1
+ # via setuptools-scm
+typing-extensions==4.5.0
+ # via setuptools-scm
+
+# The following packages are considered to be unsafe in a requirements file:
+setuptools==59.8.0
+ # via
+ # -r osm_webhook_translator/requirements-dist.in
+ # setuptools-scm
--- /dev/null
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+
+fastapi
+requests
+uvicorn
--- /dev/null
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+anyio==3.6.2
+ # via starlette
+certifi==2022.12.7
+ # via requests
+charset-normalizer==3.1.0
+ # via requests
+click==8.1.3
+ # via uvicorn
+fastapi==0.95.0
+ # via -r osm_webhook_translator/requirements.in
+h11==0.14.0
+ # via uvicorn
+idna==3.4
+ # via
+ # anyio
+ # requests
+pydantic==1.10.7
+ # via fastapi
+requests==2.28.2
+ # via -r osm_webhook_translator/requirements.in
+sniffio==1.3.0
+ # via anyio
+starlette==0.26.1
+ # via fastapi
+typing-extensions==4.5.0
+ # via
+ # pydantic
+ # starlette
+urllib3==1.26.15
+ # via requests
+uvicorn==0.21.1
+ # via -r osm_webhook_translator/requirements.in
--- /dev/null
+#!/usr/bin/env python3
+#
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import os
+
+from setuptools import find_namespace_packages, setup
+
+exec(open("src/osm_webhook_translator/_version.py").read())
+
+_name = "osm_webhook_translator"
+_description = "OSM Webhook Translator"
+with open(os.path.join(".", "README.rst")) as readme_file:
+ README = readme_file.read()
+
+setup(
+ name=_name,
+ description=_description,
+ long_description=README,
+ version=__version__, # noqa: F821
+ author="ETSI OSM",
+ author_email="osmsupport@etsi.org",
+ maintainer="ETSI OSM",
+ maintainer_email="osmsupport@etsi.org",
+ url="https://osm.etsi.org/gitweb/?p=osm/NG-SA.git;a=summary",
+ license="Apache 2.0",
+ package_dir={"": "src"},
+ packages=find_namespace_packages(where="src"),
+ include_package_data=True,
+)
--- /dev/null
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+from osm_webhook_translator._version import __version__ # noqa: F401
skip_install = true
commands =
black --check --diff src setup.py
+ black --check --diff osm_webhook_translator
#######################################################################################
sh -c 'rm -f nosetests.xml'
coverage erase
nose2 -C --coverage src -s src
- sh -c 'mv .coverage .coverage_mon'
+ sh -c 'mv .coverage .coverage_ngsa'
+ nose2 -C --coverage osm_webhook_translator -s osm_webhook_translator
+ sh -c 'mv .coverage .coverage_webhook_translator'
coverage report --omit='*tests*'
coverage html -d ./cover --omit='*tests*'
coverage xml -o coverage.xml --omit='*tests*'
flake8-import-order
commands =
flake8 src setup.py
+ flake8 osm_webhook_translator
#######################################################################################
skip_install = true
commands =
pylint -E src
+ pylint -E osm_webhook_translator
#######################################################################################
out=`echo $file | sed 's/.in/.txt/'` ; \
sed -i -e '1 e head -16 tox.ini' $out ;\
done"
+ bash -c "for file in osm_webhook_translator/requirements*.in ; do \
+ UNSAFE="" ; \
+ if [[ $file =~ 'dist' ]] ; then UNSAFE='--allow-unsafe' ; fi ; \
+ pip-compile -rU --no-header $UNSAFE $file ;\
+ out=`echo $file | sed 's/.in/.txt/'` ; \
+ sed -i -e '1 e head -16 tox.ini' $out ;\
+ done"
#######################################################################################
-[testenv:dist]
+[testenv:dist_ng_sa]
deps = {[testenv]deps}
-r{toxinidir}/requirements-dist.txt
-
-# In the commands, we copy the requirements.txt to be presented as a source file (.py)
-# so it gets included in the .deb package for others to consume
+allowlist_externals = sh
commands =
sh -c 'cp requirements.txt src/osm_ngsa/requirements.txt'
sh -c 'cp README.rst src/osm_ngsa/README.rst'
sh -c 'cd deb_dist/osm-ngsa*/ && dpkg-buildpackage -rfakeroot -uc -us'
sh -c 'rm src/osm_ngsa/requirements.txt'
sh -c 'rm src/osm_ngsa/README.rst'
+
+
+#######################################################################################
+[testenv:dist_webhook_translator]
+deps = -r{toxinidir}/osm_webhook_translator/requirements.txt
+ -r{toxinidir}/osm_webhook_translator/requirements-dist.txt
allowlist_externals = sh
+commands =
+ sh -c 'cp src/osm_ngsa/_version.py osm_webhook_translator/src/osm_webhook_translator/_version.py'
+ sh -c 'cd osm_webhook_translator && cp requirements.txt src/osm_webhook_translator/requirements.txt'
+ sh -c 'cd osm_webhook_translator && cp README.rst src/osm_webhook_translator/README.rst'
+ sh -c 'cd osm_webhook_translator && python3 setup.py --command-packages=stdeb.command sdist_dsc'
+ sh -c 'cd osm_webhook_translator/deb_dist/osm-webhook-translator*/ && dpkg-buildpackage -rfakeroot -uc -us'
+ sh -c 'rm osm_webhook_translator/src/osm_webhook_translator/requirements.txt'
+ sh -c 'rm osm_webhook_translator/src/osm_webhook_translator/README.rst'
#######################################################################################