Skip to content

Commit c0ff300

Browse files
authored
Prep sonar migration release 0.4 (#1401)
* Update what new with 0.4 release scope * Bump sonar-migration version to 0.4 * Fixes #1402 * Add test to verify portfolio key is are present * Add check for portfolios by reference * Add export of portfolios by reference * Fix test * Fixes #1386
1 parent d3710a5 commit c0ff300

File tree

9 files changed

+31
-12
lines changed

9 files changed

+31
-12
lines changed

migration/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ When sonar-migration complete successfully they return exit code 0. En case of f
108108

109109
# What's New - Release notes
110110

111+
## Version 0.4
112+
113+
- Robustness: Handle all types of HTTP errors including SSL errors, which were causing freezes
114+
- Added export of flat list of projects in each portfolio
115+
- Fix regression: Export of `platform` section is back
116+
- Added export of portfolios by reference
117+
111118
## Version 0.3
112119

113120
- Robustness: Handle `connectionError` errors in project extract threads

migration/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ if [ "$release" = "1" ]; then
6464
fi
6565

6666
if [ "$release_docker" = "1" ]; then
67-
docker buildx build --push --platform linux/amd64,linux/arm64 -t olivierkorach/sonar-migration:0.3 -t olivierkorach/sonar-migration:latest -f migration/release.Dockerfile $ROOTDIR
67+
docker buildx build --push --platform linux/amd64,linux/arm64 -t olivierkorach/sonar-migration:0.4 -t olivierkorach/sonar-migration:latest -f migration/release.Dockerfile $ROOTDIR
6868
fi

migration/release.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ COPY ./LICENSE .
3131
COPY ./sonar/audit sonar/audit
3232

3333
RUN pip install --upgrade pip \
34-
&& pip install sonar-migration==0.3 --force-reinstall
34+
&& pip install sonar-migration==0.4 --force-reinstall
3535

3636
USER ${USERNAME}
3737
WORKDIR /home/${USERNAME}

migration/what-is-new.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2+
# Version 0.4
3+
4+
- Robustness: Handle all types of HTTP errors including SSL errors, which were causing freezes
5+
- Added export of flat list of projects in each portfolio
6+
- Fix regression: Export of `platform` section is back
7+
- Added export of portfolios by reference
8+
19
# Version 0.3
210

311
- Robustness: Handle `connectionError` errors in project extract threads

sonar/platform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ def _audit_lta_latest(self) -> list[Problem]:
658658
if not v:
659659
return []
660660
# pylint: disable-next=E0606
661-
return [Problem(rule, self.url, ".".join(sq_vers), ".".join(v))]
661+
return [Problem(rule, self.url, ".".join([str(n) for n in sq_vers]), ".".join([str(n) for n in v]))]
662662

663663

664664
# --------------------- Static methods -----------------

sonar/portfolios.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ def __init__(self, endpoint: pf.Platform, name: str, key: str = None) -> None:
103103
self._tags = [] #: Portfolio tags when selection mode is TAGS
104104
self._description = None #: Portfolio description
105105
self._visibility = None #: Portfolio visibility
106-
self._ref_portfolios = {} #: Subportfolios
107106
self._sub_portfolios = {} #: Subportfolios
108107
self._applications = {} #: applications
109108
self._permissions = None #: Permissions
@@ -171,8 +170,7 @@ def reload_sub_portfolios(self) -> None:
171170
return
172171
self._sub_portfolios = {}
173172
for data in self._json["subViews"]:
174-
if data["qualifier"] == "SVW":
175-
self.load_sub_portfolio(data.copy())
173+
self.load_sub_portfolio(data.copy())
176174

177175
def load_selection_mode(self) -> None:
178176
"""Loads the portfolio selection mode"""
@@ -360,11 +358,13 @@ def to_json(self, export_settings: types.ConfigSettings) -> types.ObjectJsonRepr
360358
subp_key = subp_json.pop("key")
361359
json_data["portfolios"][subp_key] = subp_json
362360
mode = self.selection_mode().copy()
363-
if mode and "none" not in mode:
364-
json_data["projects"] = mode
361+
if mode:
362+
if "none" not in mode or export_settings.get("MODE", "") == "MIGRATION":
363+
json_data["projects"] = mode
364+
if export_settings.get("MODE", "") == "MIGRATION":
365+
json_data["projects"]["keys"] = self.get_project_list()
365366
json_data["applications"] = self._applications
366-
if export_settings.get("MODE", "") == "MIGRATION":
367-
json_data["projectsList"] = self.get_project_list()
367+
368368
return json_data
369369

370370
def export(self, export_settings: types.ConfigSettings) -> types.ObjectJsonRepr:
@@ -554,7 +554,6 @@ def is_toplevel(self) -> bool:
554554

555555
def is_parent_of(self, key: str) -> bool:
556556
"""Returns whether a portfolio is parent of another subportfolio (given by key)"""
557-
log.debug("SUBP = %s", str(list(self._sub_portfolios.keys())))
558557
return key in self._sub_portfolios
559558

560559
def is_subporfolio_of(self, key: str) -> bool:

sonar/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@
2525
"""
2626

2727
PACKAGE_VERSION = "3.5"
28-
MIGRATION_TOOL_VERSION = "0.3"
28+
MIGRATION_TOOL_VERSION = "0.4"

test/test_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ def test_config_inline_commas() -> None:
120120
# This is a list because there is a comma in one of the branches
121121
if util.SQ.version() >= (10, 0, 0):
122122
assert isinstance(json_config["portfolios"]["PORTFOLIO_MULTI_BRANCHES"]["projects"]["manual"]["BANKING-PORTAL"], list)
123+
assert json_config["portfolios"]["All"]["portfolios"]["Banking"]["byReference"]
123124
util.clean(util.JSON_FILE)
124125

125126

test/test_migration.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ def test_migration() -> None:
133133
assert json_config["projects"]["demo:gitlab-ci-maven"]["detectedCi"] == "Gitlab CI"
134134
assert json_config["projects"]["demo:github-actions-cli"]["detectedCi"] == "Github Actions"
135135

136+
for p in json_config["portfolios"].values():
137+
assert "projects" in p
138+
assert "keys" in p["projects"]
139+
136140
util.clean(util.JSON_FILE)
137141

138142

0 commit comments

Comments
 (0)