feat: unexport unneeded functions and add comments
Adin Schmahmann committed
Dec 19, 2023 at 19:52 UTC
e503c843b8174382e69cdfdcca25f7caef9f462b
1 file changed
+7
-5
cmd/ipfs/kubo/start.go
+7
-5
@@ -1,4 +1,4 @@
1
-// cmd/ipfs implements the primary CLI binary for ipfs
1
+// cmd/ipfs/kubo implements the primary CLI binary for kubo
2
package kubo
3
4
import (
@@ -62,7 +62,7 @@ const (
62
63
type PluginPreloader func(*loader.PluginLoader) error
64
65
-func LoadPlugins(repoPath string, preload PluginPreloader) (*loader.PluginLoader, error) {
65
+func loadPlugins(repoPath string, preload PluginPreloader) (*loader.PluginLoader, error) {
66
plugins, err := loader.NewPluginLoader(repoPath)
67
if err != nil {
68
return nil, fmt.Errorf("error loading plugins: %s", err)
@@ -103,16 +103,18 @@ func BuildDefaultEnv(ctx context.Context, req *cmds.Request) (cmds.Environment,
103
return BuildEnv(nil)(ctx, req)
104
}
105
106
+// BuildEnv creates an environment to be used with the kubo CLI. Note: the plugin preloader should only call functions
107
+// associated with preloaded plugins (i.e. Load).
108
func BuildEnv(pl PluginPreloader) func(ctx context.Context, req *cmds.Request) (cmds.Environment, error) {
109
return func(ctx context.Context, req *cmds.Request) (cmds.Environment, error) {
110
checkDebug(req)
109
- repoPath, err := GetRepoPath(req)
111
+ repoPath, err := getRepoPath(req)
112
if err != nil {
113
return nil, err
114
}
115
log.Debugf("config path is %s", repoPath)
116
115
- plugins, err := LoadPlugins(repoPath, pl)
117
+ plugins, err := loadPlugins(repoPath, pl)
118
if err != nil {
119
return nil, err
120
}
@@ -374,7 +376,7 @@ func (twe tracingWrappedExecutor) Execute(req *cmds.Request, re cmds.ResponseEmi
376
return err
377
}
378
377
-func GetRepoPath(req *cmds.Request) (string, error) {
379
+func getRepoPath(req *cmds.Request) (string, error) {
380
repoOpt, found := req.Options[corecmds.RepoDirOption].(string)
381
if found && repoOpt != "" {
382
return repoOpt, nil