mirror of
https://github.com/labring/sealos.git
synced 2026-09-21 13:51:32 +08:00
fix:change log level (#1838)
Signed-off-by: 晓杰 <2561589453@qq.com> Signed-off-by: 晓杰 <2561589453@qq.com>
This commit is contained in:
@@ -472,3 +472,14 @@ kind: List
|
||||
metadata:
|
||||
resourceVersion: ""
|
||||
```
|
||||
|
||||
add payment
|
||||
```yaml
|
||||
apiVersion: user.sealos.io/v1
|
||||
kind: Payment
|
||||
metadata:
|
||||
name: payment-sample
|
||||
spec:
|
||||
userID: 51d368d3-06c7-42c5-97b1-c1f0d0c8636e
|
||||
amount: 1
|
||||
```
|
||||
@@ -21,6 +21,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
|
||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||
|
||||
rbacV1 "k8s.io/api/rbac/v1"
|
||||
@@ -48,6 +50,7 @@ import (
|
||||
type AccountReconciler struct {
|
||||
client.Client
|
||||
Scheme *runtime.Scheme
|
||||
Logger logr.Logger
|
||||
}
|
||||
|
||||
//+kubebuilder:rbac:groups=user.sealos.io,resources=accounts,verbs=get;list;watch;create;update;patch;delete
|
||||
@@ -64,7 +67,7 @@ type AccountReconciler struct {
|
||||
// For more details, check Reconcile and its Result here:
|
||||
// - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.12.2/pkg/reconcile
|
||||
func (r *AccountReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
||||
log := log.FromContext(ctx)
|
||||
logger := log.FromContext(ctx)
|
||||
payment := &userv1.Payment{}
|
||||
err := r.Get(ctx, client.ObjectKey{Namespace: req.Namespace, Name: req.Name}, payment)
|
||||
if errors.IsNotFound(err) {
|
||||
@@ -90,7 +93,7 @@ func (r *AccountReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
|
||||
if errors.IsNotFound(err) {
|
||||
account.Status.Balance = 0
|
||||
account.Status.ChargeList = []userv1.Charge{}
|
||||
log.Info("create account", "account", account)
|
||||
logger.Info("create account", "account", account)
|
||||
if err := r.Create(ctx, account); err != nil {
|
||||
return ctrl.Result{}, fmt.Errorf("create account failed: %v", err)
|
||||
}
|
||||
@@ -107,7 +110,7 @@ func (r *AccountReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
|
||||
if err != nil {
|
||||
return ctrl.Result{}, fmt.Errorf("query order failed: %v", err)
|
||||
}
|
||||
log.Info(fmt.Sprintf("query order: %v", status))
|
||||
logger.V(1).Info("query order status: %s", status)
|
||||
switch status {
|
||||
case pay.StatusSuccess:
|
||||
account.Status.ChargeList = append(account.Status.ChargeList, userv1.Charge{
|
||||
@@ -188,6 +191,7 @@ func (r *AccountReconciler) syncRoleAndRoleBinding(ctx context.Context, name, na
|
||||
|
||||
// SetupWithManager sets up the controller with the Manager.
|
||||
func (r *AccountReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||
r.Logger.V(1).Info("init reconcile controller account")
|
||||
err := r.Create(context.TODO(), &v1.Namespace{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: constants.SealosSystemNamespace,
|
||||
|
||||
@@ -21,6 +21,8 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
|
||||
"github.com/labring/sealos/pkg/pay"
|
||||
|
||||
"github.com/mdp/qrterminal"
|
||||
@@ -37,6 +39,7 @@ import (
|
||||
type PaymentReconciler struct {
|
||||
client.Client
|
||||
Scheme *runtime.Scheme
|
||||
Logger logr.Logger
|
||||
}
|
||||
|
||||
//+kubebuilder:rbac:groups=user.sealos.io,resources=payments,verbs=get;list;watch;create;update;patch;delete
|
||||
@@ -90,6 +93,7 @@ func (r *PaymentReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ct
|
||||
|
||||
// SetupWithManager sets up the controller with the Manager.
|
||||
func (r *PaymentReconciler) SetupWithManager(mgr ctrl.Manager) error {
|
||||
r.Logger.V(1).Info("init reconcile controller payment")
|
||||
return ctrl.NewControllerManagedBy(mgr).
|
||||
For(&userv1.Payment{}).
|
||||
Complete(r)
|
||||
|
||||
@@ -64,7 +64,7 @@ require (
|
||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
|
||||
golang.org/x/net v0.0.0-20220805013720-a33c5aa5df48 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20220808172628-8227340efae7 // indirect
|
||||
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 // indirect
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect
|
||||
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
golang.org/x/time v0.0.0-20220722155302-e5dcc9cfc0b9 // indirect
|
||||
|
||||
@@ -872,8 +872,8 @@ golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 h1:v1W7bwXHsnLLloWYTVEdvGvA7BHMeBYsPcF0GLDxIRs=
|
||||
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 h1:v6hYoSR9T5oet+pMXwUWkbiVqx/63mlHjefrHmxwfeY=
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
|
||||
Reference in New Issue
Block a user