v2

package
v0.20.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 31 Imported by: 2

Documentation

Index

Constants

View Source
const PluginConfigEnv = "PLUGIN_CONFIG"

Variables

View Source
var HandshakeConfig = plugin.HandshakeConfig{
	ProtocolVersion: 1,

	MagicCookieKey:   "VCLUSTER_PLUGIN",
	MagicCookieValue: "vcluster",
}

Functions

This section is empty.

Types

type ClientHook

type ClientHook struct {
	APIVersion string   `json:"apiVersion,omitempty"`
	Kind       string   `json:"kind,omitempty"`
	Types      []string `json:"types,omitempty"`
}

type GRPCProviderPlugin

type GRPCProviderPlugin struct{}

GRPCProviderPlugin is an implementation of the github.com/hashicorp/go-plugin#Plugin and github.com/hashicorp/go-plugin#GRPCPlugin interfaces

func (*GRPCProviderPlugin) Client

func (p *GRPCProviderPlugin) Client(*plugin.MuxBroker, *rpc.Client) (interface{}, error)

Client always returns an error; we're only implementing the GRPCPlugin interface, not the Plugin interface.

func (*GRPCProviderPlugin) GRPCClient

func (p *GRPCProviderPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error)

GRPCClient always returns an error; we're only implementing the server half of the interface.

func (*GRPCProviderPlugin) GRPCServer

func (p *GRPCProviderPlugin) GRPCServer(_ *plugin.GRPCBroker, _ *grpc.Server) error

GRPCServer registers the gRPC provider server with the gRPC server that go-plugin is standing up.

func (*GRPCProviderPlugin) Server

func (p *GRPCProviderPlugin) Server(*plugin.MuxBroker) (interface{}, error)

Server always returns an error; we're only implementing the GRPCPlugin interface, not the Plugin interface.

type InitConfig

type InitConfig struct {
	Pro          InitConfigPro `json:"pro,omitempty"`
	SyncerConfig []byte        `json:"syncerConfig,omitempty"`

	WorkloadConfig     []byte `json:"workloadConfig,omitempty"`
	ControlPlaneConfig []byte `json:"controlPlaneConfig,omitempty"`

	Config []byte `json:"config,omitempty"`

	WorkingDir string `json:"workingDir,omitempty"`

	Port int `json:"port,omitempty"`

	// Legacy fields we still need to support
	Options               []byte `json:"options,omitempty"`
	CurrentNamespace      string `json:"currentNamespace,omitempty"`
	PhysicalClusterConfig []byte `json:"physicalClusterConfig,omitempty"`
}

InitConfig is the config the syncer sends to the plugin

type InitConfigPro

type InitConfigPro struct {
	Enabled  bool            `json:"enabled,omitempty"`
	Features map[string]bool `json:"features,omitempty"`
}

InitConfigPro is used to signal the plugin if vCluster.Pro is enabled and what features are allowed

type InterceptorRule added in v0.20.0

type InterceptorRule struct {
	APIGroups       []string `json:"apiGroups,omitempty"`
	Resources       []string `json:"resources,omitempty"`
	ResourceNames   []string `json:"resourceNames,omitempty"`
	NonResourceURLs []string `json:"nonResourceURLs,omitempty"`
	Verbs           []string `json:"verbs,omitempty"`
}

type Manager

type Manager struct {
	// PluginFolder where to load plugins from
	PluginFolder string

	// Plugins that were loaded
	Plugins []*vClusterPlugin

	// ClientHooks that were loaded
	ClientHooks map[plugintypes.VersionKindType][]*vClusterPlugin

	// map to track the port that needs to be targeted for the interceptors
	// structure is group>resource>verb>resourceName
	ResourceInterceptorsPorts map[string]map[string]map[string]map[string]portHandlerName
	// map to track the port that needs to be targeted for the non resource interceptors
	NonResourceInterceptorsPorts map[string]map[string]portHandlerName
	// ProFeatures are pro features to hand-over to the plugin
	ProFeatures map[string]bool
}

func NewManager

func NewManager() *Manager

func (*Manager) HasClientHooks

func (m *Manager) HasClientHooks() bool

func (*Manager) HasClientHooksForType

func (m *Manager) HasClientHooksForType(versionKindType plugintypes.VersionKindType) bool

func (*Manager) HasPlugins

func (m *Manager) HasPlugins() bool

func (*Manager) InterceptorPortForNonResourceURL added in v0.20.0

func (m *Manager) InterceptorPortForNonResourceURL(path, verb string) (bool, int, string)

InterceptorPortForNonResourceURL returns the port and handler name for the given nonResourceUrl and verb

func (*Manager) MutateObject

func (m *Manager) MutateObject(ctx context.Context, obj client.Object, hookType string, scheme *runtime.Scheme) error

func (*Manager) SetLeader

func (m *Manager) SetLeader(ctx context.Context) error

func (*Manager) Start

func (m *Manager) Start(
	ctx context.Context,
	syncerConfig *clientcmdapi.Config,
	vConfig *config.VirtualClusterConfig,
) error

func (*Manager) WithInterceptors added in v0.20.0

func (m *Manager) WithInterceptors(next http.Handler) http.Handler

type Plugin

type Plugin interface {
	// Start runs the plugin and blocks until the plugin finishes
	Start(
		ctx context.Context,
		currentNamespace, targetNamespace string,
		virtualKubeConfig *rest.Config,
		physicalKubeConfig *rest.Config,
		syncerConfig *clientcmdapi.Config,
		vConfig *config.VirtualClusterConfig,
	) error

	// SetLeader signals the plugin that the syncer acquired leadership and starts executing controllers
	SetLeader() error

	// MutateObject mutates the objects of the given version kind type
	MutateObject(ctx context.Context, obj client.Object, hookType string, scheme *runtime.Scheme) error

	// HasClientHooks returns if there are any plugin client hooks
	HasClientHooks() bool

	// HasClientHooksForType returns if there are any plugin client hooks for the given type
	HasClientHooksForType(versionKindType plugintypes.VersionKindType) bool
}

type PluginConfig

type PluginConfig struct {
	ClientHooks  []*ClientHook                `json:"clientHooks,omitempty"`
	Interceptors map[string][]InterceptorRule `json:"interceptors,omitempty"`
}

PluginConfig is the config the plugin sends back to the syncer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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