Skip to content

Commit

Permalink
Improvement on Sonarqube projects fetching (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyGis authored Dec 5, 2023
1 parent 31f9f18 commit d72e6ff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
7 changes: 7 additions & 0 deletions integrations/sonarqube/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- towncrier release notes start -->

# Port_Ocean 0.1.16 (2023-12-05)

### Bug Fixes

- Update startup code to skip initializing integration resources when organization_id is not specified for SonarCloud. (#16)


# Port_Ocean 0.1.15 (2023-12-05)

### Improvements
Expand Down
16 changes: 7 additions & 9 deletions integrations/sonarqube/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ def is_onpremise_deployment() -> bool:
return ocean.integration_config.get("sonar_url") != "https://sonarcloud.io"


def organization_key_missing_for_onpremise() -> bool:
return (
not ocean.integration_config.get("sonar_organization_id")
and is_onpremise_deployment()
)


@ocean.on_resync(ObjectKind.PROJECTS)
async def on_project_resync(kind: str) -> list[dict[str, Any]]:
logger.info(f"Listing Sonarqube resource: {kind}")
Expand Down Expand Up @@ -94,10 +87,15 @@ async def handle_sonarqube_webhook(webhook_data: dict[str, Any]) -> None:

@ocean.on_start()
async def on_start() -> None:
if not ocean.integration_config.get("sonar_organization_id"):
if not is_onpremise_deployment():
raise ValueError(
"Organization ID is required for SonarCloud. Please specify a valid sonarOrganizationId"
)
logger.warning("Organization key is missing for an on-premise Sonarqube setup")

sonar_client = init_sonar_client()
sonar_client.sanity_check()
if organization_key_missing_for_onpremise():
logger.warning("Organization key is missing for an on-premise Sonarqube setup")

if ocean.event_listener_type == "ONCE":
logger.info("Skipping webhook creation because the event listener is ONCE")
Expand Down
2 changes: 1 addition & 1 deletion integrations/sonarqube/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sonarqube"
version = "0.1.15"
version = "0.1.16"
description = "SonarQube projects and code quality analysis integration"
authors = ["Port Team <[email protected]>"]

Expand Down

0 comments on commit d72e6ff

Please sign in to comment.