|
23 | 23 | """ |
24 | 24 | import sys |
25 | 25 | from typing import TextIO |
26 | | -from threading import Thread, Lock |
| 26 | +from threading import Thread |
27 | 27 | from queue import Queue |
28 | 28 |
|
29 | 29 | import json |
30 | 30 | import yaml |
31 | 31 |
|
32 | 32 | from cli import options |
33 | | -from sonar import exceptions, errcodes, utilities |
| 33 | +from sonar import exceptions, errcodes, utilities, version |
34 | 34 | from sonar.util import types |
35 | 35 | import sonar.logging as log |
36 | 36 | from sonar import platform, rules, qualityprofiles, qualitygates, users, groups |
|
50 | 50 | options.WHAT_PORTFOLIOS, |
51 | 51 | ] |
52 | 52 |
|
53 | | -__JSON_KEY_PLATFORM = "platform" |
| 53 | +TOOL_NAME = "sonar-config" |
54 | 54 |
|
| 55 | +__JSON_KEY_PLATFORM = "platform" |
55 | 56 | __JSON_KEY_SETTINGS = "globalSettings" |
56 | 57 | __JSON_KEY_USERS = "users" |
57 | 58 | __JSON_KEY_GROUPS = "groups" |
|
74 | 75 | options.WHAT_PORTFOLIOS: __JSON_KEY_PORTFOLIOS, |
75 | 76 | } |
76 | 77 |
|
77 | | -_WRITE_LOCK = Lock() |
78 | | - |
79 | 78 |
|
80 | 79 | _EXPORT_CALLS = { |
81 | 80 | "platform": [__JSON_KEY_PLATFORM, platform.basics], |
@@ -123,8 +122,7 @@ def __parse_args(desc): |
123 | 122 | help="By default, sonar-config exports multi-valued settings as comma separated strings instead of arrays (if there is not comma in values). " |
124 | 123 | "Set this flag if you want to force export multi valued settings as arrays", |
125 | 124 | ) |
126 | | - args = options.parse_and_check(parser=parser, logger_name="sonar-config") |
127 | | - return args |
| 125 | + return options.parse_and_check(parser=parser, logger_name=TOOL_NAME) |
128 | 126 |
|
129 | 127 |
|
130 | 128 | def __write_export(config: dict[str, str], file: str, format: str) -> None: |
@@ -320,6 +318,7 @@ def main() -> None: |
320 | 318 | kwargs = utilities.convert_args(__parse_args("Extract SonarQube platform configuration")) |
321 | 319 | endpoint = platform.Platform(**kwargs) |
322 | 320 | endpoint.verify_connection() |
| 321 | + endpoint.set_user_agent(f"{TOOL_NAME} {version.PACKAGE_VERSION}") |
323 | 322 | except (options.ArgumentsError, exceptions.ObjectNotFound) as e: |
324 | 323 | utilities.exit_fatal(e.message, e.errcode) |
325 | 324 | if not kwargs[options.EXPORT] and not kwargs[options.IMPORT]: |
|
0 commit comments