Schiefelbein, Andrew dc43d5b17d POC pluggable auth method
Fixes #32

The changes are as follows:
1. An example for basic auth
2. An example for cookie based auth
3. An example for JWT (oauth)
4. Update the linting tools to also test the examples dir
5. Update the examples structure to be more logical

Things still needing to be worked:
1. Determine the best way to handle confs pertaining to auth
2. Understand how credentials are going to be passed where
3. How to store user credentials

Change-Id: Ie8798131d7fa338a8aeec3303593afb0390ab393
2020-05-15 11:45:50 -05:00

87 lines
2.2 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/commands.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)
EXAMPLE_NAMES := $(shell basename $(subst /main.go,,$(shell find examples -name "main.go")))
EXAMPLES := $(addprefix $(BUILD_DIR)/, $(EXAMPLE_NAMES))
MAIN := $(BUILD_DIR)/airshipui
EXTENSION :=
ifdef XDG_CONFIG_HOME
OCTANT_PLUGINSTUB_DIR ?= ${XDG_CONFIG_HOME}/octant/plugins
# Determine if on windows
else ifeq ($(OS),Windows_NT)
OCTANT_PLUGINSTUB_DIR ?= $(subst \,/,${LOCALAPPDATA}/octant/plugins)
EXTENSION=.exe
else
OCTANT_PLUGINSTUB_DIR ?= ${HOME}/.config/octant/plugins
endif
DIRS = internal
RECURSIVE_DIRS = $(addprefix ./, $(addsuffix /..., $(DIRS)))
.PHONY: build
build: $(MAIN) $(EXAMPLES)
$(MAIN): FORCE
@mkdir -p $(BUILD_DIR)
go build -o $(MAIN)$(EXTENSION) $(GO_FLAGS) cmd/$(@F)/main.go
$(EXAMPLES): FORCE
@mkdir -p $(BUILD_DIR)
go build -o $@$(EXTENSION) $(GO_FLAGS) examples/$(@F)/main.go
FORCE:
.PHONY: install-octant-plugins
install-octant-plugins: $(EXAMPLES)
@mkdir -p $(OCTANT_PLUGINSTUB_DIR)
cp $(addsuffix $(EXTENSION), $^) $(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)
.PHONY: docs
docs:
tox
# The golang-unit zuul job calls the env target, so create one
# Note: on windows if there is a WSL curl in c:\windows\system32
# it will cause problems installing the lint tools.
# The use of cygwin curl is working however
.PHONY: env
.PHONY: lint
lint: $(LINTER)
$(LINTER) run --config $(LINTER_CONFIG)
$(LINTER):
@mkdir -p $(TOOLBINDIR)
./tools/install_linter