From 5ae1da9b9028f435d5e8ffb1c39c4b367477a61b Mon Sep 17 00:00:00 2001 From: Joel Rebello Date: Tue, 20 Aug 2024 17:51:11 +0200 Subject: [PATCH] store/fleetdb: copy inbandInstall, Oem bool values from firmware set response The InbandInstall bool is required for flasher inband to plan and execute the inband install --- internal/store/fleetdb.go | 40 +++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/internal/store/fleetdb.go b/internal/store/fleetdb.go index 6ac748ac..88cdf194 100644 --- a/internal/store/fleetdb.go +++ b/internal/store/fleetdb.go @@ -313,18 +313,38 @@ func intoFirmwaresSlice(componentFirmware []fleetdbapi.ComponentFirmwareVersion) firmwares := make([]*model.Firmware, 0, len(componentFirmware)) + booleanIsTrue := func(b *bool) bool { + if b != nil && *b { + return true + } + + return false + } + // nolint:gocritic // rangeValCopy - componentFirmware is returned by fleetdb API in this form. for _, firmware := range componentFirmware { - firmwares = append(firmwares, &model.Firmware{ - ID: firmware.UUID.String(), - Vendor: strings.ToLower(firmware.Vendor), - Models: strSliceToLower(firmware.Model), - FileName: firmware.Filename, - Version: firmware.Version, - Component: strings.ToLower(firmware.Component), - Checksum: firmware.Checksum, - URL: firmware.RepositoryURL, - }) + fw := &model.Firmware{ + ID: firmware.UUID.String(), + Vendor: strings.ToLower(firmware.Vendor), + Models: strSliceToLower(firmware.Model), + FileName: firmware.Filename, + Version: firmware.Version, + Component: strings.ToLower(firmware.Component), + Checksum: firmware.Checksum, + URL: firmware.RepositoryURL, + InstallInband: *firmware.InstallInband, + Oem: *firmware.OEM, + } + + if booleanIsTrue(firmware.InstallInband) { + fw.InstallInband = true + } + + if booleanIsTrue(firmware.OEM) { + fw.Oem = true + } + + firmwares = append(firmwares, fw) } return firmwares