Skip to content

Commit 8da2ff6

Browse files
[PR #11179/ebb53416 backport][stable-12] mas: Fix parsing on mas 3.0.0+. (#11210)
mas: Fix parsing on mas 3.0.0+. (#11179) * mas: Fix parsing on mas 3.0.0+. `mas` changed the formatting of `mas list` with version 3, which breaks the parsing this module uses to determine which apps are installed. In particular, app IDs may now have leading space, which causes us to split the string too early. * Changelog fragment. * Better format examples and changlog fragment. (cherry picked from commit ebb5341) Co-authored-by: Michael Galati <[email protected]>
1 parent 9c57bb4 commit 8da2ff6

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
bugfixes:
3+
- mas - parse CLI output correctly when listing installed apps with mas 3.0.0+ (https://github.com/ansible-collections/community.general/pull/11179).

plugins/modules/mas.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,14 @@ def get_current_state(self, command):
195195
rows = []
196196
apps = []
197197
for r in rows:
198-
# Format: "123456789 App Name"
199-
r = r.split(" ", 1)
198+
# mas 2.3.0 and older:
199+
# 123456789 App Name (version)
200+
# 4567890 App Name Longer (version)
201+
#
202+
# mas 3.0.0 and newer:
203+
# 123456789 App Name (version)
204+
# 4567890 App Name Longer (version)
205+
r = r.strip().split(" ", 1)
200206
if len(r) == 2:
201207
apps.append(int(r[0]))
202208

0 commit comments

Comments
 (0)