Documentation
¶
Overview ¶
Package handler implements the http.HandlerFunc for mutating pod requests
Index ¶
- func Apply(h http.Handler, middlewares ...Middleware) http.Handler
- func ShutdownFromContext(ctx context.Context, server *http.Server, timeout time.Duration) (<-chan struct{}, <-chan error)
- type Middleware
- type Modifier
- type ModifierOpt
- func WithAnnotationDomain(domain string) ModifierOpt
- func WithContainerCredentialsConfig(config containercredentials.Config) ModifierOpt
- func WithMountPath(mountpath string) ModifierOpt
- func WithRegion(region string) ModifierOpt
- func WithSALookupGraceTime(saLookupGraceTime time.Duration) ModifierOpt
- func WithServiceAccountCache(c cache.ServiceAccountCache) ModifierOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
func Apply(h http.Handler, middlewares ...Middleware) http.Handler
Apply wraps a list of middlewares around a handler and returns it
func ShutdownFromContext ¶ added in v0.4.0
func ShutdownFromContext(ctx context.Context, server *http.Server, timeout time.Duration) (<-chan struct{}, <-chan error)
ShutdownFromContext gracefully shuts down an HTTP server when the provided context is cancelled. It waits for ctx to be cancelled, then attempts a graceful shutdown with the given timeout. If graceful shutdown fails, it will attempt to force close the server.
Parameters:
- ctx: Context to watch for cancellation signal
- server: HTTP server to shutdown
- timeout: Maximum time to wait for graceful shutdown
Returns:
- <-chan struct{}: Closed when shutdown process completes
- <-chan error: Receives shutdown error if shutdown wasn't graceful (nil on success)
Types ¶
type Middleware ¶
Middleware is a type for decorating requests.
func InstrumentRoute ¶
func InstrumentRoute() Middleware
InstrumentRoute is a middleware for adding the following metrics for each route:
# Counter
http_request_count{"verb", "path", "code}
# Histogram
http_request_latencies{"verb", "path"}
# Summary
http_request_duration_microseconds{"verb", "path", "code}
func Logging ¶
func Logging() Middleware
type Modifier ¶
type Modifier struct {
AnnotationDomain string
MountPath string
Region string
Cache cache.ServiceAccountCache
ContainerCredentialsConfig containercredentials.Config
// contains filtered or unexported fields
}
Modifier holds configuration values for pod modifications
func NewModifier ¶
func NewModifier(random *rand.Rand, opts ...ModifierOpt) *Modifier
NewModifier returns a Modifier with default values
func (*Modifier) Handle ¶
func (m *Modifier) Handle(w http.ResponseWriter, r *http.Request)
Handle handles pod modification requests
func (*Modifier) MutatePod ¶
func (m *Modifier) MutatePod(ar *v1beta1.AdmissionReview) *v1beta1.AdmissionResponse
MutatePod takes a AdmissionReview, mutates the pod, and returns an AdmissionResponse
type ModifierOpt ¶
type ModifierOpt func(*Modifier)
ModifierOpt is an option type for setting up a Modifier
func WithAnnotationDomain ¶ added in v0.3.0
func WithAnnotationDomain(domain string) ModifierOpt
WithAnnotationDomain adds an annotation domain
func WithContainerCredentialsConfig ¶ added in v0.5.0
func WithContainerCredentialsConfig(config containercredentials.Config) ModifierOpt
WithContainerCredentialsConfig sets the modifier ContainerCredentialsConfig
func WithMountPath ¶
func WithMountPath(mountpath string) ModifierOpt
WithMountPath sets the modifier mountPath
func WithRegion ¶ added in v0.3.0
func WithRegion(region string) ModifierOpt
WithRegion sets the modifier region
func WithSALookupGraceTime ¶ added in v0.5.8
func WithSALookupGraceTime(saLookupGraceTime time.Duration) ModifierOpt
WithSALookupGraceTime sets the grace time to wait for service accounts to appear in cache
func WithServiceAccountCache ¶
func WithServiceAccountCache(c cache.ServiceAccountCache) ModifierOpt
WithServiceAccountCache sets the modifiers cache