From 27122f0e47f038bd8a4b2329d1e1a1040662e48e Mon Sep 17 00:00:00 2001 From: "James W. Brinkerhoff" Date: Tue, 16 Apr 2024 09:38:26 -0400 Subject: [PATCH] Use newMetadata() helper --- bmc/bios.go | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bmc/bios.go b/bmc/bios.go index cdc0db00..13c9d3a8 100644 --- a/bmc/bios.go +++ b/bmc/bios.go @@ -37,7 +37,7 @@ type biosConfigurationResetterProvider struct { } func biosConfiguration(ctx context.Context, generic []biosConfigurationGetterProvider) (biosConfig map[string]string, metadata Metadata, err error) { - var metadataLocal Metadata + metadata = newMetadata() Loop: for _, elem := range generic { if elem.BiosConfigurationGetter == nil { @@ -48,7 +48,7 @@ Loop: err = multierror.Append(err, ctx.Err()) break Loop default: - metadataLocal.ProvidersAttempted = append(metadataLocal.ProvidersAttempted, elem.name) + metadata.ProvidersAttempted = append(metadata.ProvidersAttempted, elem.name) biosConfig, vErr := elem.GetBiosConfiguration(ctx) if vErr != nil { err = multierror.Append(err, errors.WithMessagef(vErr, "provider: %v", elem.name)) @@ -56,16 +56,16 @@ Loop: continue } - metadataLocal.SuccessfulProvider = elem.name - return biosConfig, metadataLocal, nil + metadata.SuccessfulProvider = elem.name + return biosConfig, metadata, nil } } - return biosConfig, metadataLocal, multierror.Append(err, errors.New("failure to get bios configuration")) + return biosConfig, metadata, multierror.Append(err, errors.New("failure to get bios configuration")) } func setBiosConfiguration(ctx context.Context, generic []biosConfigurationSetterProvider, biosConfig map[string]string) (metadata Metadata, err error) { - var metadataLocal Metadata + metadata = newMetadata() Loop: for _, elem := range generic { if elem.BiosConfigurationSetter == nil { @@ -76,7 +76,7 @@ Loop: err = multierror.Append(err, ctx.Err()) break Loop default: - metadataLocal.ProvidersAttempted = append(metadataLocal.ProvidersAttempted, elem.name) + metadata.ProvidersAttempted = append(metadata.ProvidersAttempted, elem.name) vErr := elem.SetBiosConfiguration(ctx, biosConfig) if vErr != nil { err = multierror.Append(err, errors.WithMessagef(vErr, "provider: %v", elem.name)) @@ -84,16 +84,16 @@ Loop: continue } - metadataLocal.SuccessfulProvider = elem.name - return metadataLocal, nil + metadata.SuccessfulProvider = elem.name + return metadata, nil } } - return metadataLocal, multierror.Append(err, errors.New("failure to set bios configuration")) + return metadata, multierror.Append(err, errors.New("failure to set bios configuration")) } func resetBiosConfiguration(ctx context.Context, generic []biosConfigurationResetterProvider) (metadata Metadata, err error) { - var metadataLocal Metadata + metadata = newMetadata() Loop: for _, elem := range generic { if elem.BiosConfigurationResetter == nil { @@ -104,7 +104,7 @@ Loop: err = multierror.Append(err, ctx.Err()) break Loop default: - metadataLocal.ProvidersAttempted = append(metadataLocal.ProvidersAttempted, elem.name) + metadata.ProvidersAttempted = append(metadata.ProvidersAttempted, elem.name) vErr := elem.ResetBiosConfiguration(ctx) if vErr != nil { err = multierror.Append(err, errors.WithMessagef(vErr, "provider: %v", elem.name)) @@ -112,12 +112,12 @@ Loop: continue } - metadataLocal.SuccessfulProvider = elem.name - return metadataLocal, nil + metadata.SuccessfulProvider = elem.name + return metadata, nil } } - return metadataLocal, multierror.Append(err, errors.New("failure to reset bios configuration")) + return metadata, multierror.Append(err, errors.New("failure to reset bios configuration")) } func GetBiosConfigurationInterfaces(ctx context.Context, generic []interface{}) (biosConfig map[string]string, metadata Metadata, err error) {