
Create airshipui executable that derives kube config from the airshipctl settings and launches octant. The executable has its own set of command-line options, which may be expanded in the future to perform additional setup before launching octant. Note that octant currently does not support being compiled together and called as a function from other code, but that support should be coming in the future. Remove goimports check from lint suite since it generates undecipherable (and sometimes unsolvable) false positives and does not substantively improve on "go fmt". Change-Id: Iad1530f536fcbae93a92a4e827dbb7aece5231fa
79 lines
1.9 KiB
Makefile
79 lines
1.9 KiB
Makefile
# 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)
|
|
|
|
TOOLBINDIR := tools/bin
|
|
LINTER := $(TOOLBINDIR)/golangci-lint
|
|
LINTER_CONFIG := .golangci.yaml
|
|
|
|
COVERAGE_OUTPUT := coverage.out
|
|
|
|
TESTFLAGS ?=
|
|
|
|
# Override the value of the version variable in main.go
|
|
LD_FLAGS= '-X opendev.org/airship/airshipui/internal/environment.version=$(GIT_VERSION)'
|
|
GO_FLAGS := -ldflags=$(LD_FLAGS)
|
|
BUILD_DIR := bin
|
|
|
|
# Find all main.go files under cmd, excluding airshipui itself (which is the octant wrapper)
|
|
PLUGIN_NAMES := $(filter-out airshipui,$(notdir $(subst /main.go,,$(wildcard cmd/*/main.go))))
|
|
PLUGINS := $(addprefix $(BUILD_DIR)/, $(PLUGIN_NAMES))
|
|
MAIN := $(BUILD_DIR)/airshipui
|
|
|
|
ifdef XDG_CONFIG_HOME
|
|
OCTANT_PLUGINSTUB_DIR ?= ${XDG_CONFIG_HOME}/octant/plugins
|
|
# Determine in on windows
|
|
else ifeq ($(OS),Windows_NT)
|
|
OCTANT_PLUGINSTUB_DIR ?= ${LOCALAPPDATA}/octant/plugins
|
|
else
|
|
OCTANT_PLUGINSTUB_DIR ?= ${HOME}/.config/octant/plugins
|
|
endif
|
|
|
|
DIRS = internal
|
|
RECURSIVE_DIRS = $(addprefix ./, $(addsuffix /..., $(DIRS)))
|
|
|
|
.PHONY: build
|
|
build: $(MAIN) $(PLUGINS)
|
|
|
|
$(MAIN): FORCE
|
|
@mkdir -p $(BUILD_DIR)
|
|
go build -o $(MAIN) $(GO_FLAGS) cmd/$(@F)/main.go
|
|
|
|
$(PLUGINS): FORCE
|
|
@mkdir -p $(BUILD_DIR)
|
|
go build -o $@ $(GO_FLAGS) cmd/$(@F)/main.go
|
|
|
|
FORCE:
|
|
|
|
.PHONY: install-plugins
|
|
install-plugins: $(PLUGINS)
|
|
@mkdir -p $(OCTANT_PLUGINSTUB_DIR)
|
|
cp $? $(OCTANT_PLUGINSTUB_DIR)
|
|
|
|
.PHONY: test
|
|
test:
|
|
go test $(RECURSIVE_DIRS) -v $(TESTFLAGS)
|
|
|
|
.PHONY: cover
|
|
cover: TESTFLAGS += -coverprofile=$(COVERAGE_OUTPUT)
|
|
cover: test
|
|
go tool cover -html=$(COVERAGE_OUTPUT)
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -rf $(BUILD_DIR) $(COVERAGE_OUTPUT)
|
|
|
|
# The golang-unit zuul job calls the env target, so create one
|
|
.PHONY: env
|
|
|
|
.PHONY: lint
|
|
lint: $(LINTER)
|
|
$(LINTER) run --config $(LINTER_CONFIG)
|
|
|
|
$(LINTER):
|
|
@mkdir -p $(TOOLBINDIR)
|
|
./tools/install_linter
|