Documentation ¶
Index ¶
- Constants
- Variables
- func FromUnstructured(u map[string]interface{}, obj interface{}) error
- func ServePlugin(name string, pl PluginService)
- func ToUnstructured(obj interface{}, gvk schema.GroupVersionKind) (*unstructured.Unstructured, error)
- type CredentialsMethodExec
- type Plugin
- type PluginClient
- func (g *PluginClient) Convert(req PluginRequest) *PluginResponse
- func (g *PluginClient) Default() *PluginResponseDefault
- func (g *PluginClient) GetCredentialsMethod(req PluginRequestCredentialsMethod) *PluginResponseCredentialsMethod
- func (g *PluginClient) Status(req PluginRequest) *PluginResponseStatus
- func (g *PluginClient) Types() *PluginResponse
- func (g *PluginClient) ValidateCreate(req PluginRequest) *PluginResponseValidation
- func (g *PluginClient) ValidateDelete(req PluginRequest) *PluginResponseValidation
- func (g *PluginClient) ValidateUpdate(req PluginRequest) *PluginResponseValidation
- type PluginRequest
- func (pl *PluginRequest) AddObject(o *unstructured.Unstructured)
- func (pl *PluginRequest) GetLimits() (*v1.ResourceList, error)
- func (pl *PluginRequest) GetObjects() []*unstructured.Unstructured
- func (pl *PluginRequest) RenderTemplate(tpl string) (*TemplatedValue, error)
- func (pl *PluginRequest) SetLimits(limits *v1.ResourceList) error
- func (pl *PluginRequest) SetObjects(objs []*unstructured.Unstructured)
- type PluginRequestCredentialsMethod
- type PluginRequestEmpty
- type PluginResponse
- type PluginResponseCredentialsMethod
- type PluginResponseDefault
- type PluginResponseStatus
- type PluginResponseValidation
- type PluginServer
- func (s *PluginServer) Convert(req PluginRequest, resp *PluginResponse) error
- func (s *PluginServer) Default(_ PluginRequestEmpty, resp *PluginResponseDefault) error
- func (s *PluginServer) GetCredentialsMethod(req PluginRequestCredentialsMethod, resp *PluginResponseCredentialsMethod) error
- func (s *PluginServer) Status(req PluginRequest, resp *PluginResponseStatus) error
- func (s *PluginServer) Types(_ PluginRequestEmpty, resp *PluginResponse) error
- func (s *PluginServer) ValidateCreate(req PluginRequest, resp *PluginResponseValidation) error
- func (s *PluginServer) ValidateDelete(req PluginRequest, resp *PluginResponseValidation) error
- func (s *PluginServer) ValidateUpdate(req PluginRequest, resp *PluginResponseValidation) error
- type PluginService
- type TemplatedValue
Constants ¶
const ( TCPproto protocol = "tcp" HTTPproto protocol = "http" )
Variables ¶
var HandshakeConfig = plugin.HandshakeConfig{
ProtocolVersion: 1,
MagicCookieKey: "KUBERLOGIC_SERVICE_PLUGIN",
MagicCookieValue: "com.kuberlogic.service.plugin",
}
HandshakeConfig are used to just do a basic handshake between a plugin and host. If the handshake fails, a user friendly error is shown. This prevents users from executing bad plugins or executing a plugin directory. It is a UX feature, not a security feature.
Functions ¶
func FromUnstructured ¶
func ServePlugin ¶
func ServePlugin(name string, pl PluginService)
func ToUnstructured ¶
func ToUnstructured(obj interface{}, gvk schema.GroupVersionKind) (*unstructured.Unstructured, error)
Types ¶
type CredentialsMethodExec ¶
type CredentialsMethodExec struct { PodSelector v12.LabelSelector Container string Command []string }
type Plugin ¶
type Plugin struct { // Impl Injection Impl PluginService }
This is the implementation of plugin.Plugin so we can serve/consume this
This has two methods: Server must return an RPC server for this plugin type. We construct a PluginServer for this.
Client must return an implementation of our interface that communicates over an RPC client. We return PluginClient for this.
Ignore MuxBroker. That is used to create more multiplexed streams on our plugin connection and is a more advanced use case.
type PluginClient ¶
type PluginClient struct {
// contains filtered or unexported fields
}
Here is an implementation that talks over RPC
func (*PluginClient) Convert ¶
func (g *PluginClient) Convert(req PluginRequest) *PluginResponse
func (*PluginClient) Default ¶
func (g *PluginClient) Default() *PluginResponseDefault
func (*PluginClient) GetCredentialsMethod ¶
func (g *PluginClient) GetCredentialsMethod(req PluginRequestCredentialsMethod) *PluginResponseCredentialsMethod
func (*PluginClient) Status ¶
func (g *PluginClient) Status(req PluginRequest) *PluginResponseStatus
func (*PluginClient) Types ¶
func (g *PluginClient) Types() *PluginResponse
func (*PluginClient) ValidateCreate ¶
func (g *PluginClient) ValidateCreate(req PluginRequest) *PluginResponseValidation
func (*PluginClient) ValidateDelete ¶
func (g *PluginClient) ValidateDelete(req PluginRequest) *PluginResponseValidation
func (*PluginClient) ValidateUpdate ¶
func (g *PluginClient) ValidateUpdate(req PluginRequest) *PluginResponseValidation
type PluginRequest ¶
type PluginRequest struct { // Requested service Name Name string // Namespace where the service object must be located Namespace string // Optional. Host is address by which service should be available. Host string // Service Replicas Replicas int32 // Requested service Version Version string // If a service should be exposed via TLS Insecure bool // TLSSecretName is a Kubernetes secret that contains tls.key / tls.crt fields. Must reside in the same namespace TLSSecretName string // Service resource Limits. Manipulated via SetLimits / GetLimits methods. Limits []byte // Service will use StorageClass / IngressClass for volume / ingress or default if empty StorageClass string IngressClass string // Additional Parameters Parameters map[string]interface{} // Credentials Credentials map[string]string // Objects contains a list of service related objects Objects []*unstructured.Unstructured }
func (*PluginRequest) AddObject ¶
func (pl *PluginRequest) AddObject(o *unstructured.Unstructured)
func (*PluginRequest) GetLimits ¶
func (pl *PluginRequest) GetLimits() (*v1.ResourceList, error)
func (*PluginRequest) GetObjects ¶
func (pl *PluginRequest) GetObjects() []*unstructured.Unstructured
func (*PluginRequest) RenderTemplate ¶
func (pl *PluginRequest) RenderTemplate(tpl string) (*TemplatedValue, error)
func (*PluginRequest) SetLimits ¶
func (pl *PluginRequest) SetLimits(limits *v1.ResourceList) error
func (*PluginRequest) SetObjects ¶
func (pl *PluginRequest) SetObjects(objs []*unstructured.Unstructured)
type PluginRequestCredentialsMethod ¶
type PluginRequestCredentialsMethod struct { // service Name Name string // Credentials Data Data map[string]string }
func (*PluginRequestCredentialsMethod) RenderTemplate ¶
func (m *PluginRequestCredentialsMethod) RenderTemplate(tpl string) (*TemplatedValue, error)
type PluginRequestEmpty ¶
type PluginRequestEmpty struct{}
type PluginResponse ¶
type PluginResponse struct { Objects []*unstructured.Unstructured Protocol protocol Service string Err string }
func ResponseFromObject ¶
func ResponseFromObject(object client.Object, gvk schema.GroupVersionKind, service string, protocol protocol) *PluginResponse
func (*PluginResponse) AddUnstructuredObject ¶
func (pl *PluginResponse) AddUnstructuredObject(object client.Object, gvk schema.GroupVersionKind) error
func (*PluginResponse) Error ¶
func (pl *PluginResponse) Error() error
type PluginResponseCredentialsMethod ¶
type PluginResponseCredentialsMethod struct { Method string // exec, etc Exec CredentialsMethodExec Err string }
type PluginResponseDefault ¶
type PluginResponseDefault struct { Replicas int32 Version string Host string // *v1.ResourceList Limits []byte Parameters map[string]interface{} Err string }
func (*PluginResponseDefault) Error ¶
func (pl *PluginResponseDefault) Error() error
func (*PluginResponseDefault) GetLimits ¶
func (pl *PluginResponseDefault) GetLimits() *v1.ResourceList
func (*PluginResponseDefault) SetLimits ¶
func (pl *PluginResponseDefault) SetLimits(limits *v1.ResourceList) error
type PluginResponseStatus ¶
func (*PluginResponseStatus) Error ¶
func (pl *PluginResponseStatus) Error() error
type PluginResponseValidation ¶
type PluginResponseValidation struct {
Err string
}
func (*PluginResponseValidation) Error ¶
func (pl *PluginResponseValidation) Error() error
type PluginServer ¶
type PluginServer struct { // This is the real implementation Impl PluginService }
Here is the RPC server that PluginClient talks to, conforming to the requirements of net/rpc
func (*PluginServer) Convert ¶
func (s *PluginServer) Convert(req PluginRequest, resp *PluginResponse) error
func (*PluginServer) Default ¶
func (s *PluginServer) Default(_ PluginRequestEmpty, resp *PluginResponseDefault) error
func (*PluginServer) GetCredentialsMethod ¶
func (s *PluginServer) GetCredentialsMethod(req PluginRequestCredentialsMethod, resp *PluginResponseCredentialsMethod) error
func (*PluginServer) Status ¶
func (s *PluginServer) Status(req PluginRequest, resp *PluginResponseStatus) error
func (*PluginServer) Types ¶
func (s *PluginServer) Types(_ PluginRequestEmpty, resp *PluginResponse) error
func (*PluginServer) ValidateCreate ¶
func (s *PluginServer) ValidateCreate(req PluginRequest, resp *PluginResponseValidation) error
func (*PluginServer) ValidateDelete ¶
func (s *PluginServer) ValidateDelete(req PluginRequest, resp *PluginResponseValidation) error
func (*PluginServer) ValidateUpdate ¶
func (s *PluginServer) ValidateUpdate(req PluginRequest, resp *PluginResponseValidation) error
type PluginService ¶
type PluginService interface { Convert(req PluginRequest) *PluginResponse Status(req PluginRequest) *PluginResponseStatus Types() *PluginResponse Default() *PluginResponseDefault ValidateCreate(req PluginRequest) *PluginResponseValidation ValidateUpdate(req PluginRequest) *PluginResponseValidation ValidateDelete(req PluginRequest) *PluginResponseValidation GetCredentialsMethod(req PluginRequestCredentialsMethod) *PluginResponseCredentialsMethod }
PluginService is the interface that we're exposing as a plugin.