Skip to content

Commit 2287136

Browse files
committed
api: allow empty filesystem string
Clients may send an empty filesystem string, don't ignore their requests but handle them as if no filesystem was set. Signed-off-by: Paul Spooren <mail@aparcar.org>
1 parent 0ca7466 commit 2287136

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

asu/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def download_file(filename: str, dest: str = None):
271271

272272
log.debug("Created store path: %s", req["store_path"] / bin_dir)
273273

274-
if "filesystem" in req:
274+
if req.get("filesystem"):
275275
config_path = cache_workdir / ".config"
276276
config = config_path.read_text()
277277

@@ -293,6 +293,7 @@ def download_file(filename: str, dest: str = None):
293293

294294
config_path.write_text(config)
295295
else:
296+
log.debug("Enable default filesystems")
296297
copyfile(
297298
cache_workdir / ".config.orig",
298299
cache_workdir / ".config",

asu/openapi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,7 @@ components:
260260
- ext4
261261
- ubifs
262262
- jffs2
263+
- ""
263264
description: |
264265
Ability to specify filesystem running on device. Attaching this
265266
optional parameter will limit the ImageBuilder to only build

tests/test_api.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,26 @@ def test_api_build_filesystem_squashfs(app, upstream):
6262
assert "# CONFIG_TARGET_ROOTFS_EXT4FS is not set" in config
6363
assert "CONFIG_TARGET_ROOTFS_SQUASHFS=y" in config
6464

65+
def test_api_build_filesystem_empty(app, upstream):
66+
client = app.test_client()
67+
response = client.post(
68+
"/api/v1/build",
69+
json=dict(
70+
version="TESTVERSION",
71+
target="testtarget/testsubtarget",
72+
profile="testprofile",
73+
packages=["test1", "test2"],
74+
filesystem="",
75+
),
76+
)
77+
assert response.status == "200 OK"
78+
assert response.json.get("request_hash") == "33377fbd91c50c4236343f1dfd67f9ae"
79+
config = (
80+
app.config["CACHE_PATH"] / "cache/TESTVERSION/testtarget/testsubtarget/.config"
81+
).read_text()
82+
assert "CONFIG_TARGET_ROOTFS_EXT4FS=y" in config
83+
assert "CONFIG_TARGET_ROOTFS_SQUASHFS=y" in config
84+
6585

6686
def test_api_build_filesystem_reset(app, upstream):
6787
client = app.test_client()

0 commit comments

Comments
 (0)