Skip to content

Commit

Permalink
stages(kickstart): implement "display_mode" option(s)
Browse files Browse the repository at this point in the history
This implements the display mode options `text`, `graphical`,
`cmdline` as an enum with the name `display_mode`.

See PR#1442 for the rational/discussion of this over using
three boolean options.

Thanks to Achilleas and Tom!
  • Loading branch information
mvo5 authored and supakeen committed Nov 15, 2023
1 parent 2c41bcd commit c9d4286
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 7 additions & 0 deletions stages/org.osbuild.kickstart
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ SCHEMA = r"""
}
}
}]
},
"display_mode": {
"description": "Perform the Kickstart installation in the given display mode",
"enum": ["text", "graphical", "cmdline"]
}
}
"""
Expand Down Expand Up @@ -342,6 +346,9 @@ def main(tree, options):
clearpart = make_clearpart(options)
if clearpart:
config += [clearpart]
display_mode = options.get("display_mode")
if display_mode:
config += [display_mode]

reboot = make_reboot(options)
if reboot:
Expand Down
5 changes: 4 additions & 1 deletion stages/test/test_kickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@
},
"lang en_US.UTF-8\nkeyboard us\ntimezone UTC\nzerombr\nclearpart --all --drives=sd*|hd*|vda,/dev/vdc",
),
# no reboot for an empty dict
({"reboot": True}, "reboot"),
({"reboot": {"eject": False}}, "reboot"),
({"reboot": {"eject": True}}, "reboot --eject"),
({"reboot": {"kexec": False}}, "reboot"),
({"reboot": {"kexec": True}}, "reboot --kexec"),
({"reboot": {"eject": True, "kexec": True}}, "reboot --eject --kexec"),
({"display_mode": "text"}, "text"),
({"display_mode": "graphical"}, "graphical"),
({"display_mode": "cmdline"}, "cmdline"),
]


Expand Down Expand Up @@ -183,6 +185,7 @@ def test_kickstart_valid(tmp_path, test_input, expected): # pylint: disable=unu
({"reboot": {}}, "{} is not valid under any of the given schemas"),
({"reboot": "random-string"}, "'random-string' is not valid "),
({"reboot": {"random": "option"}}, "{'random': 'option'} is not valid "),
({"display_mode": "invalid-mode"}, "'invalid-mode' is not one of "),
],
)
def test_schema_validation_bad_apples(test_data, expected_err):
Expand Down

0 comments on commit c9d4286

Please sign in to comment.