Skip to content

Commit

Permalink
plugin: support system-wide plugins
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <[email protected]>
  • Loading branch information
magik6k committed Oct 13, 2017
1 parent e7acb96 commit 9ee628d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
11 changes: 6 additions & 5 deletions Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,12 @@ help:
@echo ''
@echo 'BUILD TARGETS:'
@echo ''
@echo ' all - print this help message'
@echo ' build - Build binary at ./cmd/ipfs/ipfs'
@echo ' nofuse - Build binary with no fuse support'
@echo ' install - Build binary and install into $$GOPATH/bin'
# @echo ' dist_install - TODO: c.f. ./cmd/ipfs/dist/README.md'
@echo ' all - print this help message'
@echo ' build - Build binary at ./cmd/ipfs/ipfs'
@echo ' nofuse - Build binary with no fuse support'
@echo ' install - Build binary and install into $$GOPATH/bin'
# @echo ' dist_install - TODO: c.f. ./cmd/ipfs/dist/README.md'
@echo ' build_plugins - Build plugin binaries'
@echo ''
@echo 'CLEANING TARGETS:'
@echo ''
Expand Down
5 changes: 4 additions & 1 deletion cmd/ipfs/Rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ PATH := $(realpath $(d)):$(PATH)
# DEPS_OO_$(d) += merkledag/pb/merkledag.pb.go namesys/pb/namesys.pb.go
# DEPS_OO_$(d) += pin/internal/pb/header.pb.go unixfs/pb/unixfs.pb.go

$(d)_flags =-ldflags="-X "github.com/ipfs/go-ipfs/repo/config".CurrentCommit=$(shell git rev-parse --short HEAD)"
CONFIG_COMMIT ?= github.com/ipfs/go-ipfs/repo/config.CurrentCommit=$(shell git rev-parse --short HEAD)
CONFIG_PLUGIN_PATH ?= github.com/ipfs/go-ipfs/repo/config.SystemPluginPath=${PLUGIN_PATH}

$(d)_flags =-ldflags="-X ${CONFIG_COMMIT} -X ${CONFIG_PLUGIN_PATH}"

$(IPFS_BIN_$(d)): GOFLAGS += $(cmd/ipfs_flags)

Expand Down
10 changes: 8 additions & 2 deletions cmd/ipfs/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,17 @@ func callCommand(ctx context.Context, req cmds.Request, root *cmds.Command, cmd
} else {
log.Debug("executing command locally")

pluginpath := filepath.Join(req.InvocContext().ConfigRoot, "plugins")
if _, err := loader.LoadPlugins(pluginpath); err != nil {
pluginPath := filepath.Join(req.InvocContext().ConfigRoot, "plugins")
if _, err := loader.LoadPlugins(pluginPath); err != nil {
return nil, err
}

if config.SystemPluginPath != "" {
if _, err := loader.LoadPlugins(config.SystemPluginPath); err != nil {
return nil, err
}
}

err := req.SetRootContext(ctx)
if err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions repo/config/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ package config
// CurrentCommit is the current git commit, this is set as a ldflag in the Makefile
var CurrentCommit string

// SystemPluginPath is the a system-global plugin path, this is set as a ldflag in the Makefile
var SystemPluginPath string

// CurrentVersionNumber is the current application's version literal
const CurrentVersionNumber = "0.4.12-dev"

Expand Down

0 comments on commit 9ee628d

Please sign in to comment.