controllers

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: Apache-2.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Image

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

Image controller handles events related to Images. It starts and receives events from the informer, calling appropriate functions on our concrete services layer implementation.

func NewImage

func NewImage(imgsvc ImageSyncer) *Image

NewImage returns a new controller for Images. This controller runs image imports in parallel, at a given time we can have at max "tokens" distinct images being processed (hardcoded to 10).

func (*Image) Name

func (t *Image) Name() string

Name returns a name identifier for this controller.

func (*Image) RequiresLeaderElection

func (t *Image) RequiresLeaderElection() bool

RequiresLeaderElection returns if this controller requires or not a leader lease to run.

func (*Image) Start

func (t *Image) Start(ctx context.Context) error

Start starts the controller's event loop.

type ImageIO

type ImageIO struct {
	pb.UnimplementedImageIOServiceServer
	// contains filtered or unexported fields
}

ImageIO handles requests for pulling and pushing current image pointed by a Image.

func NewImageIO

func NewImageIO(imgexp ImagePusherPuller, usrval UserValidator) *ImageIO

NewImageIO returns a grpc handler for image Pull and Push requests. I have hardcoded what seems to be reasonable values in terms of keep alive and connection lifespan management (we may need to better tune this). The implementation here is made so we have a stateless handler. Panics if unable to load certificates.

func (*ImageIO) Name

func (t *ImageIO) Name() string

Name returns a name identifier for this controller.

func (*ImageIO) Pull

func (t *ImageIO) Pull(in *pb.Packet, stream pb.ImageIOService_PullServer) error

Pull handles an image pull through grpc. We receive a request informing what is the Image to be pulled from (namespace and name) and also a kubernetes token for authentication and authorization.

func (*ImageIO) Push

func (t *ImageIO) Push(stream pb.ImageIOService_PushServer) error

Push handles image pushes through grpc. The first message received indicates the image destination (Image's namespace and name) and a authorization token, all subsequent messages are of type Chunk where we can find a slice of bytes. We reassemble the image on disk and later on Load it into a registry.

func (*ImageIO) RequiresLeaderElection

func (t *ImageIO) RequiresLeaderElection() bool

RequiresLeaderElection returns if this controller requires or not a leader lease to run. On our case, as we are a grpc server, we do not require to be a leader in order to work properly.

func (*ImageIO) Start

func (t *ImageIO) Start(ctx context.Context) error

Start puts the grpc server online. TODO enable ssl on this listener.

type ImageImport

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

ImageImport controller handles events related to ImageImports. It starts and receives events from the informer, calling appropriate functions on our concrete services layer implementation.

func NewImageImport

func NewImageImport(tisvc ImageImportSyncer) *ImageImport

NewImageImport returns a new controller for ImageImports. This controller runs image imports in parallel, at a given time we can have at max "tokens" distinct imports being processed. Max number of parallel imports has been hardcoded to 10.

func (*ImageImport) Name

func (t *ImageImport) Name() string

Name returns a name identifier for this controller.

func (*ImageImport) RequiresLeaderElection

func (t *ImageImport) RequiresLeaderElection() bool

RequiresLeaderElection returns if this controller requires or not a leader lease to run.

func (*ImageImport) Start

func (t *ImageImport) Start(ctx context.Context) error

Start starts the controller's event loop.

type ImageImportSyncer

type ImageImportSyncer interface {
	Sync(context.Context, *imgv1b1.ImageImport) error
	Get(context.Context, string, string) (*imgv1b1.ImageImport, error)
	AddEventHandler(cache.ResourceEventHandler)
}

ImageImportSyncer abstraction exists to make testing easier. You most likely wanna see ImageImport struct under services/imageimport.go for a concrete implementation of this.

type ImageImportValidator

type ImageImportValidator interface {
	Validate(context.Context, *imgv1b1.ImageImport) error
}

ImageImportValidator is implemented in services/imageimport.go. This abstraction exists to make tests easier. It is anything capable of checking if a given ImageImport is valid (contain all needed fields and refers to a valid Image).

type ImagePusherPuller

type ImagePusherPuller interface {
	Push(context.Context, string, string, string) error
	Pull(context.Context, string, string) (*os.File, func(), error)
}

ImagePusherPuller is here to make tests easier. You may be looking for its concrete implementation in services/imageio.go. The goal of an ImagePusherPuller is to allow us to Push and Pull images to and from our mirror registry.

type ImageSyncer

type ImageSyncer interface {
	Sync(context.Context, *imgv1b1.Image) error
	Get(context.Context, string, string) (*imgv1b1.Image, error)
	AddEventHandler(cache.ResourceEventHandler)
}

ImageSyncer abstraction exists to make testing easier. You most likely wanna see Image struct under services/image.go for a concrete implementation of this.

type ImageValidator

type ImageValidator interface {
	Validate(context.Context, *imgv1b1.Image) error
}

ImageValidator is implemented in services/image.go. Validates that provided Image contain all mandatory fields.

type Metric

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

Metric is our controller for metric requests. Spawns an http metric and exposes all metrics registered on prometheus (see infra/metrics package to see what are we monitoring).

func NewMetric

func NewMetric() *Metric

NewMetric returns a new metric controller.

func (*Metric) Name

func (m *Metric) Name() string

Name returns a name identifier for this controller.

func (*Metric) RequiresLeaderElection

func (m *Metric) RequiresLeaderElection() bool

RequiresLeaderElection returns if this controller requires or not a leader lease to run.

func (*Metric) Start

func (m *Metric) Start(ctx context.Context) error

Start puts the metrics http server online.

type MutatingWebHook

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

MutatingWebHook handles Mutation requests from kubernetes api, e.g. validate Image and ImageImport objects.

func NewMutatingWebHook

func NewMutatingWebHook(tival ImageImportValidator, imgval ImageValidator) *MutatingWebHook

NewMutatingWebHook returns a web hook handler for kubernetes api mutation requests. This webhook validate Image and ImageImport objects when user saves them. This function will panic if certificates are not found under "olmCertDir". When deploying this operator using OLM the certificates will be automatically mounted in this location.

func (*MutatingWebHook) Name

func (m *MutatingWebHook) Name() string

Name returns a name identifier for this controller.

func (*MutatingWebHook) RequiresLeaderElection

func (m *MutatingWebHook) RequiresLeaderElection() bool

RequiresLeaderElection returns if this controller requires or not a leader lease to run.

func (*MutatingWebHook) Start

func (m *MutatingWebHook) Start(ctx context.Context) error

Start puts the http server online.

type UserValidator

type UserValidator interface {
	CanUpdateImages(context.Context, string, string) error
}

UserValidator validates an user can access Images in a given namespace. You might be looking for a concrete implementation of this, please look at services/user.go and you will find it.

Jump to

Keyboard shortcuts

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