SDK to create plugins for Mach Composer
- The only major change between v1 and v2 is the addition of the
versionfield toSetComponentConfig. If this field is added to the plugin it will be compliant with the v2 version
Mach Composer utiltizes the go-plugin
package for implementing plugins. This means that mach-composer runs each
plugin in a separate process whereby communication between mach-composer and the
plugin happens via net/rpc.
Mach Composer automatically finds plugins defined in the config file by looking
for an executable named mach-composer-plugin-<name>.
A plugin exists out of three major parts:
- Setup functionality
- Processing settings (global, site or component)
- Rendering of terraform snippets
Below is a very minimal implementation of a plugin.
import (
"github.com/mach-composer/mach-composer-plugin-sdk/plugin"
"github.com/mach-composer/mach-composer-plugin-sdk/schema"
)
func MyPlugin() schema.MachComposerPlugin {
return plugin.NewPlugin(&schema.PluginSchema{
Identifier: "<name of plugin>",
})
}
func main() {
p := MyPlugin()
plugin.ServePlugin(p)
}