Skip to content
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4a39560
first adjustments for cloudevent support
linakrisztian Apr 17, 2025
a99d5ca
first version for cloudevent endpoint + update setup
linakrisztian Apr 22, 2025
00c5bcb
add test files
linakrisztian Apr 23, 2025
ccca3b6
setup as standalone app
linakrisztian Apr 23, 2025
25b6374
update cloudevent processing: receiver url within config + added desc…
linakrisztian Apr 23, 2025
b493177
update setup: only standalone
linakrisztian Apr 24, 2025
544cd7d
fix standalone setup
linakrisztian Apr 24, 2025
563af7d
remove not needed files
linakrisztian Apr 24, 2025
5d36068
Update __init__.py
linakrisztian Jun 2, 2025
71280db
Update __init__.py
linakrisztian Jun 2, 2025
5f7587b
remove not needed parts
linakrisztian Jun 2, 2025
9383695
Merge branch 'cloudevent_support' of github.com:actinia-org/actinia-c…
linakrisztian Jun 2, 2025
93f81e8
black linting
linakrisztian Jun 2, 2025
fc61eab
linting flake8
linakrisztian Jun 2, 2025
f108f1f
lint black
linakrisztian Jun 2, 2025
72f17fd
lint hadolint
linakrisztian Jun 2, 2025
f83becd
remove exmplae plugin tests
linakrisztian Jun 2, 2025
eea12c7
linting_pylint
linakrisztian Jun 2, 2025
6d54e3b
lint black
linakrisztian Jun 2, 2025
527a1fc
linting
linakrisztian Jun 2, 2025
24018e7
update readme
linakrisztian Jun 2, 2025
35fcc9f
add pylint exceptions
linakrisztian Jun 2, 2025
991b904
fix pytlint exception
linakrisztian Jun 2, 2025
9444d62
pylint
linakrisztian Jun 2, 2025
20978ba
pylint
linakrisztian Jun 2, 2025
e290192
fix hadolint exceptions
linakrisztian Jun 2, 2025
2221209
ruff
linakrisztian Jun 2, 2025
f1e3d44
ruff
linakrisztian Jun 2, 2025
1373bf3
ruff
linakrisztian Jun 2, 2025
f6e3e79
black
linakrisztian Jun 2, 2025
5e03ba7
Update src/actinia_cloudevent_plugin/resources/config.py
linakrisztian Jun 2, 2025
532b352
black
linakrisztian Jun 2, 2025
3c8e69a
linting
linakrisztian Jun 2, 2025
ba5392a
update docker setup
linakrisztian Jun 2, 2025
d09680c
update documentation
linakrisztian Jun 2, 2025
f63f33d
update authors
linakrisztian Jun 2, 2025
1ad5dd5
Update response_models.py
linakrisztian Jun 2, 2025
1950fb5
update test setup
linakrisztian Jun 2, 2025
aef15f2
Merge branch 'cloudevent_support' of github.com:actinia-org/actinia-c…
linakrisztian Jun 2, 2025
3e1d18e
add integrationtest
linakrisztian Jun 3, 2025
1c1a867
update reademe for tests + add examples + remove unittest
linakrisztian Jun 3, 2025
3551bb2
json linting
linakrisztian Jun 3, 2025
74a257d
fix prod setup + improve error message
linakrisztian Jun 3, 2025
a284be8
update readme/comments
linakrisztian Jun 3, 2025
f9ae552
stop server within tests
linakrisztian Jun 3, 2025
b4adb25
Update src/actinia_cloudevent_plugin/resources/config.py
linakrisztian Jun 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@

# F401 'module' imported but unused
# E501 line too long (83 > 79 characters)
# F841 local variable 'pc' is assigned to but never used

exclude = .git,.pycache,build,.eggs

per-file-ignores =
./tests/cloudevent_receiver_server.py: E501
# remove when implemented:
./src/actinia_cloudevent_plugin/api/cloudevent.py: E501
./src/actinia_cloudevent_plugin/core/processing.py: F841, E501
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ docker/valkey_data/dump.rdb
.pylintrc_allowed_to_fail
ruff-github-workflows.toml
ruff-merged.toml

# Development env
config/*.cfg
55 changes: 55 additions & 0 deletions .pylintrc_allowed_to_fail
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# For documentation about this config, see
# https://pylint.readthedocs.io/en/stable/user_guide/configuration/all-options.html (as of writing, version 2.17.4)

[MAIN]

exit-zero=yes

jobs=0 # Default: 1

load-plugins=
pylint.extensions.broad_try_clause

recursive=yes # Default: False

# score=no # Default: True

[BROAD_TRY_CLAUSE]
max-try-statements=4 # Default: 1

[FORMAT]
max-line-length=80 # Default: 100
max-module-lines=800 # Default: 1000
ignore-long-lines=.*COPYRIGHT:.* |# . description:.*|\s*(# )?.*http.:\/\/\S+?|# %%*

[MESSAGES CONTROL]
# C0301: Line too long
# C0103: Function name doesn't conform to snake_case naming style
disable=C0301
disable=C0103

[VARIABLES]
additional-builtins=_ # Default: ()


; [DESIGN]

; # Maximum number of arguments for function / method.
; # Default: 5
; max-args=9

; # Maximum number of attributes for a class (see R0902).
; # Default: 7
; max-attributes=11

; # Maximum number of branch for function / method body.
; # Default: 12
; max-branches=15

; # Maximum number of locals for function / method body.
; # Default: 15
; max-locals=19

; # Maximum number of return / yield for function / method body.
; # Default: 6
; max-returns=11
75 changes: 43 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,74 @@
# actinia-cloudevent-plugin

This is an plugin for [actinia-core](https://github.com/mundialis/actinia_core) which adds cloudevent endpoints to actinia-core.
This is a plugin for [actinia-core](https://github.com/mundialis/actinia_core) which adds cloudevent endpoints and runs as standalone app.

You can run actinia-cloudevent-plugin as an actinia-core plugin.
## Installation and Setup

## Installation
Use docker-compose for installation:
```bash
docker compose -f docker/docker-compose.yml build
docker compose -f docker/docker-compose.yml up -d
docker compose -f docker/docker-compose.yml run --rm --service-ports --entrypoint sh actinia-cloudevent
# within docker
# TODO: FIX
# gunicorn.errors.HaltServer: <HaltServer 'App failed to load.' 4>
gunicorn -b 0.0.0.0:5000 -w 8 --access-logfile=- -k gthread actinia_cloudevent_plugin.main:flask_app
```

### DEV setup
```bash
docker compose -f docker/docker-compose-dev.yml build
docker compose -f docker/docker-compose-dev.yml run --rm --service-ports --entrypoint sh actinia-cloudevent
# within docker:
# install the plugin
pip3 install .
# start flask app with actinia-cloudevent-plugin
python3 -m actinia_cloudevent_plugin.main
```

### Installation hints
* If you get an error like: `ERROR: for docker_kvdb_1 Cannot start service valkey: network xxx not found` you can try the following:
```bash
docker compose -f docker/docker-compose.yml down
docker compose -f docker/docker-compose-dev.yml down
# remove all custom networks not used by a container
docker network prune
docker compose -f docker/docker-compose.yml up -d
docker compose -f docker/docker-compose-dev.yml up -d
```

### Requesting helloworld endpoint
You can test the plugin and request the `/helloworld` endpoint, e.g. with:
```bash
curl -u actinia-gdi:actinia-gdi -X GET http://localhost:8088/api/v3/helloworld | jq
## Configuration

curl -u actinia-gdi:actinia-gdi -H 'accept: application/json' -H 'Content-Type: application/json' -X POST http://localhost:8088/api/v3/helloworld -d '{"name": "test"}' | jq
```
- the URL of the cloudevent receiver is defined within [config/mount/sample.ini](config/mount/sample.ini): `[EVENTRECEIVER]` (Default value defined within [src/actinia_cloudevent_plugin/resources/config.py](src/actinia_cloudevent_plugin/resources/config.py))

## Requesting endpoint

## DEV setup
For a DEV setup you can use the docker/docker-compose.yml:
**Note**: Assuming cloudevent-plugin is running as described in previous DEV setup.

You can test the plugin and request the `/` endpoint, e.g. with:
```bash
docker compose -f docker/docker-compose.yml build
docker compose -f docker/docker-compose.yml run --rm --service-ports --entrypoint sh actinia
# Start server for receiving of cloudevents (which are returned as response)
# NOTE: as defined within config/mount/sample.ini: [EVENTRECEIVER]
python3 tests/cloudevent_receiver_server.py

# install the plugin
(cd /src/actinia-cloudevent-plugin && python3 setup.py install)
# start actinia-core with your plugin
sh /src/start.sh
# gunicorn -b 0.0.0.0:8088 -w 1 --access-logfile=- -k gthread actinia_core.main:flask_app
# In another terminal
JSON=tests/cloudevent_example.json
curl -X POST -H 'Content-Type: application/json' --data @$JSON localhost:5000/api/v1/ | jq
```

### Hints
## Hints

* If you have no `.git` folder in the plugin folder, you need to set the
`SETUPTOOLS_SCM_PRETEND_VERSION` before installing the plugin:
```bash
export SETUPTOOLS_SCM_PRETEND_VERSION=0.0
```
Otherwise you will get an error like this
`LookupError: setuptools-scm was unable to detect version for '/src/actinia-cloudevent-plugin'.`.
```bash
export SETUPTOOLS_SCM_PRETEND_VERSION=0.0
```
Otherwise you will get an error like this `LookupError: setuptools-scm was unable to detect version for '/src/actinia-cloudevent-plugin'.`.

* If you make changes in code and nothing changes you can try to uninstall the plugin:
```bash
pip3 uninstall actinia-cloudevent-plugin.wsgi -y
rm -rf /usr/lib/python3.8/site-packages/actinia_cloudevent_plugin.wsgi-*.egg
```
```bash
pip3 uninstall actinia-cloudevent-plugin.wsgi -y
rm -rf /usr/lib/python3.8/site-packages/actinia_cloudevent_plugin.wsgi-*.egg
```

### Running tests
## Running tests - **TODO**
You can run the tests in the actinia test docker:

```bash
Expand Down
7 changes: 7 additions & 0 deletions config/mount/sample.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[EVENTRECEIVER]
url = http://localhost:3000/

[LOGCONFIG]
logfile = actinia-cloudevent-plugin.log
level = DEBUG
type = json
24 changes: 0 additions & 24 deletions docker/Dockerfile

This file was deleted.

23 changes: 23 additions & 0 deletions docker/actinia-cloudevent-plugin-alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM alpine:3.21

# python3 + pip3
# hadolint ignore=DL3018
RUN apk update; \
apk add --no-cache python3 python3-dev
ENV PATH="/opt/venv/bin:$PATH"
RUN /usr/bin/python -m venv --system-site-packages --without-pip /opt/venv
# hadolint ignore=DL3013
RUN python -m ensurepip && pip3 install --no-cache-dir --upgrade pip pep517 wheel

# gunicorn
# hadolint ignore=DL3013
RUN pip3 install --no-cache-dir gunicorn

COPY . /src/actinia-cloudevent-plugin/

# SETUPTOOLS_SCM_PRETEND_VERSION is only needed if in the plugin folder is no
# .git folder
ENV SETUPTOOLS_SCM_PRETEND_VERSION=0.0

WORKDIR /src/actinia-cloudevent-plugin
RUN pip3 install --no-cache-dir -e .
19 changes: 19 additions & 0 deletions docker/actinia-cloudevent-plugin-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM alpine:3.21

# python3 + pip3
# hadolint ignore=DL3018
RUN apk update; \
apk add --no-cache python3 python3-dev
ENV PATH="/opt/venv/bin:$PATH"
RUN /usr/bin/python -m venv --system-site-packages --without-pip /opt/venv
# hadolint ignore=DL3013
RUN python -m ensurepip && pip3 install --no-cache-dir --upgrade pip pep517 wheel

COPY . /src/actinia-cloudevent-plugin/

# SETUPTOOLS_SCM_PRETEND_VERSION is only needed if in the plugin folder is no
# .git folder
ENV SETUPTOOLS_SCM_PRETEND_VERSION=0.0

WORKDIR /src/actinia-cloudevent-plugin
RUN pip3 install --no-cache-dir -e .
2 changes: 1 addition & 1 deletion docker/actinia-cloudevent-plugin-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ ENV DEFAULT_CONFIG_PATH=/etc/default/actinia-cloudevent-plugin-test
# DL3018: Pin versions in apk add
# hadolint ignore=DL3018
RUN apk add --no-cache valkey && \
pip3 install --no-cache-dir iniconfig==2.0.0 colorlog==6.8.2 pwgen==0.8.2.post0 pytest==8.3.5 pytest-cov==6.0.0
pip3 install --no-cache-dir pwgen==0.8.2.post0 pytest==8.3.5 pytest-cov==6.0.0

# COPY docker/actinia-cloudevent-plugin-test/start.sh /src/start.sh

Expand Down
2 changes: 1 addition & 1 deletion docker/actinia.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins = ["actinia_cloudevent_plugin"]
force_https_urls = False

[KVDB]
kvdb_server_url = valkey
kvdb_server_url = localhost
kvdb_server_pw = pass
kvdb_resource_expire_time = 864001
worker_logfile = /actinia_core/workspace/tmp/actinia_worker.log
Expand Down
14 changes: 14 additions & 0 deletions docker/docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
services:

actinia-cloudevent:
build:
context: ..
dockerfile: docker/actinia-cloudevent-plugin-dev/Dockerfile
volumes:
- ..:/src/actinia-cloudevent-plugin/.
cap_add:
- SYS_PTRACE
ports:
- "5000:5000"
network_mode: "host"

38 changes: 4 additions & 34 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,12 @@
version: "3"
services:

actinia:
actinia-cloudevent:
build:
context: ..
dockerfile: docker/Dockerfile
volumes:
- ..:/src/actinia-cloudevent-plugin/.
ports:
- "8088:8088"
depends_on:
- valkey
dockerfile: docker/actinia-cloudevent-plugin-alpine/Dockerfile
cap_add:
- SYS_PTRACE
networks:
- actinia

valkey:
image: valkey/valkey:8.1-alpine
volumes:
- ./valkey_data:/data
environment:
- VALKEY_PASS_FILE=/data/config/.valkey
command: [
"sh", "-c",
'
docker-entrypoint.sh
"/data/config/valkey.conf"
--requirepass "$$(cat $$VALKEY_PASS_FILE)"
'
]
ports:
- "6379:6379"
networks:
- actinia
- "5000:5000"
network_mode: "host"

networks:
actinia:
ipam:
config:
- subnet: 172.18.0.0/16
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ keywords = [
"example",
]
dependencies = [
"colorlog>=4.2.1",
"xmltodict",
"Flask",
"Flask-Cors>=3.0.3",
"flask-restful-swagger-2>=0.35",
"colorlog>=3.1.4",
"python-json-logger",
"requests>=2.20.0",
"cloudevents",
]

[project.optional-dependencies]
Expand Down
17 changes: 0 additions & 17 deletions requirements.txt

This file was deleted.

Loading
Loading