Inject version number into plugin description (#3)

This commit is contained in:
Gary Smith 2019-09-20 14:50:24 -07:00 committed by Jordan Jensen
parent bc6b42ff10
commit 85c3834a9e
2 changed files with 17 additions and 3 deletions

View File

@ -1,6 +1,14 @@
# Copyright (c) 2019 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
SHELL=/bin/bash
# Obtain the version and git commit info
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)
ifdef XDG_CONFIG_HOME
OCTANT_PLUGINSTUB_DIR ?= ${XDG_CONFIG_HOME}/octant/plugins
# Determine in on windows
@ -16,7 +24,7 @@ RECURSIVE_DIRS = $(addsuffix /...,$(DIRS))
.PHONY: install-plugin
install-plugin:
mkdir -p $(OCTANT_PLUGINSTUB_DIR)
go build -o $(OCTANT_PLUGINSTUB_DIR)/airship-ui-plugin opendev.org/airship/airshipui/cmd/airshipui
go build -o $(OCTANT_PLUGINSTUB_DIR)/airship-ui-plugin $(GO_FLAGS) opendev.org/airship/airshipui/cmd/airshipui
.PHONY: test
test: generate

View File

@ -1,19 +1,25 @@
package main
import (
"fmt"
"log"
"opendev.org/airship/airshipui/internal/plugin"
)
var pluginName = "airship-ui"
var (
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("")
description := fmt.Sprintf("Airship UI version %s", version)
// Use the plugin service helper to register this plugin.
p, err := plugin.Register(pluginName, "Airship UI")
p, err := plugin.Register(pluginName, description)
if err != nil {
log.Fatal(err)
}