Documentation
¶
Index ¶
- Constants
- Variables
- type ClientHook
- type GRPCProviderPlugin
- func (p *GRPCProviderPlugin) Client(*plugin.MuxBroker, *rpc.Client) (interface{}, error)
- func (p *GRPCProviderPlugin) GRPCClient(_ context.Context, _ *plugin.GRPCBroker, clientConn *grpc.ClientConn) (interface{}, error)
- func (p *GRPCProviderPlugin) GRPCServer(_ *plugin.GRPCBroker, _ *grpc.Server) error
- func (p *GRPCProviderPlugin) Server(*plugin.MuxBroker) (interface{}, error)
- type InitConfig
- type InitConfigPro
- type InterceptorRule
- type Manager
- func (m *Manager) HasClientHooks() bool
- func (m *Manager) HasClientHooksForType(versionKindType plugintypes.VersionKindType) bool
- func (m *Manager) HasPlugins() bool
- func (m *Manager) InterceptorPortForNonResourceURL(path, verb string) (bool, int, string)
- func (m *Manager) MutateObject(ctx context.Context, obj client.Object, hookType string, ...) error
- func (m *Manager) SetLeader(ctx context.Context) error
- func (m *Manager) Start(ctx context.Context, syncerConfig *clientcmdapi.Config, ...) error
- func (m *Manager) WithInterceptors(next http.Handler) http.Handler
- type Plugin
- type PluginConfig
Constants ¶
const PluginConfigEnv = "PLUGIN_CONFIG"
Variables ¶
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.
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) 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