plugin.go
1 package plugin 2 3 // Environment is the environment passed into the plugin on init. 4 type Environment struct { 5 // Path to the IPFS repo. 6 Repo string 7 8 // The plugin's config, if specified in the 9 // Plugins.Plugins["plugin-name"].Config field of the user's go-ipfs 10 // config. See docs/plugins.md for details. 11 // 12 // This is an arbitrary JSON-like object unmarshaled into an interface{} 13 // according to https://golang.org/pkg/encoding/json/#Unmarshal. 14 Config any 15 } 16 17 // Plugin is the base interface for all kinds of go-ipfs plugins 18 // It will be included in interfaces of different Plugins 19 // 20 // Optionally, Plugins can implement io.Closer if they want to 21 // have a termination step when unloading. 22 type Plugin interface { 23 // Name should return unique name of the plugin 24 Name() string 25 26 // Version returns current version of the plugin 27 Version() string 28 29 // Init is called once when the Plugin is being loaded 30 // The plugin is passed an environment containing the path to the 31 // (possibly uninitialized) IPFS repo and the plugin's config. 32 Init(env *Environment) error 33 }