Creating a Plugin¶
0 Thanks for Contributing!¶
First, please read our CONTRIBUTING doc.
1 Scaffolding Automagically¶
dtm develop create-plugin --name=YOUR-PLUGIN-NAME , and dtm will automatically generate the following file.
This is the only main entrance to the plugin code.
You do not need to change this file. If you want, feel free to submit a pull request to change the plugin template directly.
This is the automatically generated plugin documentation.
Although dtm is automagic, but it can’t read your mind. I’m afraid that you will have to write your own doc.
Please fill in the main logic of the plugin here.
You can check out our Standard Go Project Layout document for detailed instruction on the project layout.
Each plugin needs to satisfy all the interfaces defined in the plugin engine.
At the moment, there are 4 interfaces, which might be subject to change. Currently, the 4 interfaces are:
2.2 Return Value¶
Update interfaces return two values
(statemanager.ResourceStatus, error); the first being the "state".
Delete interface returns two values
(bool, error). It returns
(true, nil) if there is no error; otherwise
(false, error) will be returned.
If no error occurred, the return value would be
(true, nil). Otherwise, the result would be
3 How does plugin work?¶
DevStream uses go plugin to implement custom DevOps plugins.
When you execute a command which calls any of the interfaces(
Delete), devstream's pluginengine will call the
plugin.Lookup("DevStreamPlugin") function to load the plugin, get the variable
DevStreamPlugin that implements the
DevStreamPlugin interface, and then you can call the corresponding plugin logic functions. This is why it is not recommended to modify the
/cmd/plugin/YOUR-PLUGIN-NAME/main.go file directly.
/cmd/plugin/YOUR-PLUGIN-NAME/main.go file will not be executed, it is only used to avoid the golangci-lint error.