handlers

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseHandler

type BaseHandler interface {
	// An entry point to the handler. Takes care of initializing / updating the resource.
	Handle(context.Context) error
	// Get the subset unique name for this handler
	GetSubset() string
}

Common functionality for SRHandler and MRHandler

type DeploymentHandler

type DeploymentHandler struct {
	client.Client
	// The unique name of the deployment we need to handle
	UniqueName string
	// The unique version of the deployment we need to handle
	UniqueVersion string
	// The name of the subset/consumer as it appears in the Status map
	SubsetName string
	// THe owner of the deployment we need to handle (e.g., to configure watches)
	Owner types.NamespacedName
	// The deployment we should use as base
	BaseDeployment *appsv1.Deployment
	// Is it a Consumer or Subset?
	DeploymentType riskifiedv1alpha1.SubsetOrConsumer
	// A list of labels to be removed from the overriding deployment
	LabelsToRemove []string
	// The version label to use
	VersionLabel string
	// Status handler (to be able to update status)
	StatusManager *model.StatusManager
	// The DynamicEnv matchers
	Matches []riskifiedv1alpha1.IstioMatch
	// An indicator whether the current deployment is updating (as opposed to initializing).
	Updating bool
	// The subset that contains the data of our deployment
	Subset riskifiedv1alpha1.Subset
	Log    logr.Logger
}

A handler for managing Deployments manipulations.

func NewDeploymentHandler added in v0.2.0

func NewDeploymentHandler(
	subsetData model.DynamicEnvReconcileData,
	client client.Client,
	dt riskifiedv1alpha1.SubsetOrConsumer,
	labelsToRemove []string,
	versionLabel string,
) *DeploymentHandler

Initializes DeploymentHandler with provided and default values

func (*DeploymentHandler) ApplyStatus

func (*DeploymentHandler) GetStatus

func (*DeploymentHandler) GetSubset

func (h *DeploymentHandler) GetSubset() string

func (*DeploymentHandler) Handle

func (h *DeploymentHandler) Handle(ctx context.Context) error

Handles creation and manipulation of related Deployments.

func (*DeploymentHandler) UpdateIfRequired

func (h *DeploymentHandler) UpdateIfRequired(ctx context.Context) error

type DestinationRuleHandler

type DestinationRuleHandler struct {
	client.Client
	// The unique name of the target DestinationRule
	UniqueName string
	// The unique version of the target DestinationRule
	UniqueVersion string
	// The namespace of the target DestinationRule
	Namespace string
	// The name of the subset/consumer as it appears in the Status map
	SubsetName string
	// The version label
	VersionLabel string
	// The version that gets the default route
	DefaultVersion string
	// Status handler (to be able to update status)
	StatusManager *model.StatusManager
	// The host name of the service that points to the Deployment specified in
	// the subset.
	ServiceHosts []string
	// The name/namespace of the DynamicEnv that launches this DestinationRule
	Owner types.NamespacedName
	Log   logr.Logger
	// contains filtered or unexported fields
}

A handler for managing DestinationRule manipulations.

func NewDestinationRuleHandler added in v0.2.0

func NewDestinationRuleHandler(
	subsetData model.DynamicEnvReconcileData,
	versionLabel,
	defaultVersion string,
	serviceHosts []string,
	client client.Client,
) *DestinationRuleHandler

func (*DestinationRuleHandler) ApplyStatus

func (*DestinationRuleHandler) GetHosts

func (h *DestinationRuleHandler) GetHosts() []string

func (*DestinationRuleHandler) GetStatus

func (h *DestinationRuleHandler) GetStatus(ctx context.Context) (statuses []riskifiedv1alpha1.ResourceStatus, err error)

GetStatus here can only return missing or running is there is no real status for DestinationRule, just whether it exists or missing.

func (*DestinationRuleHandler) GetSubset

func (h *DestinationRuleHandler) GetSubset() string

func (*DestinationRuleHandler) Handle

Handles creation and manipulation of related DestinationRules.

type IgnoredMissing

type IgnoredMissing struct{}

IgnoredMissing should indicate an acceptable missing resource (e.g., missing DR per hostname)

func (IgnoredMissing) Error

func (im IgnoredMissing) Error() string

type MRHandler

type MRHandler interface {
	BaseHandler
	// Computes the status of all the services which are affected by this handler. It doesn't change
	// anything, just returns the found statuses.
	GetStatus(ctx context.Context) ([]riskifiedv1alpha1.ResourceStatus, error)
	// Apply the provided status to the DynamicEnvironment.
	ApplyStatus(context.Context, []riskifiedv1alpha1.ResourceStatus) error
	/// GetHosts returns non-missing hosts.
	GetHosts() []string
}

MultiResourceHandler is a spacial kind of Handler as it may affect several resources.

type SRHandler

type SRHandler interface {
	BaseHandler
	// Computes what the current status of the resource should be. It does not
	// update the status, just computes what the current status should be.
	GetStatus(ctx context.Context) (riskifiedv1alpha1.ResourceStatus, error)
	// Apply the provided status to the DynamicEnvironment.
	ApplyStatus(context.Context, riskifiedv1alpha1.ResourceStatus) error
}

A SingleResourceHandler for any of the resources we manage in DynamicEnv controller.

type VirtualServiceHandler

type VirtualServiceHandler struct {
	client.Client
	Identifier    types.NamespacedName
	UniqueName    string
	UniqueVersion string
	Namespace     string
	// The name of the subset/consumer as it appears in the Status map
	SubsetName     string
	RoutePrefix    string
	ServiceHosts   []string
	DefaultVersion string
	Matches        []riskifiedv1alpha1.IstioMatch
	StatusManager  *model.StatusManager
	Log            logr.Logger
	// contains filtered or unexported fields
}

A handler for managing VirtualService manipulations.

func NewVirtualServiceHandler added in v0.2.0

func NewVirtualServiceHandler(
	subsetData model.DynamicEnvReconcileData,
	serviceHosts []string,
	defaultVersion string,
	client client.Client,
) *VirtualServiceHandler

Initializes VirtualServiceHandler with provided and default values

func (*VirtualServiceHandler) ApplyStatus

func (*VirtualServiceHandler) GetHosts

func (h *VirtualServiceHandler) GetHosts() []string

func (*VirtualServiceHandler) GetStatus

func (*VirtualServiceHandler) GetSubset

func (h *VirtualServiceHandler) GetSubset() string

func (*VirtualServiceHandler) Handle

func (h *VirtualServiceHandler) Handle(ctx context.Context) error

Fetches related Virtual Services and manipulates them accordingly.

Jump to

Keyboard shortcuts

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