Skip to content

Commit 9cabd11

Browse files
committed
Adapt SwapConfiguration to the declarative SubConfig summary
SubConfig now requires a NAME and summary(level) returning a list, and ZramConfiguration.summary() reports the disabled state, so the swap summary lists its own zram and swap file entries. The output is the same as before under the "Swap" label. The config round-trip test now compares the whole config, so the test fixture uses the swap format that gets written back.
1 parent a8e78a2 commit 9cabd11

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎archinstall/lib/models/application.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ class SwapConfiguration(SubConfig):
255255
zram: ZramConfiguration = ZramConfiguration(enabled=True)
256256
swapfile: bool = False
257257

258+
NAME: str = tr('Swap')
259+
258260
@classmethod
259261
def parse_arg(cls, arg: bool | dict[str, Any]) -> Self:
260262
# the option used to hold the zram configuration on its own, so a bare bool
@@ -278,13 +280,17 @@ def json(self) -> dict[str, Any]:
278280
}
279281

280282
@override
281-
def summary(self) -> list[str] | None:
282-
out = self.zram.summary() or []
283+
def summary(self, _level: SummaryLevel = SummaryLevel.BASIC) -> list[str]:
284+
out: list[str] = []
285+
286+
if self.zram.enabled:
287+
out.append(tr('Zram enabled'))
288+
out.append(tr('Zram algorithm {}').format(self.zram.algorithm))
283289

284290
if self.swapfile:
285291
out.append(tr('Swap file enabled'))
286292

287-
return out or None
293+
return out
288294

289295

290296
@dataclass

‎tests/data/test_config.json‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,11 @@
208208
"echo 'Hello, World!'"
209209
],
210210
"swap": {
211-
"enabled": true,
212-
"algorithm": "zstd"
211+
"zram": {
212+
"enabled": true,
213+
"algorithm": "zstd"
214+
},
215+
"swapfile": false
213216
},
214217
"timezone": "UTC",
215218
"version": "3.0.2"

0 commit comments

Comments
 (0)