Skip to content

Commit

Permalink
Fix SetBiosFromFile
Browse files Browse the repository at this point in the history
Fix example
  • Loading branch information
jakeschuurmans committed Nov 8, 2024
1 parent f669e7b commit 63408f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
4 changes: 2 additions & 2 deletions bmc/bios.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func SetBiosConfigurationFromFileInterfaces(ctx context.Context, generic []inter
temp.BiosConfigurationSetter = p
implementations = append(implementations, temp)
default:
e := fmt.Sprintf("not a BiosConfigurationSetter implementation: %T", p)
e := fmt.Sprintf("not a BiosConfigurationSetterFromFile implementation: %T", p)
err = multierror.Append(err, errors.New(e))
}
}
Expand All @@ -219,7 +219,7 @@ func SetBiosConfigurationFromFileInterfaces(ctx context.Context, generic []inter
err,
errors.Wrap(
bmclibErrs.ErrProviderImplementation,
("no BiosConfigurationSetter implementations found"),
("no BiosConfigurationSetterFromFile implementations found"),
),
)
}
Expand Down
26 changes: 5 additions & 21 deletions examples/bios/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,29 +93,14 @@ func main() {
l.Error(err)
}
case "setfile":
exampleConfig := make(map[string]string)

if *dfile != "" {
cfgFile, err := os.Open(*dfile)
if err != nil {
l.Fatal(err)
}

defer cfgFile.Close()
fmt.Println("Attempting to set BIOS configuration:")

jsonData, _ := io.ReadAll(cfgFile)
err = json.Unmarshal(jsonData, &exampleConfig)
if err != nil {
l.Error(err)
}
} else {
exampleConfig["TpmSecurity"] = "Off"
contents, err := os.ReadFile(*dfile)
if err != nil {
l.Fatal(err)
}

fmt.Println("Attempting to set BIOS configuration:")
fmt.Printf("exampleConfig: %+v\n", exampleConfig)

err := client.SetBiosConfiguration(ctx, exampleConfig)
err = client.SetBiosConfigurationFromFile(ctx, string(contents))
if err != nil {
l.Error(err)
}
Expand All @@ -126,6 +111,5 @@ func main() {
}
default:
l.Fatal("Unknown mode: " + *mode)

}
}
2 changes: 1 addition & 1 deletion providers/supermicro/supermicro.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (c *Client) SetBiosConfiguration(ctx context.Context, biosConfig map[string
}

// SetBiosConfigurationFromFile sets the bios configuration from a raw vendor config file
func (c *Client) SetBIOSConfigurationFromFile(ctx context.Context, cfg string) (err error) {
func (c *Client) SetBiosConfigurationFromFile(ctx context.Context, cfg string) (err error) {
if c.serviceClient == nil || c.serviceClient.sum == nil {
return errors.Wrap(bmclibErrs.ErrLoginFailed, "client not initialized")
}
Expand Down

0 comments on commit 63408f3

Please sign in to comment.