-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The System engineering toolchain team for Digitale Schiene is offering several model modifiers and model derivative jobs. Example for model modifiers are: - ID injection bot (inject IDs into model elements) Example for model derivates: - Model complexity badge generation - Diagram cache generation - Automatic documentation generation Synchronisation between TeamForCapella and Git is also considered as job, somewhere in between. Currently, all "jobs" are run in the Gitlab CI. There is no UI for the setup of these jobs. Each job repository provides a Gitlab CI templates, which can be easily integrated in project repositories. However, this approach is not intuitive for external people, leading to operation support effort for operation teams, which have to take care of the creation and updates of jobs. Another disadavantage of the current approach is the Gitlab dependency. Not all environments have a Gitlab instance available. Getting it running on other platforms is even more effort. This commit adds a plugin/job store to the Capella Colloration Manager. A plugin/job is still developed in a Git repository. Plugins have to define a `mbse-works-plugin.yml`, providing metadata, input, output, trigger and job information. The JSON schema can be fetched via `GET /api/v1.0/plugins-schema` (backend). A human-readable documentation is available via `/docs/plugin-schema` (backend). With this information, registered plugins can be easily integrated into projects. The integration should be intuitive for project leads. The steps are: - Create a new pipeline - Select a supported plugin from the store - Configure the plugin: Supported types for the beginning are: - git (Select a linked git model from the project, so that the job can access the Git repository information) - t4c (Select a linked T4C repository/project from the project). The job gets the connection information + a session token. - yml (Most flexible option, the yml configuration file is mounted into the job container, validation via yml schema) - environment (Key/value pairs, which are used as environment variable for the job) - Confirm the creation As part of this commit, there are only two options: - Run the pipeline manually - Run it as 3am during the night. Co-authored-by: ewuerger <[email protected]> Co-authored-by: Paula-Kli <[email protected]>
- Loading branch information
1 parent
5dbbe56
commit 576fb32
Showing
92 changed files
with
3,807 additions
and
2,384 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
34 changes: 34 additions & 0 deletions
34
backend/capellacollab/alembic/versions/e3f1006f6b49_add_plugins_table.py
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,34 @@ | ||
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
"""Add plugins table | ||
Revision ID: e3f1006f6b49 | ||
Revises: d0cbf2813066 | ||
Create Date: 2023-05-26 11:56:13.928534 | ||
""" | ||
import sqlalchemy as sa | ||
from alembic import op | ||
from sqlalchemy.dialects import postgresql | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "e3f1006f6b49" | ||
down_revision = "ac0e6e0f77ee" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
op.create_table( | ||
"plugins", | ||
sa.Column("id", sa.Integer(), nullable=False), | ||
sa.Column("username", sa.String(), nullable=True), | ||
sa.Column("password", sa.String(), nullable=True), | ||
sa.Column("remote", sa.String(), nullable=False), | ||
sa.Column( | ||
"content", postgresql.JSONB(astext_type=sa.Text()), nullable=True | ||
), | ||
sa.PrimaryKeyConstraint("id"), | ||
) | ||
op.create_index(op.f("ix_plugins_id"), "plugins", ["id"], unique=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
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
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
File renamed without changes.
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,62 @@ | ||
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
from collections import abc | ||
|
||
import sqlalchemy as sa | ||
from sqlalchemy import orm | ||
|
||
from . import models | ||
|
||
|
||
def get_plugins(db: orm.Session) -> abc.Sequence[models.DatabasePlugin]: | ||
return db.execute(sa.select(models.DatabasePlugin)).scalars().all() | ||
|
||
|
||
def get_plugin_by_id( | ||
db: orm.Session, plugin_id: int | ||
) -> models.DatabasePlugin | None: | ||
return db.execute( | ||
sa.select(models.DatabasePlugin).where( | ||
models.DatabasePlugin.id == plugin_id | ||
) | ||
).scalar_one_or_none() | ||
|
||
|
||
def create_plugin( | ||
db: orm.Session, | ||
remote: str, | ||
username: str | None, | ||
password: str | None, | ||
content: dict | None, | ||
) -> models.DatabasePlugin: | ||
plugin = models.DatabasePlugin( | ||
remote=remote, username=username, password=password, content=content | ||
) | ||
db.add(plugin) | ||
db.commit() | ||
return plugin | ||
|
||
|
||
def update_plugin( | ||
db: orm.Session, | ||
plugin: models.DatabasePlugin, | ||
patch_plugin: models.PatchPlugin, | ||
content: str, | ||
) -> models.DatabasePlugin: | ||
if patch_plugin.username: | ||
plugin.username = patch_plugin.username | ||
if patch_plugin.password: | ||
plugin.password = patch_plugin.password | ||
if patch_plugin.remote: | ||
plugin.remote = patch_plugin.remote | ||
if content: | ||
plugin.content = content | ||
db.commit() | ||
return plugin | ||
|
||
|
||
def delete_plugin(db: orm.Session, plugin: models.DatabasePlugin) -> None: | ||
db.delete(plugin) | ||
db.commit() |
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,23 @@ | ||
# SPDX-FileCopyrightText: Copyright DB Netz AG and the capella-collab-manager contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
from fastapi import Depends, HTTPException | ||
from sqlalchemy.orm import Session | ||
|
||
from capellacollab.core import database | ||
|
||
from . import crud, models | ||
|
||
|
||
def get_existing_plugin( | ||
plugin_id: int, db: Session = Depends(database.get_db) | ||
) -> models.DatabasePlugin: | ||
if plugin := crud.get_plugin_by_id(db, plugin_id): | ||
return plugin | ||
|
||
raise HTTPException( | ||
404, | ||
{ | ||
"reason": f"The plugin with the id {plugin_id} was not found.", | ||
}, | ||
) |
Oops, something went wrong.