Modifies Makefile to support multiple plugins
Introduces new convention for plugins that fixes multi plugin support Each plugin name will exist at : - cmd/<plugin name>/main.go Definitions to call plugin registration - internal/plugin/<plugin name> Implementations for Navigation, Tab and Print as appropriate Change-Id: I6f5e71900eb90b26917216ebd1a2749acc4f5a52
This commit is contained in:
parent
e4e14c891a
commit
b273aab419
12
Makefile
12
Makefile
@ -8,6 +8,7 @@ GIT_VERSION=$(shell git describe --match 'v*' --always)
|
||||
# Override the value of the version variable in main.go
|
||||
LD_FLAGS= '-X main.version=$(GIT_VERSION)'
|
||||
GO_FLAGS= -ldflags=$(LD_FLAGS)
|
||||
PLUGINS:= $(shell ls cmd)
|
||||
|
||||
ifdef XDG_CONFIG_HOME
|
||||
OCTANT_PLUGINSTUB_DIR ?= ${XDG_CONFIG_HOME}/octant/plugins
|
||||
@ -20,11 +21,16 @@ endif
|
||||
|
||||
DIRS = internal pkg
|
||||
RECURSIVE_DIRS = $(addsuffix /...,$(DIRS))
|
||||
#.PHONY: install-plugin
|
||||
#install-plugin:
|
||||
# mkdir -p $(OCTANT_PLUGINSTUB_DIR)
|
||||
# go build -o $(OCTANT_PLUGINSTUB_DIR)/airship-ui-plugin $(GO_FLAGS) opendev.org/airship/airshipui/cmd/airshipui
|
||||
|
||||
.PHONY: install-plugin
|
||||
install-plugin:
|
||||
.PHONY: install-plugins
|
||||
install-plugins: $(PLUGINS)
|
||||
$(PLUGINS):
|
||||
mkdir -p $(OCTANT_PLUGINSTUB_DIR)
|
||||
go build -o $(OCTANT_PLUGINSTUB_DIR)/airship-ui-plugin $(GO_FLAGS) opendev.org/airship/airshipui/cmd/airshipui
|
||||
go build -o $(OCTANT_PLUGINSTUB_DIR)/$@-plugin $(GO_FLAGS) opendev.org/airship/airshipui/cmd/$@
|
||||
|
||||
.PHONY: test
|
||||
test: generate
|
||||
|
@ -1,31 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"opendev.org/airship/airshipui/internal/plugin"
|
||||
"opendev.org/airship/airshipui/internal/plugin/airshipui"
|
||||
)
|
||||
|
||||
var (
|
||||
pluginName = "airship-ui"
|
||||
// version will be overriden by ldflags supplied in Makefile
|
||||
version = "(dev-version)"
|
||||
pluginName = "airship-ui"
|
||||
// version will be overriden by ldflags supplied in Makefile
|
||||
version = "(dev-version)"
|
||||
)
|
||||
|
||||
// This is a sample plugin showing the features of Octant's plugin API.
|
||||
func main() {
|
||||
// Remove the prefix from the go logger since Octant will print logs with timestamps.
|
||||
log.SetPrefix("")
|
||||
// Remove the prefix from the go logger since Octant will print logs with timestamps.
|
||||
log.SetPrefix("")
|
||||
|
||||
description := fmt.Sprintf("Airship UI version %s", version)
|
||||
// Use the plugin service helper to register this plugin.
|
||||
p, err := plugin.Register(pluginName, description)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
description := fmt.Sprintf("Airship UI version %s", version)
|
||||
// Use the plugin service helper to register this plugin.
|
||||
p, err := plugin.Register(pluginName, description)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
// The plugin can log and the log messages will show up in Octant.
|
||||
log.Printf("%s is starting", pluginName)
|
||||
p.Serve()
|
||||
// The plugin can log and the log messages will show up in Octant.
|
||||
log.Printf("%s is starting", pluginName)
|
||||
p.Serve()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user