solvers

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RoutingNotSupported = errors.New("routingclass not supported by this controller")

RoutingNotSupported is used by the solvers when they supported the routingclass of the workspace they've been asked to route

Functions

func GetDiscoverableServicesForEndpoints

func GetDiscoverableServicesForEndpoints(endpoints map[string]controllerv1alpha1.EndpointList, meta DevWorkspaceMetadata) []corev1.Service

GetDiscoverableServicesForEndpoints converts the endpoint list into a set of services, each corresponding to a single discoverable endpoint from the list. Endpoints with the NoneEndpointExposure are ignored.

func GetServiceForEndpoints

func GetServiceForEndpoints(endpoints map[string]controllerv1alpha1.EndpointList, meta DevWorkspaceMetadata, includeDiscoverable bool, exposureType ...controllerv1alpha1.EndpointExposure) *corev1.Service

GetServiceForEndpoints returns a single service that exposes all endpoints of given exposure types, possibly also including the discoverable types. `nil` is returned if the service would expose no ports satisfying the provided criteria.

Types

type BasicSolver

type BasicSolver struct{}

Basic solver exposes endpoints without any authentication According to the current cluster there is different behavior: Kubernetes: use Ingresses without TLS OpenShift: use Routes with TLS enabled

func (*BasicSolver) Finalize

func (*BasicSolver) FinalizerRequired

func (s *BasicSolver) FinalizerRequired(*controllerv1alpha1.DevWorkspaceRouting) bool

func (*BasicSolver) GetExposedEndpoints

func (s *BasicSolver) GetExposedEndpoints(
	endpoints map[string]controllerv1alpha1.EndpointList,
	routingObj RoutingObjects) (exposedEndpoints map[string]controllerv1alpha1.ExposedEndpointList, ready bool, err error)

func (*BasicSolver) GetSpecObjects

func (s *BasicSolver) GetSpecObjects(routing *controllerv1alpha1.DevWorkspaceRouting, workspaceMeta DevWorkspaceMetadata) (RoutingObjects, error)

type ClusterSolver

type ClusterSolver struct {
	TLS bool
}

func (*ClusterSolver) Finalize

func (*ClusterSolver) FinalizerRequired

func (*ClusterSolver) GetExposedEndpoints

func (s *ClusterSolver) GetExposedEndpoints(
	endpoints map[string]controllerv1alpha1.EndpointList,
	routingObj RoutingObjects) (exposedEndpoints map[string]controllerv1alpha1.ExposedEndpointList, ready bool, err error)

func (*ClusterSolver) GetSpecObjects

func (s *ClusterSolver) GetSpecObjects(routing *controllerv1alpha1.DevWorkspaceRouting, workspaceMeta DevWorkspaceMetadata) (RoutingObjects, error)

type DevWorkspaceMetadata added in v0.3.0

type DevWorkspaceMetadata struct {
	DevWorkspaceId string
	Namespace      string
	PodSelector    map[string]string
}

type RoutingInvalid

type RoutingInvalid struct {
	Reason string
}

RoutingInvalid is used by the solvers to report that they were asked to route a workspace that has the correct routingclass but is invalid in some other sense - missing configuration, etc.

func (*RoutingInvalid) Error

func (e *RoutingInvalid) Error() string

type RoutingNotReady

type RoutingNotReady struct {
	Retry time.Duration
}

RoutingNotReady is used by the solvers when they are not ready to route an otherwise OK workspace. They can also suggest the duration after which to retry the workspace routing. If not specified, the retry is made after 1 second.

func (*RoutingNotReady) Error

func (*RoutingNotReady) Error() string

type RoutingObjects

type RoutingObjects struct {
	Services     []corev1.Service
	Ingresses    []networkingv1.Ingress
	Routes       []routeV1.Route
	PodAdditions *controllerv1alpha1.PodAdditions
}

type RoutingSolver

type RoutingSolver interface {
	// FinalizerRequired tells the caller if the solver requires a finalizer on the routing object.
	FinalizerRequired(routing *controllerv1alpha1.DevWorkspaceRouting) bool

	// Finalize implements the custom finalization logic required by the solver. The solver doesn't have to
	// remove any finalizer from the finalizer list on the routing. Instead just implement the custom
	// logic required for the finalization itself. If this method doesn't return any error, the finalizer
	// is automatically removed from the routing.
	Finalize(routing *controllerv1alpha1.DevWorkspaceRouting) error

	// GetSpecObjects constructs cluster routing objects which should be applied on the cluster
	// This method should return RoutingNotReady error if the solver is not ready yet to process
	// the workspace routing, RoutingInvalid error if there is a specific reason for the failure or
	// any other error.
	// The implementors can also create any additional objects not captured by the RoutingObjects struct. If that's
	// the case they are required to set the restricted access annotation on any objects created according to the
	// restricted access specified by the routing.
	GetSpecObjects(routing *controllerv1alpha1.DevWorkspaceRouting, workspaceMeta DevWorkspaceMetadata) (RoutingObjects, error)

	// GetExposedEndpoints retreives the URL for each endpoint in a devfile spec from a set of RoutingObjects.
	// Returns is a map from component ids (as defined in the devfile) to the list of endpoints for that component
	// Return value "ready" specifies if all endpoints are resolved on the cluster; if false it is necessary to retry, as
	// URLs will be undefined.
	GetExposedEndpoints(endpoints map[string]controllerv1alpha1.EndpointList, routingObj RoutingObjects) (exposedEndpoints map[string]controllerv1alpha1.ExposedEndpointList, ready bool, err error)
}

type RoutingSolverGetter

type RoutingSolverGetter interface {
	// SetupControllerManager is called during the setup of the controller and can modify the controller manager with additional
	// watches, etc., needed for the correct operation of the solver.
	SetupControllerManager(mgr *builder.Builder) error

	// HasSolver returns whether the provided routingClass is supported by this RoutingSolverGetter. Returns false if
	// calling GetSolver with routingClass will return a RoutingNotSupported error. Can be used to check if a routingClass
	// is supported without having to provide a runtime client. Note that GetSolver may still return another error, if e.g.
	// an OpenShift-only routingClass is used on a vanilla Kubernetes platform.
	HasSolver(routingClass controllerv1alpha1.DevWorkspaceRoutingClass) bool

	// GetSolver that obtains a Solver (see github.com/devfile/devworkspace-operator/controllers/controller/devworkspacerouting/solvers)
	// for a particular DevWorkspaceRouting instance. This function should return a RoutingNotSupported error if
	// the routingClass is not recognized, and any other error if the routingClass is invalid (e.g. an OpenShift-only
	// routingClass on a vanilla Kubernetes platform). Note that an empty routingClass is handled by the DevWorkspace controller itself,
	// and should not be handled by external controllers.
	GetSolver(client client.Client, routingClass controllerv1alpha1.DevWorkspaceRoutingClass) (solver RoutingSolver, err error)
}

type SolverGetter

type SolverGetter struct{}

func (*SolverGetter) GetSolver

func (*SolverGetter) HasSolver

func (_ *SolverGetter) HasSolver(routingClass controllerv1alpha1.DevWorkspaceRoutingClass) bool

func (*SolverGetter) SetupControllerManager

func (*SolverGetter) SetupControllerManager(*builder.Builder) error

Jump to

Keyboard shortcuts

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