mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Merge pull request #70060 from pbarker/audit-webhook
updates shared apiserver webhook client
This commit is contained in:
commit
9fb4a2aa9a
@ -66,14 +66,14 @@ func NewClientManager(gv schema.GroupVersion, addToSchemaFunc func(s *runtime.Sc
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ClientManager{}, err
|
return ClientManager{}, err
|
||||||
}
|
}
|
||||||
admissionScheme := runtime.NewScheme()
|
hookScheme := runtime.NewScheme()
|
||||||
if err := addToSchemaFunc(admissionScheme); err != nil {
|
if err := addToSchemaFunc(hookScheme); err != nil {
|
||||||
return ClientManager{}, err
|
return ClientManager{}, err
|
||||||
}
|
}
|
||||||
return ClientManager{
|
return ClientManager{
|
||||||
cache: cache,
|
cache: cache,
|
||||||
negotiatedSerializer: serializer.NegotiatedSerializerWrapper(runtime.SerializerInfo{
|
negotiatedSerializer: serializer.NegotiatedSerializerWrapper(runtime.SerializerInfo{
|
||||||
Serializer: serializer.NewCodecFactory(admissionScheme).LegacyCodec(gv),
|
Serializer: serializer.NewCodecFactory(hookScheme).LegacyCodec(gv),
|
||||||
}),
|
}),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ type ErrCallingWebhook struct {
|
|||||||
|
|
||||||
func (e *ErrCallingWebhook) Error() string {
|
func (e *ErrCallingWebhook) Error() string {
|
||||||
if e.Reason != nil {
|
if e.Reason != nil {
|
||||||
return fmt.Sprintf("failed calling admission webhook %q: %v", e.WebhookName, e.Reason)
|
return fmt.Sprintf("failed calling webhook %q: %v", e.WebhookName, e.Reason)
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("failed calling admission webhook %q; no further details available", e.WebhookName)
|
return fmt.Sprintf("failed calling webhook %q; no further details available", e.WebhookName)
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ const defaultRequestTimeout = 30 * time.Second
|
|||||||
|
|
||||||
type GenericWebhook struct {
|
type GenericWebhook struct {
|
||||||
RestClient *rest.RESTClient
|
RestClient *rest.RESTClient
|
||||||
initialBackoff time.Duration
|
InitialBackoff time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGenericWebhook creates a new GenericWebhook from the provided kubeconfig file.
|
// NewGenericWebhook creates a new GenericWebhook from the provided kubeconfig file.
|
||||||
@ -83,7 +83,7 @@ func newGenericWebhook(scheme *runtime.Scheme, codecFactory serializer.CodecFact
|
|||||||
// it returns an error for which apierrors.SuggestsClientDelay() or apierrors.IsInternalError() returns true.
|
// it returns an error for which apierrors.SuggestsClientDelay() or apierrors.IsInternalError() returns true.
|
||||||
func (g *GenericWebhook) WithExponentialBackoff(webhookFn func() rest.Result) rest.Result {
|
func (g *GenericWebhook) WithExponentialBackoff(webhookFn func() rest.Result) rest.Result {
|
||||||
var result rest.Result
|
var result rest.Result
|
||||||
WithExponentialBackoff(g.initialBackoff, func() error {
|
WithExponentialBackoff(g.InitialBackoff, func() error {
|
||||||
result = webhookFn()
|
result = webhookFn()
|
||||||
return result.Error()
|
return result.Error()
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user