Skip to content

Commit

Permalink
Merge pull request #110 from Thymis-io/fix/image-format
Browse files Browse the repository at this point in the history
Fix use first available image format if not set
  • Loading branch information
MSchmoecker authored Oct 9, 2024
2 parents 0a1911b + d697325 commit ae6c84d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions controller/thymis_controller/modules/thymis.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ def write_nix_settings(

if image_format:
f.write(f" inputs.thymis.nixosModules.thymis-image-{image_format}\n")
elif device_type:
first_format = self.find_image_format_by_device_type(device_type)
f.write(f" inputs.thymis.nixosModules.thymis-image-{first_format}\n")

f.write(f" ];\n")

Expand Down Expand Up @@ -729,3 +732,16 @@ def write_nix_settings(
f.write(f' time.timeZone = "{time_zone}";\n')

return super().write_nix_settings(f, module_settings, priority, project)

def find_image_format_by_device_type(self, device_type):
restricted = self.image_format.type.extra_data["restrict_values_on_other_key"]
available_formats = restricted["device_type"][device_type]

return next(
(
format[1]
for format in self.image_format.type.select_one
if format[1] in available_formats
),
None,
)

0 comments on commit ae6c84d

Please sign in to comment.