Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #104 from FabianKramm/master
Browse files Browse the repository at this point in the history
improvement: improve create space logging
  • Loading branch information
FabianKramm authored Feb 12, 2021
2 parents f024cb9 + 70e2b79 commit a7acf7a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/apiserver/registry/space/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func (r *spaceStorage) Create(ctx context.Context, obj runtime.Object, createVal
}

// print some log information
loghelper.Infof("create space %s for user %s: %v", space.Name, a.GetUser().GetName(), err)
loghelper.Infof("create space %s for user %s", space.Name, a.GetUser().GetName())

// Create the target namespace
namespace := ConvertSpace(space)
Expand All @@ -280,7 +280,7 @@ func (r *spaceStorage) Create(ctx context.Context, obj runtime.Object, createVal
}

// Create the default space templates and role binding
loghelper.Infof("initialize space %s for user %s: %v", namespace.Name, a.GetUser().GetName(), err)
loghelper.Infof("initialize space %s for user %s", namespace.Name, a.GetUser().GetName())
err = r.initializeSpace(ctx, namespace, account)
if err != nil {
// we have to use a background context here, because it might
Expand Down
11 changes: 2 additions & 9 deletions pkg/manager/webhooks/quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ type QuotaValidator struct {
Log logr.Logger
Scheme *runtime.Scheme

decoder *admission.Decoder

Decoder *admission.Decoder
AdmissionController apiadmission.ValidationInterface
}

Expand All @@ -48,7 +47,7 @@ func (v *QuotaValidator) Handle(ctx context.Context, req admission.Request) admi
}

// Convert request
attributes, err := NewAttributeFromRequest(req, v.decoder, v.Scheme)
attributes, err := NewAttributeFromRequest(req, v.Decoder, v.Scheme)
if err != nil {
return admission.Errored(1, err)
}
Expand All @@ -61,9 +60,3 @@ func (v *QuotaValidator) Handle(ctx context.Context, req admission.Request) admi

return admission.Allowed("")
}

// InjectDecoder injects the decoder.
func (v *QuotaValidator) InjectDecoder(d *admission.Decoder) error {
v.decoder = d
return nil
}
6 changes: 6 additions & 0 deletions pkg/manager/webhooks/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,24 @@ import (
"github.com/loft-sh/kiosk/pkg/util/encoding"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

// Register registers the webhooks to the manager
func Register(ctrlCtx *controllers.Context) error {
hookServer := ctrlCtx.Manager.GetWebhookServer()
admissionDecoder, err := admission.NewDecoder(ctrlCtx.Manager.GetScheme())
if err != nil {
return err
}

// Create the admission controller
admissionController := quota.NewAccountResourceQuota(ctrlCtx)
hookServer.Register("/quota", &webhook.Admission{Handler: &QuotaValidator{
Log: ctrl.Log.WithName("webhooks").WithName("Quota"),
Scheme: ctrlCtx.Manager.GetScheme(),
AdmissionController: admissionController,
Decoder: admissionDecoder,
}})

hookServer.Register("/validate", &webhook.Admission{Handler: &Validator{
Expand Down

0 comments on commit a7acf7a

Please sign in to comment.