-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdevops.sh
executable file
·59 lines (50 loc) · 1.62 KB
/
devops.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env bash
export CONTROLLER_GEN_VERSION="v0.16.1"
export GOLANGCI_LINT_VERSION="v1.60.1"
export MOCKERY_GEN_VERSION="v2.44.2"
export GOFUMPT_VERSION="v0.7.0"
export TESTENV_VERSION="1.25.x!"
prerequisites() {
if [[ "$(controller-gen --version 2>&1)" != *"$CONTROLLER_GEN_VERSION"* ]]; then
go install sigs.k8s.io/controller-tools/cmd/controller-gen@"${CONTROLLER_GEN_VERSION}"
fi
if [[ "$(golangci-lint --version 2>&1)" != *"$GOLANGCI_LINT_VERSION"* ]]; then
go install github.com/golangci/golangci-lint/cmd/golangci-lint@"${GOLANGCI_LINT_VERSION}"
fi
if [[ "$(mockery --version 2>&1)" != *"$MOCKERY_GEN_VERSION"* ]]; then
go install github.com/vektra/mockery/v2@"${MOCKERY_GEN_VERSION}"
fi
if [[ "$(gofumpt --version 2>&1)" != *"$GOFUMPT_VERSION"* ]]; then
go install mvdan.cc/gofumpt@"${GOFUMPT_VERSION}"
fi
if ! command -v crd-ref-docs &>/dev/null; then
go install github.com/elastic/crd-ref-docs@latest
fi
if ! command -v setup-envtest &>/dev/null; then
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
fi
}
lint() {
gofumpt -l -w .
golangci-lint run
}
generate() {
rm -rf deploy/crds
controller-gen object paths="./..."
controller-gen crd paths="./..." output:dir=deploy/crds
crd-ref-docs --source-path=./pkg/apis --config .apidoc.yaml --renderer markdown --output-path=./docs/api.md
mockery
}
install() {
kubectl apply -f deploy/crds
}
prepare_envtest() {
mkdir -p .envtest/crds
mkdir -p .envtest/bins
cp -rf "$(setup-envtest use $TESTENV_VERSION -p path)"/* .envtest/bins/
}
test() {
go test -v -coverpkg=./... ./...
}
prerequisites
"$@"