diff --git a/Makefile b/Makefile index 0af960d..1d85bcd 100644 --- a/Makefile +++ b/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 diff --git a/cmd/airshipui/main.go b/cmd/airshipui/main.go index 2d01c2d..713d500 100644 --- a/cmd/airshipui/main.go +++ b/cmd/airshipui/main.go @@ -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() } diff --git a/internal/plugin/register.go b/internal/plugin/airshipui/register.go similarity index 100% rename from internal/plugin/register.go rename to internal/plugin/airshipui/register.go