Skip to content

Run development tools rather than install them #4172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2025
Merged
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
22 changes: 22 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# https://editorconfig.org
#
# https://neovim.io/doc/user/editorconfig.html
# https://github.com/editorconfig/editorconfig-emacs
# https://plugins.jetbrains.com/plugin/7294-editorconfig
# https://marketplace.visualstudio.com/items/EditorConfig.EditorConfig

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.{go,sh}]
indent_size = tab
indent_style = tab

[*.{md,yml,yaml}]
indent_size = 2
indent_style = space

[Makefile]
indent_style = tab
9 changes: 6 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -18,11 +18,12 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version: stable }
- run: make check
- run: make check-generate

- name: Ensure go.mod is tidy
run: go mod tidy && git diff --exit-code -- go.mod
- name: Ensure generated files are committed
run: make check-generate
- run: make check

kubernetes-api:
runs-on: ubuntu-24.04
@@ -35,6 +36,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with: { go-version: stable }

- run: go mod download
- run: ENVTEST_K8S_VERSION="${KUBERNETES#default}" make check-envtest
env:
@@ -163,7 +165,8 @@ jobs:
echo '::group::PGO logs'; docker logs 'postgres-operator'; echo '::endgroup::'
exit $failed
env:
KUTTL_TEST: kubectl-kuttl test
KUTTL: kubectl-kuttl

- name: Stop PGO
run: docker stop 'postgres-operator' || true

40 changes: 14 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -15,9 +15,17 @@ BUILDAH_BUILD ?= buildah bud
GO ?= go
GO_BUILD = $(GO) build
GO_TEST ?= $(GO) test
KUTTL ?= kubectl-kuttl

# Ensure modules imported by `postgres-operator` and `controller-gen` are compatible
# by managing them together in the main module.
CONTROLLER ?= $(GO) tool sigs.k8s.io/controller-tools/cmd/controller-gen

# Run tests using the latest tools.
ENVTEST ?= $(GO) run sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
KUTTL ?= $(GO) run github.com/kudobuilder/kuttl/pkg/kuttlctl/cmd/kubectl-kuttl@latest
KUTTL_TEST ?= $(KUTTL) test


##@ General

# The help target prints out all targets with their descriptions organized
@@ -62,7 +70,6 @@ clean: clean-deprecated
rm -f bin/postgres-operator
rm -rf licenses/*/
[ ! -d testing/kuttl/e2e-generated ] || rm -r testing/kuttl/e2e-generated
[ ! -f hack/tools/setup-envtest ] || rm hack/tools/setup-envtest
[ ! -d hack/tools/envtest ] || { chmod -R u+w hack/tools/envtest && rm -r hack/tools/envtest; }
[ ! -d hack/tools/pgmonitor ] || rm -rf hack/tools/pgmonitor
[ ! -d hack/tools/external-snapshotter ] || rm -rf hack/tools/external-snapshotter
@@ -90,6 +97,9 @@ clean-deprecated: ## Clean deprecated resources
[ ! -d build/crd ] || rm -r build/crd
@# Old testing directories
[ ! -d testing/kuttl/e2e-generated-other ] || rm -r testing/kuttl/e2e-generated-other
@# Tools used to be downloaded directly
[ ! -f hack/tools/controller-gen ] || rm hack/tools/controller-gen
[ ! -f hack/tools/setup-envtest ] || rm hack/tools/setup-envtest


##@ Deployment
@@ -199,13 +209,13 @@ check: get-pgmonitor
check-envtest: ## Run check using envtest and a mock kube api
check-envtest: ENVTEST_USE = $(ENVTEST) --bin-dir=$(CURDIR)/hack/tools/envtest use $(ENVTEST_K8S_VERSION)
check-envtest: SHELL = bash
check-envtest: get-pgmonitor tools/setup-envtest
check-envtest: get-pgmonitor
@$(ENVTEST_USE) --print=overview && echo
source <($(ENVTEST_USE) --print=env) && PGO_NAMESPACE="postgres-operator" QUERIES_CONFIG_DIR="$(CURDIR)/${QUERIES_CONFIG_DIR}" \
$(GO_TEST) -count=1 -cover ./...

# The "PGO_TEST_TIMEOUT_SCALE" environment variable (default: 1) can be set to a
# positive number that extends test timeouts. The following runs tests with
# positive number that extends test timeouts. The following runs tests with
# timeouts that are 20% longer than normal:
# make check-envtest-existing PGO_TEST_TIMEOUT_SCALE=1.2
.PHONY: check-envtest-existing
@@ -270,7 +280,6 @@ generate: generate-rbac

.PHONY: generate-crd
generate-crd: ## Generate Custom Resource Definitions (CRDs)
generate-crd: tools/controller-gen
$(CONTROLLER) \
crd:crdVersions='v1' \
paths='./pkg/apis/...' \
@@ -282,38 +291,17 @@ generate-collector: ## Generate OTel Collector files

.PHONY: generate-deepcopy
generate-deepcopy: ## Generate DeepCopy functions
generate-deepcopy: tools/controller-gen
$(CONTROLLER) \
object:headerFile='hack/boilerplate.go.txt' \
paths='./pkg/apis/postgres-operator.crunchydata.com/...'

.PHONY: generate-rbac
generate-rbac: ## Generate RBAC
generate-rbac: tools/controller-gen
$(CONTROLLER) \
rbac:roleName='postgres-operator' \
paths='./cmd/...' paths='./internal/...' \
output:dir='config/rbac' # {directory}/role.yaml

##@ Tools

.PHONY: tools
tools: ## Download tools like controller-gen and kustomize if necessary.

# go-get-tool will 'go install' any package $2 and install it to $1.
define go-get-tool
@[ -f '$(1)' ] || { echo Downloading '$(2)'; GOBIN='$(abspath $(dir $(1)))' $(GO) install '$(2)'; }
endef

CONTROLLER ?= hack/tools/controller-gen
tools: tools/controller-gen
tools/controller-gen:
$(call go-get-tool,$(CONTROLLER),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.17.2)

ENVTEST ?= hack/tools/setup-envtest
tools: tools/setup-envtest
tools/setup-envtest:
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)

##@ Release

Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.17.2
controller-gen.kubebuilder.io/version: v0.17.3
name: crunchybridgeclusters.postgres-operator.crunchydata.com
spec:
group: postgres-operator.crunchydata.com
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.17.2
controller-gen.kubebuilder.io/version: v0.17.3
name: pgadmins.postgres-operator.crunchydata.com
spec:
group: postgres-operator.crunchydata.com
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.17.2
controller-gen.kubebuilder.io/version: v0.17.3
name: pgupgrades.postgres-operator.crunchydata.com
spec:
group: postgres-operator.crunchydata.com

Large diffs are not rendered by default.

61 changes: 34 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module github.com/crunchydata/postgres-operator

// If this is changing when you don't want it to, see hack/go-get.sh
go 1.23.0
go 1.24.0

require (
github.com/go-logr/logr v1.4.2
github.com/golang-jwt/jwt/v5 v5.2.2
github.com/google/go-cmp v0.6.0
github.com/google/go-cmp v0.7.0
github.com/google/uuid v1.6.0
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.0.0
github.com/onsi/ginkgo/v2 v2.22.0
github.com/onsi/gomega v1.36.1
github.com/onsi/ginkgo/v2 v2.22.1
github.com/onsi/gomega v1.36.2
github.com/pganalyze/pg_query_go/v5 v5.1.0
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
@@ -22,19 +22,20 @@ require (
go.opentelemetry.io/otel/sdk v1.32.0
go.opentelemetry.io/otel/trace v1.32.0
golang.org/x/crypto v0.36.0
golang.org/x/tools v0.28.0
golang.org/x/tools v0.30.0
gotest.tools/v3 v3.5.1
k8s.io/api v0.31.0
k8s.io/apimachinery v0.31.0
k8s.io/client-go v0.31.0
k8s.io/component-base v0.31.0
k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a
k8s.io/api v0.32.2
k8s.io/apimachinery v0.32.2
k8s.io/client-go v0.32.2
k8s.io/component-base v0.32.2
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f
sigs.k8s.io/controller-runtime v0.19.3
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3
sigs.k8s.io/yaml v1.4.0
)

require (
cel.dev/expr v0.18.0 // indirect
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
github.com/beorn7/perks v1.0.1 // indirect
@@ -44,6 +45,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.12.1 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
@@ -52,22 +54,23 @@ require (
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/gobuffalo/flect v1.0.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/cel-go v0.20.1 // indirect
github.com/google/cel-go v0.22.0 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.23.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.11 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/moby/spdystream v0.4.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/moby/spdystream v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
@@ -76,9 +79,9 @@ require (
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.60.1 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
github.com/spf13/cobra v1.9.1 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/stoewer/go-strcase v1.3.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.opentelemetry.io/contrib/bridges/prometheus v0.57.0 // indirect
go.opentelemetry.io/contrib/propagators/aws v1.32.0 // indirect
@@ -102,28 +105,32 @@ require (
go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/mod v0.23.0 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/oauth2 v0.27.0 // indirect
golang.org/x/sync v0.12.0 // indirect
golang.org/x/sys v0.31.0 // indirect
golang.org/x/term v0.30.0 // indirect
golang.org/x/text v0.23.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/time v0.7.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241104194629-dd2ea8efbc28 // indirect
google.golang.org/grpc v1.68.0 // indirect
google.golang.org/protobuf v1.35.1 // indirect
google.golang.org/protobuf v1.36.1 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.31.0 // indirect
k8s.io/apiserver v0.31.0 // indirect
k8s.io/apiextensions-apiserver v0.32.2 // indirect
k8s.io/apiserver v0.32.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.30.3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.0 // indirect
sigs.k8s.io/controller-tools v0.17.3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
)

// https://go.dev/doc/modules/managing-dependencies#tools
tool sigs.k8s.io/controller-tools/cmd/controller-gen
135 changes: 77 additions & 58 deletions go.sum

Large diffs are not rendered by default.