Skip to content

Commit

Permalink
UpdateRequirements getters to return a pointer to struct
Browse files Browse the repository at this point in the history
instead of a copy of the struct
  • Loading branch information
joelrebel committed Aug 15, 2024
1 parent f707d24 commit e42b165
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions actions/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type Getter interface {
// Retrieve BIOS configuration for device
GetBIOSConfiguration(ctx context.Context) (map[string]string, error)
// UpdateRequirements returns requirements to be met before and after a firmware install
UpdateRequirements(ctx context.Context, componentSlug, componentVendor, componentModel string) (model.UpdateRequirements, error)
UpdateRequirements(ctx context.Context, componentSlug, componentVendor, componentModel string) (*model.UpdateRequirements, error)
}

// Utility interface couples the configuration, collection and update interfaces
Expand Down Expand Up @@ -154,7 +154,7 @@ type UEFIVarsCollector interface {
// UpdateRequirements returns requirements to be met before and after a firmware install,
// the caller may use the information to determine if a powercycle, reconfiguration or other actions are required on the component.
type UpdateRequirementsGetter interface {
UpdateRequirements(componentModel string) model.UpdateRequirements
UpdateRequirements(componentModel string) *model.UpdateRequirements
}

// DriveUpdater defines an interface to update drive firmware
Expand Down
7 changes: 3 additions & 4 deletions actions/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,21 @@ func UpdateAll(ctx context.Context, device *common.Device, options []*model.Upda

// UpdateRequirements returns requirements to be met before and after a firmware install,
// the caller may use the information to determine if a powercycle, reconfiguration or other actions are required on the component.
func UpdateRequirements(componentSlug, componentVendor, componentModel string) (model.UpdateRequirements, error) {
func UpdateRequirements(componentSlug, componentVendor, componentModel string) (*model.UpdateRequirements, error) {
slug := strings.ToUpper(componentSlug)
vendor := common.FormatVendorName(componentVendor)
req := model.UpdateRequirements{}

switch componentSlug {
case common.SlugNIC:
updater, err := GetNICUpdater(vendor)
if err != nil {
return req, err
return nil, err
}

return updater.UpdateRequirements(componentModel), nil

default:
return req, errors.Wrap(errs.ErrNoUpdateHandlerForComponent, "component: "+slug)
return nil, errors.Wrap(errs.ErrNoUpdateHandlerForComponent, "component: "+slug)
}
}

Expand Down
4 changes: 2 additions & 2 deletions providers/asrockrack/asrockrack.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ func (a *asrockrack) InstallUpdates(context.Context, *model.UpdateOptions) error

// UpdateRequirements returns requirements to be met before and after a firmware install,
// the caller may use the information to determine if a powercycle, reconfiguration or other actions are required on the component.
func (a *asrockrack) UpdateRequirements(_ context.Context, _, _, _ string) (model.UpdateRequirements, error) {
return model.UpdateRequirements{}, errors.Wrap(errs.ErrUpdateReqNotImplemented, "provider: asrockrack")
func (a *asrockrack) UpdateRequirements(_ context.Context, _, _, _ string) (*model.UpdateRequirements, error) {
return nil, errors.Wrap(errs.ErrUpdateReqNotImplemented, "provider: asrockrack")
}

// GetInventoryOEM collects device inventory using vendor specific tooling
Expand Down
4 changes: 2 additions & 2 deletions providers/dell/dell.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ func (d *dell) ListAvailableUpdates(ctx context.Context, options *model.UpdateOp

// UpdateRequirements returns requirements to be met before and after a firmware install,
// the caller may use the information to determine if a powercycle, reconfiguration or other actions are required on the component.
func (d *dell) UpdateRequirements(_ context.Context, _, _, _ string) (model.UpdateRequirements, error) {
return model.UpdateRequirements{}, errors.Wrap(errs.ErrUpdateReqNotImplemented, "provider: generic")
func (d *dell) UpdateRequirements(_ context.Context, _, _, _ string) (*model.UpdateRequirements, error) {
return nil, errors.Wrap(errs.ErrUpdateReqNotImplemented, "provider: generic")
}

// InstallUpdates for Dells based on updateOptions
Expand Down
4 changes: 2 additions & 2 deletions providers/generic/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ func (a *Generic) ListAvailableUpdates(_ context.Context, _ *model.UpdateOptions

// UpdateRequirements returns requirements to be met before and after a firmware install,
// the caller may use the information to determine if a powercycle, reconfiguration or other actions are required on the component.
func (a *Generic) UpdateRequirements(_ context.Context, _, _, _ string) (model.UpdateRequirements, error) {
return model.UpdateRequirements{}, errors.Wrap(errs.ErrUpdateReqNotImplemented, "provider: generic")
func (a *Generic) UpdateRequirements(_ context.Context, _, _, _ string) (*model.UpdateRequirements, error) {
return nil, errors.Wrap(errs.ErrUpdateReqNotImplemented, "provider: generic")
}

// InstallUpdates installs updates based on updateOptions
Expand Down
2 changes: 1 addition & 1 deletion providers/supermicro/supermicro.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (s *supermicro) ListAvailableUpdates(context.Context, *model.UpdateOptions)

// UpdateRequirements returns requirements to be met before and after a firmware install,
// the caller may use the information to determine if a powercycle, reconfiguration or other actions are required on the component.
func (s *supermicro) UpdateRequirements(_ context.Context, componentSlug, componentVendor, componentModel string) (model.UpdateRequirements, error) {
func (s *supermicro) UpdateRequirements(_ context.Context, componentSlug, componentVendor, componentModel string) (*model.UpdateRequirements, error) {
return actions.UpdateRequirements(componentSlug, componentVendor, componentModel)
}

Expand Down
4 changes: 2 additions & 2 deletions utils/mlxup.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func setNICFirmware(d *MlxupDevice, firmware *common.Firmware) {
}

// UpdateRequirements implements the actions/NICUpdater interface to return any pre/post firmware install requirements.
func (m *Mlxup) UpdateRequirements(_ string) model.UpdateRequirements {
return model.UpdateRequirements{PostInstallHostPowercycle: true}
func (m *Mlxup) UpdateRequirements(_ string) *model.UpdateRequirements {
return &model.UpdateRequirements{PostInstallHostPowercycle: true}
}

// UpdateNIC updates mellanox NIC with the given update file
Expand Down

0 comments on commit e42b165

Please sign in to comment.