v2

package
v0.19.5 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: Apache-2.0 Imports: 25 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"`
	PhysicalClusterConfig []byte        `json:"physicalClusterConfig,omitempty"`
	SyncerConfig          []byte        `json:"syncerConfig,omitempty"`
	CurrentNamespace      string        `json:"currentNamespace,omitempty"`
	Options               []byte        `json:"options,omitempty"`
	WorkingDir            string        `json:"workingDir,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 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

	// 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) 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,
	currentNamespace string,
	physicalKubeConfig *rest.Config,
	syncerConfig *clientcmdapi.Config,
	options *options.VirtualClusterOptions,
) error

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,
		options *options.VirtualClusterOptions,
	) 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"`
}

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