ignore dryRun k8s request when auditing

Signed-off-by: wanjunlei <wanjunlei@yunify.com>
This commit is contained in:
wanjunlei
2020-07-15 11:38:32 +08:00
parent 42b543ec5e
commit a0255d6409
4 changed files with 25 additions and 12 deletions

View File

@@ -18,9 +18,8 @@ package request
import (
"context"
"kubesphere.io/kubesphere/pkg/apiserver/auditing/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apiserver/pkg/apis/audit"
"k8s.io/apiserver/pkg/authentication/user"
)
@@ -87,12 +86,12 @@ func UserFrom(ctx context.Context) (user.Info, bool) {
}
// WithAuditEvent returns set audit event struct.
func WithAuditEvent(parent context.Context, ev *v1alpha1.Event) context.Context {
func WithAuditEvent(parent context.Context, ev *audit.Event) context.Context {
return WithValue(parent, auditKey, ev)
}
// AuditEventFrom returns the audit event struct on the ctx
func AuditEventFrom(ctx context.Context) *v1alpha1.Event {
ev, _ := ctx.Value(auditKey).(*v1alpha1.Event)
func AuditEventFrom(ctx context.Context) *audit.Event {
ev, _ := ctx.Value(auditKey).(*audit.Event)
return ev
}