Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 40 additions & 32 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

SHELL = /usr/bin/env bash

RED := \033[0;31m
NO_COLOR := \033[0m

GOLANGCI_VERSION = 2.7.2
GOFUMPT_VERSION=0.9.2
JQ_VERSION=1.8.1
Expand Down Expand Up @@ -55,41 +58,41 @@ endif
.PHONY: bin/jq bin/gofumpt bin/golangci-lint clean validation/license/download curl-installed docker-installed go-installed clean/test clean/ssh clean/docker

bin:
mkdir -p bin
@mkdir -p bin

curl-installed:
command -v curl > /dev/null
@command -v curl > /dev/null

docker-installed:
command -v docker > /dev/null
@command -v docker > /dev/null

go-installed:
command -v go > /dev/null
go version
@command -v go > /dev/null
@go version

bin/jq: curl-installed bin
if ! ./hack/check_binary.sh "jq" "--version" "$(JQ_VERSION)" ; then \
@if ! ./hack/check_binary.sh "jq" "--version" "$(JQ_VERSION)" ; then \
echo "Install jq"; \
curl -sSfL https://github.com/jqlang/jq/releases/download/jq-$(JQ_VERSION)/jq-$(JQ_PLATFORM_ARCH) -o ./bin/jq; \
chmod +x "./bin/jq"; \
fi

bin/golangci-lint: curl-installed bin
if ! ./hack/check_binary.sh "golangci-lint" "--version" "$(GOLANGCI_VERSION)"; then \
@if ! ./hack/check_binary.sh "golangci-lint" "--version" "$(GOLANGCI_VERSION)"; then \
echo "Install golangci-lint"; \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | BINARY=golangci-lint bash -s -- v${GOLANGCI_VERSION}; \
chmod +x "./bin/golangci-lint"; \
fi

bin/gofumpt: curl-installed bin
if ! ./hack/check_binary.sh "gofumpt" "-version" "$(GOFUMPT_VERSION)"; then \
@if ! ./hack/check_binary.sh "gofumpt" "-version" "$(GOFUMPT_VERSION)"; then \
echo "Install gofumpt"; \
curl -sSfLo "bin/gofumpt" https://github.com/mvdan/gofumpt/releases/download/v$(GOFUMPT_VERSION)/gofumpt_v$(GOFUMPT_VERSION)_$(GOFUMPT_PLATFORM)_$(GOFUMPT_ARCH); \
chmod +x "./bin/gofumpt"; \
fi

bin/kind: curl-installed bin
if ! ./hack/check_binary.sh "kind" "version" "$(KIND_VERSION)"; then \
@if ! ./hack/check_binary.sh "kind" "version" "$(KIND_VERSION)"; then \
echo "Install kind"; \
curl -sSfLo "bin/kind" https://github.com/kubernetes-sigs/kind/releases/download/v$(KIND_VERSION)/kind-$(KIND_PLATFORM)-$(KIND_ARCH); \
chmod +x "./bin/kind"; \
Expand All @@ -98,26 +101,31 @@ bin/kind: curl-installed bin
deps: bin bin/jq bin/golangci-lint bin/gofumpt bin/kind

go-deps/update: go-installed
if [ -z "$(DEP)" ] ; then \
echo "Please pass dependency name over DEP like make go-deps/update DEP=github.com/some/lib VER=v1.1.1"; \
@if [ -z "$(DEP)" ] ; then \
echo -e "${RED}Please pass dependency name over DEP like make go-deps/update DEP=github.com/some/lib VER=v1.1.1${NO_COLOR}"; \
exit 1; \
fi; \
if [ -z "$(VER)" ] ; then \
echo "Please pass dependency version over VER like make go-deps/update DEP=github.com/some/lib VER=v1.1.1"; \
echo -e "${RED}Please pass dependency version over VER like make go-deps/update DEP=github.com/some/lib VER=v1.1.1${NO_COLOR}"; \
exit 1; \
fi; \
go get "$(DEP)@$(VER)"; \
cd ./tests; \
go get "$(DEP)@$(VER)";
ls -lh;
cd ./examples/cobra;
go get "$(DEP)@$(VER)"
for ii in $$(find $(CURDIR) -type f -name "go.mod" -printf "%h\n" | sort -u); do \
echo "Run go get in $$(realpath $$ii)"; \
cd "$$ii" && go get "$(DEP)@$(VER)"; \
done

go-deps/tidy: go-installed
go mod tidy && cd ./tests && go mod tidy && cd ../examples/cobra && go mod tidy
@for ii in $$(find $(CURDIR) -type f -name "go.mod" -printf "%h\n" | sort -u); do \
echo "Run go mod tidy in $$(realpath $$ii)"; \
cd "$$ii" && go mod tidy; \
done

go-deps/ci/check/no-tidy: go-installed go-deps/tidy
git diff --exit-code
@if ! git diff --exit-code; then \
echo ""; \
echo -e "${RED}go mod tidy produce diff. Please run 'make go-deps/tidy' and commit${NO_COLOR}"; \
exit 1; \
fi

test: go-installed docker-installed bin/kind
./hack/run_tests.sh
Expand All @@ -127,46 +135,46 @@ test/no-integration:
$(MAKE) SKIP_INTEGRATION_TESTS=true test

lint: bin/golangci-lint
./bin/golangci-lint run ./... -c .golangci.yaml
@./bin/golangci-lint run ./... -c .golangci.yaml

lint/fix: bin/golangci-lint
./bin/golangci-lint run ./... -c .golangci.yaml --fix
@./bin/golangci-lint run ./... -c .golangci.yaml --fix

fmt: bin/gofumpt
find . -type f -name '*.go' -not -path "./validation*" -print0 | xargs -0 ./bin/gofumpt -l
@find . -type f -name '*.go' -not -path "./validation*" -print0 | xargs -0 ./bin/gofumpt -l

validation/license/dir:
mkdir -p validation
@mkdir -p validation

validation/license/download: curl-installed validation/license/dir bin/jq
set -o pipefail; \
@set -o pipefail; \
curl -sL https://api.github.com/repos/deckhouse/deckhouse/contents/tools/validation \
| ./bin/jq 'map(select(.type == "file")) | map(select(.name | test(".*.go")))' \
| ./bin/jq -r '.[] | ["curl -sSfLo \"validation/\(.name)\" \"\(.download_url)\""] | join("\n")' \
| while IFS= read -r command_to_run; do echo "run: $$command_to_run"; $(SHELL) -c "$$command_to_run"; done

validation/license: go-installed validation/license/download
cd ./validation; declare -a validation_deps=("github.com/tidwall/gjson" "gopkg.in/yaml.v2"); \
@cd ./validation; declare -a validation_deps=("github.com/tidwall/gjson" "gopkg.in/yaml.v2"); \
for i in "${validation_deps[@]}"; do \
go get "$$i"; \
done
go run ./validation/{main,messages,diff,copyright,no_cyrillic,doc_changes,grafana_dashboard,release_requirements}.go -type copyright
@go run ./validation/{main,messages,diff,copyright,no_cyrillic,doc_changes,grafana_dashboard,release_requirements}.go -type copyright
# prevent goland ide errors
rm -f ./validation/go.mod ./validation/go.sum

clean/ssh: clean/docker
echo "Remove test dir /tmp/test-lib-connection"
rm -rf /tmp/test-lib-connection
@echo "Remove test dir /tmp/test-lib-connection"
@rm -rf /tmp/test-lib-connection

clean/docker: docker-installed
./hack/clean_docker.sh
@./hack/clean_docker.sh

clean/kind: bin/kind
./hack/clean_kind.sh
@./hack/clean_kind.sh

clean/test: clean/kind clean/ssh

all: bin deps validation/license fmt lint test
all: bin deps validation/license fmt lint test clean/test

clean: clean/test
rm -rf ./bin
Expand Down
2 changes: 1 addition & 1 deletion examples/cobra/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.25.5

require (
github.com/deckhouse/lib-connection v0.0.0-00010101000000-000000000000
github.com/deckhouse/lib-dhctl v0.13.0
github.com/deckhouse/lib-dhctl v0.17.0
github.com/name212/govalue v1.1.0
github.com/spf13/cobra v1.10.2
k8s.io/apimachinery v0.33.8
Expand Down
7 changes: 4 additions & 3 deletions examples/cobra/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckhouse/deckhouse/pkg/log v0.1.1-0.20251230144142-2bad7c3d1edf h1:4HrDzRZcLpREJ+2cSGNmxHVQlxXRcH2r5TGmTcoTZiU=
github.com/deckhouse/deckhouse/pkg/log v0.1.1-0.20251230144142-2bad7c3d1edf/go.mod h1:pbAxTSDcPmwyl3wwKDcEB3qdxHnRxqTV+J0K+sha8bw=
github.com/deckhouse/lib-dhctl v0.13.0 h1:Xh7G30seic4Aa8MdXOH2ecGvO0zsn6PBGBHbJ4YNnZM=
github.com/deckhouse/lib-dhctl v0.13.0/go.mod h1:RCthjbhLf0CtgdltTmFHk+lRyjRai8BlAO7SocAYR+E=
github.com/deckhouse/lib-dhctl v0.17.0 h1:2bDR+kohYp3JI6pBq7T4XwEhIWuagnc39Y8Cmd186ck=
github.com/deckhouse/lib-dhctl v0.17.0/go.mod h1:RCthjbhLf0CtgdltTmFHk+lRyjRai8BlAO7SocAYR+E=
github.com/deckhouse/lib-gossh v0.3.0 h1:FUAlF8+fLnBCII9hXSNx+arZ4PH3H/6fzp5LBlnmlps=
github.com/deckhouse/lib-gossh v0.3.0/go.mod h1:6bT8jf2fkBPEhYBU35+vMBr5YscliTiS+Vr8v06C+70=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
Expand Down Expand Up @@ -300,8 +300,9 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
github.com/werf/logboek v0.5.5 h1:RmtTejHJOyw0fub4pIfKsb7OTzD90ZOUyuBAXqYqJpU=
github.com/werf/logboek v0.5.5/go.mod h1:Gez5J4bxekyr6MxTmIJyId1F61rpO+0/V4vjCIEIZmk=
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.25.5
require (
al.essio.dev/pkg/shellescape v1.6.0
github.com/bramvdbogaerde/go-scp v1.6.0
github.com/deckhouse/lib-dhctl v0.13.0
github.com/deckhouse/lib-dhctl v0.17.0
github.com/deckhouse/lib-gossh v0.3.0
github.com/flant/kube-client v1.6.0
github.com/go-openapi/spec v0.19.8
Expand Down Expand Up @@ -71,6 +71,7 @@ require (
github.com/prometheus/common v0.62.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/rogpeppe/go-internal v1.14.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/werf/logboek v0.5.5 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckhouse/deckhouse/pkg/log v0.1.1-0.20251230144142-2bad7c3d1edf h1:4HrDzRZcLpREJ+2cSGNmxHVQlxXRcH2r5TGmTcoTZiU=
github.com/deckhouse/deckhouse/pkg/log v0.1.1-0.20251230144142-2bad7c3d1edf/go.mod h1:pbAxTSDcPmwyl3wwKDcEB3qdxHnRxqTV+J0K+sha8bw=
github.com/deckhouse/lib-dhctl v0.13.0 h1:Xh7G30seic4Aa8MdXOH2ecGvO0zsn6PBGBHbJ4YNnZM=
github.com/deckhouse/lib-dhctl v0.13.0/go.mod h1:RCthjbhLf0CtgdltTmFHk+lRyjRai8BlAO7SocAYR+E=
github.com/deckhouse/lib-dhctl v0.17.0 h1:2bDR+kohYp3JI6pBq7T4XwEhIWuagnc39Y8Cmd186ck=
github.com/deckhouse/lib-dhctl v0.17.0/go.mod h1:RCthjbhLf0CtgdltTmFHk+lRyjRai8BlAO7SocAYR+E=
github.com/deckhouse/lib-gossh v0.3.0 h1:FUAlF8+fLnBCII9hXSNx+arZ4PH3H/6fzp5LBlnmlps=
github.com/deckhouse/lib-gossh v0.3.0/go.mod h1:6bT8jf2fkBPEhYBU35+vMBr5YscliTiS+Vr8v06C+70=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
Expand Down Expand Up @@ -293,8 +293,9 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
github.com/werf/logboek v0.5.5 h1:RmtTejHJOyw0fub4pIfKsb7OTzD90ZOUyuBAXqYqJpU=
github.com/werf/logboek v0.5.5/go.mod h1:Gez5J4bxekyr6MxTmIJyId1F61rpO+0/V4vjCIEIZmk=
Expand Down
2 changes: 1 addition & 1 deletion tests/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
github.com/avelino/slugify v0.0.0-20180501145920-855f152bd774 // indirect
github.com/deckhouse/deckhouse/pkg/log v0.1.1-0.20251230144142-2bad7c3d1edf // indirect
github.com/deckhouse/lib-dhctl v0.13.0 // indirect
github.com/deckhouse/lib-dhctl v0.17.0 // indirect
github.com/deckhouse/lib-gossh v0.3.0 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
Expand Down
7 changes: 4 additions & 3 deletions tests/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deckhouse/deckhouse/pkg/log v0.1.1-0.20251230144142-2bad7c3d1edf h1:4HrDzRZcLpREJ+2cSGNmxHVQlxXRcH2r5TGmTcoTZiU=
github.com/deckhouse/deckhouse/pkg/log v0.1.1-0.20251230144142-2bad7c3d1edf/go.mod h1:pbAxTSDcPmwyl3wwKDcEB3qdxHnRxqTV+J0K+sha8bw=
github.com/deckhouse/lib-dhctl v0.13.0 h1:Xh7G30seic4Aa8MdXOH2ecGvO0zsn6PBGBHbJ4YNnZM=
github.com/deckhouse/lib-dhctl v0.13.0/go.mod h1:RCthjbhLf0CtgdltTmFHk+lRyjRai8BlAO7SocAYR+E=
github.com/deckhouse/lib-dhctl v0.17.0 h1:2bDR+kohYp3JI6pBq7T4XwEhIWuagnc39Y8Cmd186ck=
github.com/deckhouse/lib-dhctl v0.17.0/go.mod h1:RCthjbhLf0CtgdltTmFHk+lRyjRai8BlAO7SocAYR+E=
github.com/deckhouse/lib-gossh v0.3.0 h1:FUAlF8+fLnBCII9hXSNx+arZ4PH3H/6fzp5LBlnmlps=
github.com/deckhouse/lib-gossh v0.3.0/go.mod h1:6bT8jf2fkBPEhYBU35+vMBr5YscliTiS+Vr8v06C+70=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
Expand Down Expand Up @@ -251,8 +251,9 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw=
github.com/werf/logboek v0.5.5 h1:RmtTejHJOyw0fub4pIfKsb7OTzD90ZOUyuBAXqYqJpU=
github.com/werf/logboek v0.5.5/go.mod h1:Gez5J4bxekyr6MxTmIJyId1F61rpO+0/V4vjCIEIZmk=
Expand Down
Loading