The official Software Development Kit (SDK) for creating MOPS plugins.
The MOPS Plugin SDK provides a stable, version-controlled interface for developing plugins that integrate with the MOPS (Micro Operations Platform System). This SDK ensures compatibility across MOPS versions and provides a consistent development experience.
- 🔌 Plugin Interface: Standardized plugin interface for MOPS integration
- 🎯 CLI Commands: Support for command-line interface commands
- 🖥️ Interactive Functions: UI-based interactive plugin operations
- 📊 Dynamic Providers: Context-aware menu and action providers
- 🔄 Version Compatibility: Automatic compatibility checking
- 📝 Type Safety: Comprehensive type definitions and interfaces
go mod init your-plugin-name
go get github.com/totmicro/mops-plugin-sdk@latest
package main
import (
"context"
"github.com/totmicro/mops-plugin-sdk/interfaces"
"github.com/totmicro/mops-plugin-sdk/types"
)
type MyPlugin struct {
config *types.PluginConfig
}
// Plugin Interface Implementation
func (p *MyPlugin) GetName() string {
return "my-plugin"
}
func (p *MyPlugin) GetVersion() string {
return "1.0.0"
}
func (p *MyPlugin) GetDescription() string {
return "My awesome MOPS plugin"
}
func (p *MyPlugin) GetAPIVersion() types.APIVersion {
return interfaces.CurrentSDKVersion
}
func (p *MyPlugin) Initialize(config *types.PluginConfig) error {
p.config = config
return nil
}
func (p *MyPlugin) GetProviders() []interfaces.Provider {
return []interfaces.Provider{}
}
func (p *MyPlugin) GetExecutors() []interfaces.ActionExecutor {
return []interfaces.ActionExecutor{}
}
func (p *MyPlugin) Cleanup() error {
return nil
}
// CLI Commands (optional)
func (p *MyPlugin) GetCLICommands() []interfaces.CLICommand {
return []interfaces.CLICommand{
{
Name: "my-plugin-hello",
Description: "Say hello from my plugin",
Usage: "mops my-plugin-hello [name]",
Handler: p.helloCLI,
},
}
}
func (p *MyPlugin) helloCLI(args []string) error {
name := "World"
if len(args) > 0 {
name = args[0]
}
fmt.Printf("Hello %s from my plugin!\n", name)
return nil
}
// Interactive Functions (optional)
func (p *MyPlugin) GetInteractiveFunctions() []interfaces.InteractiveFunction {
return []interfaces.InteractiveFunction{
{
Name: "my-plugin-interactive-hello",
Description: "Interactive hello",
Handler: p.helloInteractive,
},
}
}
func (p *MyPlugin) helloInteractive(ctx context.Context, outputChan chan<- string, inputChan <-chan string, params map[string]interface{}) error {
outputChan <- "Hello from interactive mode!"
return nil
}
// Required export for MOPS
func GetPlugin() interfaces.Plugin {
return &MyPlugin{}
}
go build -buildmode=plugin -o my-plugin.so main.go
Plugin
: Main plugin interface with lifecycle methodsCLIProvider
: For plugins that provide CLI commandsInteractiveProvider
: For plugins with UI interactionsDynamicProvider
: For context-aware menu generationFullCapabilityPlugin
: Combines all interface capabilities
Provider
: Menu entry generationActionExecutor
: Action execution handlingDynamicProvider
: Runtime menu generation
The SDK uses semantic versioning for API compatibility:
- Major version: Breaking changes to the plugin interface
- Minor version: New features, backward compatible
- Patch version: Bug fixes, backward compatible
Current API Version: 1.0.0
Check out example plugins in the main MOPS repository:
sdk-plugins/example-sdk-plugin/
- Basic plugin examplesdk-plugins/saml2aws-sdk/
- Advanced plugin with CLI and UIsdk-plugins/samples-sdk/
- Interactive demonstrations
For maintainable plugins, follow the recommended structure:
your-plugin/
├── main.go # Plugin interface implementation
├── core.go # Shared business logic
├── go.mod # Go module definition
└── README.md # Plugin documentation
Separate your business logic from plugin interfaces:
// core.go - Shared business logic
type MyService struct{}
func (s *MyService) DoSomething() error {
// Business logic here
return nil
}
// main.go - Plugin interfaces
func (p *MyPlugin) cliCommand(args []string) error {
service := &MyService{}
return service.DoSomething()
}
func (p *MyPlugin) interactiveFunction(ctx context.Context, outputChan chan<- string, inputChan <-chan string, params map[string]interface{}) error {
service := &MyService{}
return service.DoSomething()
}
This SDK is part of the MOPS project. For contributions and issues, please refer to the main MOPS repository.
This project is licensed under the same terms as the main MOPS project.
MOPS Plugin SDK - Build powerful, compatible plugins for the MOPS platform.