Skip to content

Commit

Permalink
fix webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
bxy4543 committed Sep 11, 2024
1 parent 7a19c64 commit 4c53781
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 4 additions & 1 deletion controllers/account/api/v1/debt_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,12 @@ func (d *DebtValidate) Handle(ctx context.Context, req admission.Request) admiss
return admission.ValidationResponse(true, "")
}
// is user sa
if !strings.HasPrefix(g, saPrefix+":ns-") {
if !strings.HasPrefix(g, saPrefix+":user-system") {
continue
}
if strings.Contains(req.UserInfo.Username, "user-controller-manager") {
break
}
if isWhiteList(req) {
return admission.ValidationResponse(true, "")
}
Expand Down
6 changes: 3 additions & 3 deletions controllers/account/controllers/billing_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ func (r *BillingReconciler) SetupWithManager(mgr ctrl.Manager, rateOpts controll
own, ok := createEvent.Object.GetLabels()[v1.UserLabelOwnerKey]
return ok && getUsername(createEvent.Object.GetName()) == own
},
UpdateFunc: func(updateEvent event.UpdateEvent) bool {
UpdateFunc: func(_ event.UpdateEvent) bool {
return false
},
DeleteFunc: func(deleteEvent event.DeleteEvent) bool {
DeleteFunc: func(_ event.DeleteEvent) bool {
return false
},
GenericFunc: func(genericEvent event.GenericEvent) bool {
GenericFunc: func(_ event.GenericEvent) bool {
return false
},
})).
Expand Down
4 changes: 3 additions & 1 deletion controllers/account/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package main
import (
"context"
"flag"
"fmt"
"os"
"time"

Expand Down Expand Up @@ -80,7 +81,7 @@ func main() {
)
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
flag.BoolVar(&development, "development", false, "Enable development mode.")
flag.BoolVar(&development, "development", true, "Enable development mode.")
flag.BoolVar(&enableLeaderElection, "leader-elect", true,
"Enable leader election for controller manager. "+
"Enabling this will ensure there is only one active controller manager.")
Expand All @@ -91,6 +92,7 @@ func main() {
opts := zap.Options{
Development: development,
}
fmt.Printf("opts: %v\n", opts)
rateLimiterOptions.BindFlags(flag.CommandLine)
opts.BindFlags(flag.CommandLine)
flag.Parse()
Expand Down

0 comments on commit 4c53781

Please sign in to comment.