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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CONTROLLER ?= $(GO) tool sigs.k8s.io/controller-tools/cmd/controller-gen
# Run tests using the latest tools.
CHAINSAW ?= $(GO) run github.com/kyverno/chainsaw@latest
CHAINSAW_TEST ?= $(CHAINSAW) test
CRD_CHECKER ?= $(GO) run github.com/openshift/crd-schema-checker/cmd/crd-schema-checker@latest
ENVTEST ?= $(GO) run sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
KUTTL ?= $(GO) run github.com/kudobuilder/kuttl/cmd/kubectl-kuttl@latest
KUTTL_TEST ?= $(KUTTL) test
Expand Down Expand Up @@ -147,6 +148,12 @@ check: ## Run basic go tests with coverage output
check: get-pgmonitor
QUERIES_CONFIG_DIR="$(CURDIR)/${QUERIES_CONFIG_DIR}" $(GO_TEST) -cover ./...

# Informational only; no criteria to enforce at this time.
.PHONY: check-crd
check-crd:
$(foreach CRD, $(wildcard config/crd/bases/*.yaml), \
$(CRD_CHECKER) check-manifests --new-crd-filename '$(CRD)' 2>&1 | awk -f hack/check-manifests.awk $(newline))

# Available versions: curl -s 'https://storage.googleapis.com/kubebuilder-tools/' | grep -o '<Key>[^<]*</Key>'
# - KUBEBUILDER_ATTACH_CONTROL_PLANE_OUTPUT=true
.PHONY: check-envtest
Expand Down Expand Up @@ -253,3 +260,9 @@ generate-rbac: ## Generate RBAC
) rbac:roleName='postgres-operator' $(\
) paths='./cmd/...' paths='./internal/...' $(\
) output:dir='config/rbac' # {directory}/role.yaml

# https://www.gnu.org/software/make/manual/make.html#Multi_002dLine
define newline


endef
26 changes: 26 additions & 0 deletions hack/check-manifests.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2025 Crunchy Data Solutions, Inc.
#
# SPDX-License-Identifier: Apache-2.0

## TODO: Exit successfully only when there are no errors.
#/^ERROR:/ { rc = 1 }
#END { exit rc }

# Shorten these frequent messages about validation rules.
/The maximum allowable value is 10000000[.]/ {
sub(/ The maximum allowable value is 10000000./, "")
sub(/ allowed budget/, "&, 10M")
}

# These are informational, but "MustNot" sounds like something is wrong.
/^info: "MustNotExceedCostBudget"/ {
sub(/"MustNotExceedCostBudget"/, "\"CostBudget\"")
}

# Color errors and warnings when attached to a terminal.
ENVIRON["MAKE_TERMOUT"] != "" {
sub(/^ERROR:/, "\033[0;31m&\033[0m")
sub(/^Warning:/, "\033[1;33m&\033[0m")
}

{ print }
Loading