Skip to content

Commit

Permalink
[Integration][GitLab] Add project labels (#1245)
Browse files Browse the repository at this point in the history
# Description

What - Added project labels to the project kind response

Why -

How - Enriched the project response with `__labels` object

## Type of change

Please leave one option from the following and delete the rest:

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] New Integration (non-breaking change which adds a new integration)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] Non-breaking change (fix of existing functionality that will not
change current behavior)
- [ ] Documentation (added/updated documentation)

<h4> All tests should be run against the port production
environment(using a testing org). </h4>

### Core testing checklist

- [ ] Integration able to create all default resources from scratch
- [ ] Resync finishes successfully
- [ ] Resync able to create entities
- [ ] Resync able to update entities
- [ ] Resync able to detect and delete entities
- [ ] Scheduled resync able to abort existing resync and start a new one
- [ ] Tested with at least 2 integrations from scratch
- [ ] Tested with Kafka and Polling event listeners
- [ ] Tested deletion of entities that don't pass the selector


### Integration testing checklist

- [ ] Integration able to create all default resources from scratch
- [ ] Resync able to create entities
- [ ] Resync able to update entities
- [ ] Resync able to detect and delete entities
- [ ] Resync finishes successfully
- [ ] If new resource kind is added or updated in the integration, add
example raw data, mapping and expected result to the `examples` folder
in the integration directory.
- [ ] If resource kind is updated, run the integration with the example
data and check if the expected result is achieved
- [ ] If new resource kind is added or updated, validate that
live-events for that resource are working as expected
- [ ] Docs PR link [here](#)

### Preflight checklist

- [ ] Handled rate limiting
- [ ] Handled pagination
- [ ] Implemented the code in async
- [ ] Support Multi account

## Screenshots

Include screenshots from your environment showing how the resources of
the integration will look.

## API Documentation

Provide links to the API documentation used for this integration.
  • Loading branch information
PeyGis authored Dec 17, 2024
1 parent b5566a9 commit 7c20230
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
8 changes: 8 additions & 0 deletions integrations/gitlab/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

<!-- towncrier release notes start -->

0.2.5 (2024-12-16)
==================

### Improvements

- Added labels as an extra property to the project kind response


0.2.4 (2024-12-15)
==================

Expand Down
13 changes: 13 additions & 0 deletions integrations/gitlab/gitlab_integration/gitlab_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,18 @@ async def get_all_projects(self) -> typing.AsyncIterator[List[Project]]:
else:
logger.info("No valid projects found for the token in the current page")

@classmethod
async def async_project_labels_wrapper(cls, project: Project) -> dict[str, Any]:
try:
labels = await anyio.to_thread.run_sync(project.labels.list)
serialized_labels = [label.attributes for label in labels]
return {"__labels": serialized_labels}
except Exception as e:
logger.warning(
f"Failed to get labels for project={project.path_with_namespace}. error={e}"
)
return {"__labels": []}

@classmethod
async def async_project_language_wrapper(cls, project: Project) -> dict[str, Any]:
try:
Expand All @@ -562,6 +574,7 @@ async def async_project_language_wrapper(cls, project: Project) -> dict[str, Any
async def enrich_project_with_extras(cls, project: Project) -> Project:
tasks = [
cls.async_project_language_wrapper(project),
cls.async_project_labels_wrapper(project),
]
tasks_extras = await asyncio.gather(*tasks)
for task_extras in tasks_extras:
Expand Down
2 changes: 1 addition & 1 deletion integrations/gitlab/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "gitlab"
version = "0.2.4"
version = "0.2.5"
description = "Gitlab integration for Port using Port-Ocean Framework"
authors = ["Yair Siman-Tov <[email protected]>"]

Expand Down

0 comments on commit 7c20230

Please sign in to comment.