Skip to content

Commit

Permalink
fix billing nil point error
Browse files Browse the repository at this point in the history
  • Loading branch information
bxy4543 committed Sep 26, 2023
1 parent 6ac6bf8 commit e7e35ad
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions controllers/account/controllers/billing_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ func (r *BillingReconciler) rechargeBalance(owner string, amount int64) (err err
if err = r.Get(context.Background(), types.NamespacedName{Name: owner, Namespace: r.AccountSystemNamespace}, account); err != nil {
return fmt.Errorf("get account cr failed: %w", err)
}
if account.Status.EncryptDeductionBalance == nil {
account.Status.EncryptDeductionBalance, err = crypto.EncryptInt64(0)
if err != nil {
return fmt.Errorf("encrypt balance failed: %w", err)
}
}
if err = crypto.RechargeBalance(account.Status.EncryptDeductionBalance, amount); err != nil {
return fmt.Errorf("recharge balance failed: %w", err)
}
Expand Down

0 comments on commit e7e35ad

Please sign in to comment.