Documentation ¶
Overview ¶
Package webhook implements a generic HTTP webhook plugin.
Index ¶
- func WithExponentialBackoff(initialBackoff time.Duration, webhookFn func() error) error
- type AuthenticationInfoResolver
- type AuthenticationInfoResolverDelegator
- type AuthenticationInfoResolverWrapper
- type ClientConfig
- type ClientConfigService
- type ClientManager
- func (cm *ClientManager) HookClient(cc ClientConfig) (*rest.RESTClient, error)
- func (cm *ClientManager) SetAuthenticationInfoResolver(resolver AuthenticationInfoResolver)
- func (cm *ClientManager) SetAuthenticationInfoResolverWrapper(wrapper AuthenticationInfoResolverWrapper)
- func (cm *ClientManager) SetServiceResolver(sr ServiceResolver)
- func (cm *ClientManager) Validate() error
- type ErrCallingWebhook
- type GenericWebhook
- type ServiceResolver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithExponentialBackoff ¶
WithExponentialBackoff will retry webhookFn() up to 5 times with exponentially increasing backoff when it returns an error for which apierrors.SuggestsClientDelay() or apierrors.IsInternalError() returns true.
Types ¶
type AuthenticationInfoResolver ¶ added in v1.12.0
type AuthenticationInfoResolver interface { // ClientConfigFor builds rest.Config based on the server. ClientConfigFor(server string) (*rest.Config, error) // ClientConfigForService builds rest.Config based on the serviceName and // serviceNamespace. ClientConfigForService(serviceName, serviceNamespace string) (*rest.Config, error) }
AuthenticationInfoResolver builds rest.Config base on the server or service name and service namespace.
func NewDefaultAuthenticationInfoResolver ¶ added in v1.12.0
func NewDefaultAuthenticationInfoResolver(kubeconfigFile string) (AuthenticationInfoResolver, error)
NewDefaultAuthenticationInfoResolver generates an AuthenticationInfoResolver that builds rest.Config based on the kubeconfig file. kubeconfigFile is the path to the kubeconfig.
type AuthenticationInfoResolverDelegator ¶ added in v1.12.0
type AuthenticationInfoResolverDelegator struct { ClientConfigForFunc func(server string) (*rest.Config, error) ClientConfigForServiceFunc func(serviceName, serviceNamespace string) (*rest.Config, error) }
AuthenticationInfoResolverDelegator implements AuthenticationInfoResolver.
func (*AuthenticationInfoResolverDelegator) ClientConfigFor ¶ added in v1.12.0
func (a *AuthenticationInfoResolverDelegator) ClientConfigFor(server string) (*rest.Config, error)
ClientConfigFor returns client config for given server.
func (*AuthenticationInfoResolverDelegator) ClientConfigForService ¶ added in v1.12.0
func (a *AuthenticationInfoResolverDelegator) ClientConfigForService(serviceName, serviceNamespace string) (*rest.Config, error)
ClientConfigForService returns client config for given service.
type AuthenticationInfoResolverWrapper ¶ added in v1.12.0
type AuthenticationInfoResolverWrapper func(AuthenticationInfoResolver) AuthenticationInfoResolver
AuthenticationInfoResolverWrapper can be used to inject Dial function to the rest.Config generated by the resolver.
type ClientConfig ¶ added in v1.12.0
type ClientConfig struct { Name string URL string CABundle []byte Service *ClientConfigService }
ClientConfig defines parameters required for creating a hook client.
type ClientConfigService ¶ added in v1.12.0
ClientConfigService defines service discovery parameters of the webhook.
type ClientManager ¶ added in v1.12.0
type ClientManager struct {
// contains filtered or unexported fields
}
ClientManager builds REST clients to talk to webhooks. It caches the clients to avoid duplicate creation.
func NewClientManager ¶ added in v1.12.0
func NewClientManager(gv schema.GroupVersion, addToSchemaFunc func(s *runtime.Scheme) error) (ClientManager, error)
NewClientManager creates a clientManager.
func (*ClientManager) HookClient ¶ added in v1.12.0
func (cm *ClientManager) HookClient(cc ClientConfig) (*rest.RESTClient, error)
HookClient get a RESTClient from the cache, or constructs one based on the webhook configuration.
func (*ClientManager) SetAuthenticationInfoResolver ¶ added in v1.12.0
func (cm *ClientManager) SetAuthenticationInfoResolver(resolver AuthenticationInfoResolver)
SetAuthenticationInfoResolver sets the AuthenticationInfoResolver.
func (*ClientManager) SetAuthenticationInfoResolverWrapper ¶ added in v1.12.0
func (cm *ClientManager) SetAuthenticationInfoResolverWrapper(wrapper AuthenticationInfoResolverWrapper)
SetAuthenticationInfoResolverWrapper sets the AuthenticationInfoResolverWrapper.
func (*ClientManager) SetServiceResolver ¶ added in v1.12.0
func (cm *ClientManager) SetServiceResolver(sr ServiceResolver)
SetServiceResolver sets the ServiceResolver.
func (*ClientManager) Validate ¶ added in v1.12.0
func (cm *ClientManager) Validate() error
Validate checks if ClientManager is properly set up.
type ErrCallingWebhook ¶ added in v1.12.0
ErrCallingWebhook is returned for transport-layer errors calling webhooks. It represents a failure to talk to the webhook, not the webhook rejecting a request.
func (*ErrCallingWebhook) Error ¶ added in v1.12.0
func (e *ErrCallingWebhook) Error() string
type GenericWebhook ¶
type GenericWebhook struct { RestClient *rest.RESTClient // contains filtered or unexported fields }
func NewGenericWebhook ¶
func NewGenericWebhook(scheme *runtime.Scheme, codecFactory serializer.CodecFactory, kubeConfigFile string, groupVersions []schema.GroupVersion, initialBackoff time.Duration) (*GenericWebhook, error)
NewGenericWebhook creates a new GenericWebhook from the provided kubeconfig file.
func (*GenericWebhook) WithExponentialBackoff ¶
func (g *GenericWebhook) WithExponentialBackoff(webhookFn func() rest.Result) rest.Result
WithExponentialBackoff will retry webhookFn() up to 5 times with exponentially increasing backoff when it returns an error for which apierrors.SuggestsClientDelay() or apierrors.IsInternalError() returns true.
type ServiceResolver ¶ added in v1.12.0
ServiceResolver knows how to convert a service reference into an actual location.
func NewDefaultServiceResolver ¶ added in v1.12.0
func NewDefaultServiceResolver() ServiceResolver
NewDefaultServiceResolver creates a new default server resolver.