File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,18 @@ GIT_ROOT := $(shell git rev-parse --show-toplevel)
44export MCP_SERVER_PATH := $(GIT_ROOT ) /_output/ovnk-mcp-server
55export KUBECONFIG := $(HOME ) /ovn.conf
66
7+ # CONTAINER_RUNNABLE determines if the tests can be run inside a container. It checks to see if
8+ # podman/docker is installed on the system.
9+ PODMAN ?= $(shell podman -v > /dev/null 2>&1; echo $$? )
10+ ifeq ($(PODMAN ) , 0)
11+ CONTAINER_RUNTIME? =podman
12+ else
13+ CONTAINER_RUNTIME? =docker
14+ endif
15+ CONTAINER_RUNNABLE ?= $(shell $(CONTAINER_RUNTIME ) -v > /dev/null 2>&1; echo $$? )
16+
17+ GOPATH ?= $(shell go env GOPATH)
18+
719.PHONY : build
820build :
921 go build -o $(MCP_SERVER_PATH ) cmd/ovnk-mcp-server/main.go
@@ -37,3 +49,20 @@ run-e2e:
3749
3850.PHONY : test-e2e
3951test-e2e : build deploy-kind-ovnk run-e2e undeploy-kind-ovnk
52+
53+ .PHONY : lint
54+ lint :
55+ ifeq ($(CONTAINER_RUNNABLE ) , 0)
56+ @GOPATH=${GOPATH} ./hack/lint.sh $(CONTAINER_RUNTIME) || { echo "lint failed! Try running 'make lint-fix'"; exit 1; }
57+ else
58+ echo "linter can only be run within a container since it needs a specific golangci-lint version"; exit 1
59+ endif
60+
61+ .PHONY : lint-fix
62+ lint-fix :
63+ ifeq ($(CONTAINER_RUNNABLE ) , 0)
64+ @GOPATH=${GOPATH} ./hack/lint.sh ${CONTAINER_RUNTIME} fix || { echo "ERROR: lint fix failed! There is a bug that changes file ownership to root \
65+ when this happens. To fix it, simply run 'chown -R <user>:<group> *' from the repo root."; exit 1; }
66+ else
67+ echo "linter can only be run within a container since it needs a specific golangci-lint version"; exit 1
68+ endif
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ VERSION=v1.64.8
3+ extra_flags=" "
4+ if [ " $# " -ne 1 ]; then
5+ if [ " $# " -eq 2 ] && [ " $2 " == " fix" ]; then
6+ extra_flags=" --fix"
7+ else
8+ echo " Expected command line argument - container runtime (docker/podman) got $# arguments: $* "
9+ exit 1
10+ fi
11+ fi
12+
13+ $1 run --security-opt label=disable --rm \
14+ -v " ${HOME} " /.cache/golangci-lint:/cache -e GOLANGCI_LINT_CACHE=/cache \
15+ -v " $( pwd) " :/app -w /app -e GO111MODULE=on docker.io/golangci/golangci-lint:" ${VERSION} " \
16+ golangci-lint run --verbose --print-resources-usage \
17+ --modules-download-mode=vendor --timeout=15m0s ${extra_flags} && \
18+ echo " lint OK!"
You can’t perform that action at this time.
0 commit comments