Skip to content

Commit

Permalink
Use newMetadata() helper
Browse files Browse the repository at this point in the history
  • Loading branch information
splaspood committed Apr 16, 2024
1 parent 78a8bbd commit 27122f0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions bmc/bios.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -48,24 +48,24 @@ Loop:
err = multierror.Append(err, ctx.Err())

Check failure on line 48 in bmc/bios.go

View workflow job for this annotation

GitHub Actions / lint

undefined: multierror (typecheck)

Check failure on line 48 in bmc/bios.go

View workflow job for this annotation

GitHub Actions / lint

undefined: multierror (typecheck)
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))

Check failure on line 54 in bmc/bios.go

View workflow job for this annotation

GitHub Actions / lint

undefined: multierror (typecheck)

Check failure on line 54 in bmc/bios.go

View workflow job for this annotation

GitHub Actions / lint

undefined: multierror (typecheck)
err = multierror.Append(err, vErr)

Check failure on line 55 in bmc/bios.go

View workflow job for this annotation

GitHub Actions / lint

undefined: multierror (typecheck)

Check failure on line 55 in bmc/bios.go

View workflow job for this annotation

GitHub Actions / lint

undefined: multierror (typecheck)
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 {
Expand All @@ -76,24 +76,24 @@ 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))
err = multierror.Append(err, vErr)
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 {
Expand All @@ -104,20 +104,20 @@ 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))
err = multierror.Append(err, vErr)
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) {
Expand Down

0 comments on commit 27122f0

Please sign in to comment.