webhook

package
v0.0.0-...-035f276 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 11, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package webhook is setting up the webhook service and it's own dependencies (e.g. cert controller, logger, metrics, etc.).

Package webhook is setting up the webhook service, and its own dependencies (e.g. cert controller, logger, metrics, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertRotatorConfiguration

type CertRotatorConfiguration struct {
	// Namespace is the namespace that the pod is running.
	Namespace string
	// SecretName matches the Secret name.
	SecretName string
	// SecretName matches the Service name.
	ServiceName string
	// WebhookName matches the MutatingWebhookConfiguration name.
	WebhookName string
	// CaName is the Ca name.
	CaName string
	// CaOrganization
	CaOrganization string
	// CertDir is the directory that the certificates are saved.
	CertDir string
}

CertRotatorConfiguration is the certRotator configuration.

type CertRotatorFactory

type CertRotatorFactory struct {
	// contains filtered or unexported fields
}

CertRotatorFactory implements ICertRotatorFactory interface. It iss factory that creates rotator.CertRotator.

func (*CertRotatorFactory) CreateCertRotator

func (factory *CertRotatorFactory) CreateCertRotator() (certRotator *rotator.CertRotator)

CreateCertRotator Creates new cert rotator

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler implements the admission.Handler interface that each webhook have to implement. Handler handles with all admission requests according to the MutatingWebhookConfiguration.

func NewHandler

func NewHandler(azdSecInfoProvider azdsecinfo.IAzdSecInfoProvider, configuration *HandlerConfiguration, instrumentationProvider instrumentation.IInstrumentationProvider, extractor admisionrequest.IExtractor) *Handler

NewHandler Constructor for Handler

func (*Handler) Handle

func (handler *Handler) Handle(ctx context.Context, req admission.Request) admission.Response

Handle processes the AdmissionRequest by invoking the underlying function.

type HandlerConfiguration

type HandlerConfiguration struct {
	// DryRun is flag that if it's true, it handles request but doesn't mutate the workLoadResource podSpec.
	DryRun                               bool
	SupportedKubernetesWorkloadResources []string
}

HandlerConfiguration configuration for handler

type ICertRotatorFactory

type ICertRotatorFactory interface {
	// CreateCertRotator Creates new cert rotator
	CreateCertRotator() (certRotator *rotator.CertRotator)
}

ICertRotatorFactory is factory of rotator.CertRotator

func NewCertRotatorFactory

func NewCertRotatorFactory(configuration *CertRotatorConfiguration) (factory ICertRotatorFactory)

NewCertRotatorFactory Creates new cert rotator factory

type IManagerFactory

type IManagerFactory interface {
	// CreateManager Initialize the manager object of the service - this object is manages the creation and registration
	// of the controllers of the server
	CreateManager() (mgr manager.Manager, err error)
}

IManagerFactory Factory to create manager.Manager

type IServerFactory

type IServerFactory interface {
	// CreateServer creates new server
	CreateServer() (server *Server, err error)
}

IServerFactory factory to create server

func NewServerFactory

func NewServerFactory(configuration *ServerConfiguration,
	managerFactory IManagerFactory,
	certRotatorFactory ICertRotatorFactory,
	webhookHandler admission.Handler,
	instrumentationProvider instrumentation.IInstrumentationProvider) (factory IServerFactory)

NewServerFactory constructor for ServerFactory

type ManagerConfiguration

type ManagerConfiguration struct {
	// Port is the port that the manager will register the server on.
	Port int
	// CertDir is the directory that the certificates are saved.
	CertDir string
}

ManagerConfiguration Factory configuration to create a manager.Manager

type ManagerFactory

type ManagerFactory struct {
	// contains filtered or unexported fields
}

ManagerFactory Factory to create manager.Manager from configuration

func NewManagerFactory

func NewManagerFactory(configuration *ManagerConfiguration, instrumentationProvider instrumentation.IInstrumentationProvider) (factory *ManagerFactory)

NewManagerFactory Constructor for ManagerFactory

func (*ManagerFactory) CreateManager

func (factory *ManagerFactory) CreateManager() (mgr manager.Manager, err error)

CreateManager Initialize the manager object of the service - this object is manages the creation and registration of the controllers of the server

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server this struct is responsible for setting up azdproxy server in the cluster.

func NewServer

func NewServer(instrumentationProvider instrumentation.IInstrumentationProvider,
	manager manager.Manager, certRotator *rotator.CertRotator,
	webhookHandler admission.Handler,
	configuration *ServerConfiguration) *Server

NewServer Server constructor

func (*Server) Run

func (server *Server) Run() (err error)

Run Starting server - this is function is called from the main (entrypoint of azdproxy) It initializes the server with all the instrumentation, initialize the controllers, and register them. There are 2 controllers - cert-controller (https://github.com/open-policy-agent/cert-controller) that manages the certificates of the server and the mutation webhook server that is registered with the AzDSecInfo Handler.

type ServerConfiguration

type ServerConfiguration struct {
	// Path matches the MutatingWebhookConfiguration clientConfig path
	Path string
	// EnableCertRotation is flag that indicates whether cert rotator should run
	EnableCertRotation bool
}

ServerConfiguration configuration

type ServerFactory

type ServerFactory struct {
	// contains filtered or unexported fields
}

ServerFactory Factory to create a Server using configuration and manager.

func (*ServerFactory) CreateServer

func (factory *ServerFactory) CreateServer() (server *Server, err error)

CreateServer creates new server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL