From 83c47b10f648e874d63d1b99aa1926193b35de1f Mon Sep 17 00:00:00 2001 From: Chun Lin Yang Date: Tue, 17 Dec 2019 16:08:34 +0800 Subject: [PATCH 1/2] Have a Makefile to install operator-verify Signed-off-by: Chun Lin Yang --- Makefile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 10 ++++++++++ 2 files changed, 58 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..43ca0495d --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +# kernel-style V=1 build verbosity +ifeq ("$(origin V)", "command line") + BUILD_VERBOSE = $(V) +endif + +ifeq ($(BUILD_VERBOSE),1) + Q = +else + Q = @ +endif + +REPO = github.com/operator-framework/api +BUILD_PATH = $(REPO)/cmd/operator-verify +PKGS = $(shell go list ./... | grep -v /vendor/) + +.PHONY: help +help: ## Show this help screen + @echo 'Usage: make ... ' + @echo '' + @echo 'Available targets are:' + @echo '' + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) + +.PHONY: install + +install: ## Build & install the operator-verify + + $(Q)go install \ + -gcflags "all=-trimpath=${GOPATH}" \ + -asmflags "all=-trimpath=${GOPATH}" \ + -ldflags " \ + -X '${REPO}/version.GitVersion=${VERSION}' \ + -X '${REPO}/version.GitCommit=${GIT_COMMIT}' \ + " \ + $(BUILD_PATH) + +# Code management. +.PHONY: format tidy clean + +format: ## Format the source code + $(Q)go fmt $(PKGS) + +tidy: ## Update dependencies + $(Q)go mod tidy -v + +clean: ## Clean up the build artifacts + $(Q)rm -rf build + diff --git a/README.md b/README.md index 91bb12ffb..918a388c4 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,13 @@ Contains the API definitions used by [Operator Lifecycle Manager][olm] (OLM) and [olm]:https://github.com/operator-framework/operator-lifecycle-manager [marketplace]:https://github.com/operator-framework/operator-marketplace + +## Usage + +You can install the `operator-verify` tool from source using: + +`$ make install` + +To verify your ClusterServiceVersion yaml, + +`$ operator-verify verify /path/to/filename.yaml` \ No newline at end of file From 5d38ef761affd48c7270d7952e05e9c3b691b3cd Mon Sep 17 00:00:00 2001 From: Chun Lin Yang Date: Tue, 17 Dec 2019 16:22:20 +0800 Subject: [PATCH 2/2] Add test target --- Makefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Makefile b/Makefile index 43ca0495d..2ba562cc7 100644 --- a/Makefile +++ b/Makefile @@ -46,3 +46,17 @@ tidy: ## Update dependencies clean: ## Clean up the build artifacts $(Q)rm -rf build +############################## +# Tests # +############################## + +##@ Tests + +# Static tests. +.PHONY: test test-unit + +test: test-unit ## Run the tests + +TEST_PKGS:=$(shell go list ./...) +test-unit: ## Run the unit tests + $(Q)go test -short ${TEST_PKGS}