mirror of
https://github.com/ipfs/kubo.git
synced 2025-05-17 23:16:11 +08:00
feat: unexport unneeded functions and add comments
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
// cmd/ipfs implements the primary CLI binary for ipfs
|
// cmd/ipfs/kubo implements the primary CLI binary for kubo
|
||||||
package kubo
|
package kubo
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@ -62,7 +62,7 @@ const (
|
|||||||
|
|
||||||
type PluginPreloader func(*loader.PluginLoader) error
|
type PluginPreloader func(*loader.PluginLoader) error
|
||||||
|
|
||||||
func LoadPlugins(repoPath string, preload PluginPreloader) (*loader.PluginLoader, error) {
|
func loadPlugins(repoPath string, preload PluginPreloader) (*loader.PluginLoader, error) {
|
||||||
plugins, err := loader.NewPluginLoader(repoPath)
|
plugins, err := loader.NewPluginLoader(repoPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("error loading plugins: %s", err)
|
return nil, fmt.Errorf("error loading plugins: %s", err)
|
||||||
@ -103,16 +103,18 @@ func BuildDefaultEnv(ctx context.Context, req *cmds.Request) (cmds.Environment,
|
|||||||
return BuildEnv(nil)(ctx, req)
|
return BuildEnv(nil)(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BuildEnv creates an environment to be used with the kubo CLI. Note: the plugin preloader should only call functions
|
||||||
|
// associated with preloaded plugins (i.e. Load).
|
||||||
func BuildEnv(pl PluginPreloader) func(ctx context.Context, req *cmds.Request) (cmds.Environment, error) {
|
func BuildEnv(pl PluginPreloader) func(ctx context.Context, req *cmds.Request) (cmds.Environment, error) {
|
||||||
return func(ctx context.Context, req *cmds.Request) (cmds.Environment, error) {
|
return func(ctx context.Context, req *cmds.Request) (cmds.Environment, error) {
|
||||||
checkDebug(req)
|
checkDebug(req)
|
||||||
repoPath, err := GetRepoPath(req)
|
repoPath, err := getRepoPath(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
log.Debugf("config path is %s", repoPath)
|
log.Debugf("config path is %s", repoPath)
|
||||||
|
|
||||||
plugins, err := LoadPlugins(repoPath, pl)
|
plugins, err := loadPlugins(repoPath, pl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -374,7 +376,7 @@ func (twe tracingWrappedExecutor) Execute(req *cmds.Request, re cmds.ResponseEmi
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetRepoPath(req *cmds.Request) (string, error) {
|
func getRepoPath(req *cmds.Request) (string, error) {
|
||||||
repoOpt, found := req.Options[corecmds.RepoDirOption].(string)
|
repoOpt, found := req.Options[corecmds.RepoDirOption].(string)
|
||||||
if found && repoOpt != "" {
|
if found && repoOpt != "" {
|
||||||
return repoOpt, nil
|
return repoOpt, nil
|
||||||
|
Reference in New Issue
Block a user