-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6613 from ipfs/feat/plugin-config
plugins: add support for plugin configs
- Loading branch information
Showing
15 changed files
with
156 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
package plugin | ||
|
||
// Environment is the environment passed into the plugin on init. | ||
type Environment struct { | ||
// Path to the IPFS repo. | ||
Repo string | ||
|
||
// The plugin's config, if specified. | ||
Config interface{} | ||
} | ||
|
||
// Plugin is base interface for all kinds of go-ipfs plugins | ||
// It will be included in interfaces of different Plugins | ||
type Plugin interface { | ||
// Name should return unique name of the plugin | ||
Name() string | ||
|
||
// Version returns current version of the plugin | ||
Version() string | ||
|
||
// Init is called once when the Plugin is being loaded | ||
Init() error | ||
// The plugin is passed an environment containing the path to the | ||
// (possibly uninitialized) IPFS repo and the plugin's config. | ||
Init(env *Environment) error | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/ipfs/go-ipfs/plugin" | ||
) | ||
|
||
var Plugins = []plugin.Plugin{ | ||
&testPlugin{}, | ||
} | ||
|
||
var _ = Plugins // used | ||
|
||
type testPlugin struct{} | ||
|
||
func (*testPlugin) Name() string { | ||
return "test-plugin" | ||
} | ||
|
||
func (*testPlugin) Version() string { | ||
return "0.1.0" | ||
} | ||
|
||
func (*testPlugin) Init(env *plugin.Environment) error { | ||
fmt.Fprintf(os.Stderr, "testplugin %s\n", env.Repo) | ||
fmt.Fprintf(os.Stderr, "testplugin %v\n", env.Config) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters