Skip to content

Commit 4614d05

Browse files
committed
removes unused ctx param in redfish funcs
1 parent 962fcee commit 4614d05

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

bmc/bmc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ type BMC interface {
121121
DeleteAccount(ctx context.Context, userName, id string) error
122122

123123
// GetAccounts retrieves all BMC user accounts.
124-
GetAccounts(ctx context.Context) ([]*redfish.ManagerAccount, error)
124+
GetAccounts() ([]*redfish.ManagerAccount, error)
125125

126126
// GetAccountService retrieves the account service.
127-
GetAccountService(ctx context.Context) (*redfish.AccountService, error)
127+
GetAccountService() (*redfish.AccountService, error)
128128
}
129129

130130
type Entity struct {

bmc/redfish.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -805,26 +805,24 @@ func (r *RedfishBMC) DeleteAccount(ctx context.Context, userName, id string) err
805805
if err != nil {
806806
return err
807807
}
808-
defer func(Body io.ReadCloser) {
809-
if err = Body.Close(); err != nil {
810-
log.Error(err, "failed to close response body")
811-
}
812-
}(resp.Body)
808+
if err = resp.Body.Close(); err != nil {
809+
log.Error(err, "failed to close response body")
810+
}
813811
return nil
814812
}
815813
}
816814
return fmt.Errorf("account %s not found", userName)
817815
}
818816

819-
func (r *RedfishBMC) GetAccountService(ctx context.Context) (*redfish.AccountService, error) {
817+
func (r *RedfishBMC) GetAccountService() (*redfish.AccountService, error) {
820818
service, err := r.client.GetService().AccountService()
821819
if err != nil {
822820
return nil, fmt.Errorf("failed to get account service: %w", err)
823821
}
824822
return service, nil
825823
}
826824

827-
func (r *RedfishBMC) GetAccounts(ctx context.Context) ([]*redfish.ManagerAccount, error) {
825+
func (r *RedfishBMC) GetAccounts() ([]*redfish.ManagerAccount, error) {
828826
service, err := r.client.GetService().AccountService()
829827
if err != nil {
830828
return nil, fmt.Errorf("failed to get account service: %w", err)

bmc/redfish_local.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func NewRedfishLocalBMCClient(ctx context.Context, options Options) (BMC, error)
5353
}
5454

5555
// GetAccounts retrieves all user accounts from the BMC.
56-
func (r *RedfishLocalBMC) GetAccounts(ctx context.Context) ([]*redfish.ManagerAccount, error) {
56+
func (r *RedfishLocalBMC) GetAccounts() ([]*redfish.ManagerAccount, error) {
5757
accounts := make([]*redfish.ManagerAccount, 0, len(UnitTestMockUps.Accounts))
5858
for _, a := range UnitTestMockUps.Accounts {
5959
accounts = append(accounts, a)

internal/controller/bmcuser_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (r *BMCUserReconciler) reconcile(ctx context.Context, log logr.Logger, user
125125
}
126126

127127
func (r *BMCUserReconciler) patchUserStatus(ctx context.Context, log logr.Logger, user *metalv1alpha1.BMCUser, bmcClient bmc.BMC) error {
128-
accounts, err := bmcClient.GetAccounts(ctx)
128+
accounts, err := bmcClient.GetAccounts()
129129
if err != nil {
130130
return fmt.Errorf("failed to get BMC accounts: %w", err)
131131
}
@@ -183,7 +183,7 @@ func (r *BMCUserReconciler) handleRotatingPassword(ctx context.Context, log logr
183183
}, nil
184184
}
185185
log.Info("Rotating BMC user password", "User", user.Name)
186-
accountService, err := bmcClient.GetAccountService(ctx)
186+
accountService, err := bmcClient.GetAccountService()
187187
if err != nil {
188188
return ctrl.Result{}, fmt.Errorf("failed to get account service: %w", err)
189189
}
@@ -213,7 +213,7 @@ func (r *BMCUserReconciler) handleRotatingPassword(ctx context.Context, log logr
213213

214214
func (r *BMCUserReconciler) ensureBMCSecretForUser(ctx context.Context, log logr.Logger, bmcClient bmc.BMC, user *metalv1alpha1.BMCUser, bmcObj *metalv1alpha1.BMC) error {
215215
log.Info("No BMCSecret reference set for User, creating a new one", "User", user.Name)
216-
accountService, err := bmcClient.GetAccountService(ctx)
216+
accountService, err := bmcClient.GetAccountService()
217217
if err != nil {
218218
return fmt.Errorf("failed to get account service: %w", err)
219219
}

internal/webhook/v1alpha1/bmcsecret_webhook_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ var _ = Describe("BMCSecret Webhook", func() {
2222
validator = BMCSecretCustomValidator{
2323
Client: k8sClient,
2424
}
25-
Expect(validator).NotTo(BeNil(), "Expected validator to be initialized")
2625
BMCSecret = &metalv1alpha1.BMCSecret{
2726
ObjectMeta: metav1.ObjectMeta{
2827
Namespace: "test-namespace",

0 commit comments

Comments
 (0)