Skip to content

Refactor BMC superuser creation - #191

Draft
simcod wants to merge 4 commits into
masterfrom
refactor-superuser-check-creation
Draft

Refactor BMC superuser creation#191
simcod wants to merge 4 commits into
masterfrom
refactor-superuser-check-creation

Conversation

@simcod

@simcod simcod commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Description

Refactors the code to check, if a password change for the BMC superuser is necessary.

Used AI-Tools ✨

  • None

@metal-robot metal-robot Bot added this to Development Jul 7, 2026

@izvyk izvyk left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me overall!

Comment thread cmd/supwd.go Outdated
// return fmt.Errorf("failed to create bmc superuser: %s %w", bmcConn.SuperUser().Name, err)
h.log.Error("failed to create bmc superuser", "user", bmcConn.SuperUser().Name, "error", err)
return nil
if !changeIsNeeded {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just a matter of taste, but still: Here the returned value is trusted although the function returned a non-nil error. The current implementation only returns true with an error, so this implementation follows that correctly. I'd suggest removing the error in case true is returned, see here.

Comment thread cmd/supwd.go Outdated
h.log.Warn("bmc reported an error configuring superuser, but password verification succeeded, proceed",
"user", bmcConn.SuperUser().Name, "error", err)
} else {
h.log.Info("created superuser", "user", bmcConn.SuperUser().Name)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to check if the password was actually changed? Or would it be too much xD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants