Skip to content

Commit 196500e

Browse files
committed
Single signature for import_config()
1 parent 7062e0b commit 196500e

File tree

7 files changed

+18
-6
lines changed

7 files changed

+18
-6
lines changed

sonar/devops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ def export(endpoint: platform.Platform, export_settings: types.ConfigSettings) -
255255
return json_data
256256

257257

258-
def import_config(endpoint: platform.Platform, config_data: types.ObjectJsonRepr) -> None:
258+
def import_config(endpoint: platform.Platform, config_data: types.ObjectJsonRepr, key_list: types.KeyList = None) -> None:
259259
"""Imports DevOps platform configuration in SonarQube/Cloud"""
260260
devops_settings = config_data.get("devopsIntegration", {})
261261
if len(devops_settings) == 0:

sonar/groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def create_or_update(endpoint: pf.Platform, name: str, description: str) -> Grou
337337
return Group.create(endpoint, name, description)
338338

339339

340-
def import_config(endpoint: pf.Platform, config_data: types.ObjectJsonRepr) -> None:
340+
def import_config(endpoint: pf.Platform, config_data: types.ObjectJsonRepr, key_list: types.KeyList = None) -> None:
341341
"""Imports a group configuration in SonarQube
342342
343343
:param Platform endpoint: reference to the SonarQube platform

sonar/platform.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,17 @@ def latest() -> tuple[int, int, int]:
819819
return __lta_and_latest()[1]
820820

821821

822+
def import_config(endpoint: Platform, config_data: types.ObjectJsonRepr, key_list: types.KeyList = None) -> None:
823+
"""Imports a configuration in SonarQube
824+
825+
:param Platform endpoint: reference to the SonarQube platform
826+
:param ObjectJsonRepr config_data: the configuration to import
827+
:param KeyList key_list: List of project keys to be considered for the import, defaults to None (all projects)
828+
:return: Nothing
829+
"""
830+
endpoint.import_config(config_data)
831+
832+
822833
def _check_for_retry(response: requests.models.Response) -> tuple[bool, str]:
823834
"""Verifies if a response had a 301 Moved permanently and if so provide the new location"""
824835
if len(response.history) > 0 and response.history[0].status_code == HTTPStatus.MOVED_PERMANENTLY:

sonar/qualitygates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def export(endpoint: pf.Platform, export_settings: types.ConfigSettings) -> type
389389
return {k: qg.to_json(export_settings) for k, qg in sorted(get_list(endpoint).items())}
390390

391391

392-
def import_config(endpoint: pf.Platform, config_data: types.ObjectJsonRepr) -> bool:
392+
def import_config(endpoint: pf.Platform, config_data: types.ObjectJsonRepr, key_list: types.KeyList = None) -> bool:
393393
"""Imports quality gates in a SonarQube platform, fom sonar-config data
394394
Quality gates already existing are updates with the provided configuration
395395

sonar/qualityprofiles.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ def __import_thread(queue: Queue) -> None:
647647
queue.task_done()
648648

649649

650-
def import_config(endpoint: pf.Platform, config_data: types.ObjectJsonRepr, threads: int = 8) -> None:
650+
def import_config(endpoint: pf.Platform, config_data: types.ObjectJsonRepr, key_list: types.KeyList = None) -> None:
651651
"""Imports a configuration in SonarQube
652652
653653
:param Platform endpoint: reference to the SonarQube platform
@@ -656,6 +656,7 @@ def import_config(endpoint: pf.Platform, config_data: types.ObjectJsonRepr, thre
656656
:type threads: int
657657
:return: Nothing
658658
"""
659+
threads = 8
659660
if "qualityProfiles" not in config_data:
660661
log.info("No quality profiles to import")
661662
return

sonar/rules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def export(
307307
return export_needed(endpoint, instantiated, extended, export_settings["FULL_EXPORT"])
308308

309309

310-
def import_config(endpoint: platform.Platform, config_data: types.ObjectJsonRepr) -> bool:
310+
def import_config(endpoint: platform.Platform, config_data: types.ObjectJsonRepr, key_list: types.KeyList = None) -> bool:
311311
"""Imports a sonar-config configuration"""
312312
if "rules" not in config_data:
313313
log.info("No customized rules (custom tags, extended description) to import")

sonar/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ def get_login_from_name(endpoint: pf.Platform, name: str) -> Union[str, None]:
455455
return list(u_list.keys()).pop(0)
456456

457457

458-
def import_config(endpoint: pf.Platform, config_data: types.ObjectJsonRepr) -> None:
458+
def import_config(endpoint: pf.Platform, config_data: types.ObjectJsonRepr, key_list: types.KeyList = None) -> None:
459459
"""Imports in SonarQube a complete users configuration described from a sonar-config JSON
460460
461461
:param Platform endpoint: reference to the SonarQube platform

0 commit comments

Comments
 (0)