Skip to content
Open
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
4 changes: 2 additions & 2 deletions .ci-operator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
build_root_image:
name: release
name: boilerplate
namespace: openshift
tag: rhel-9-release-golang-1.25-openshift-4.22
tag: image-v8.3.6
10 changes: 8 additions & 2 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ coverage:
range: "20...100"

status:
project: no
patch: no
project:
default:
target: 35%
threshold: 1%
patch:
default:
target: 50%
threshold: 1%
changes: no

parsers:
Expand Down
143 changes: 143 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# =============================================================================
# Tier 1 — Common Pre-Commit Hooks for OSD Operators
# SREP-4485 | Golden rules: SREP-4450
# =============================================================================
#
# INSTALL
# For detailed setup instructions including uv (recommended) and pip,
# see: boilerplate/openshift/golang-osd-operator/docs/pre-commit.md
#
# Quick start (uv):
# uv sync && source .venv/bin/activate && pre-commit install
#
# Quick start (pip):
# pip install 'pre-commit==4.6.0' && pre-commit install
#
# USAGE
# pre-commit run # staged files only (developer / agent workflow)
# pre-commit run --all-files # full repo (CI / first-time setup)
#
# BYPASS (golden rule 16)
# Skip one hook: SKIP=hook-id git commit
# Never use: git commit --no-verify
# Agents: never bypass any hook
# Security hooks: never bypassable under any circumstances
#
# CI RELATIONSHIP (golden rule 17)
# These hooks mirror ci/prow/lint. CI remains the authoritative gate.
# Every check here also runs in CI. Pre-commit is developer convenience.
#
# AGENT USAGE (golden rule 1, 7, 19)
# Agents run: pre-commit run
# Output: PRE_COMMIT=1 is set automatically — hooks emit structured output
# Retry: max 2 fix-and-retry iterations before escalating to human
#
# TIMING TARGETS (golden rule 2, 3)
# Total run: <= 10s target / <= 60s hard limit on a 10-file changeset
# Hooks run fastest-first (golden rule 13). Each hook has a timeout guard.
#
# FIRST RUN NOTE
# Auto-fix hooks (trailing-whitespace, end-of-file-fixer) will correct
# pre-existing violations on the first run. Stage and commit those fixes
# separately before day-to-day use.
#
# Fix commits can be excluded from git blame
# https://git-scm.com/docs/git-blame#Documentation/git-blame.txt---ignore-revs-filefile
#
# =============================================================================

repos:

# ---------------------------------------------------------------------------
# 1. FILE HYGIENE + YAML SYNTAX | target < 2s | auto-fix + error
# - check-merge-conflict: detects unresolved merge markers
# - trailing-whitespace: removes trailing spaces (auto-fix)
# - end-of-file-fixer: ensures single EOF newline (auto-fix)
# - check-yaml: validates YAML syntax in deploy/ manifests;
# mirrors ci/prow/lint: olm-deploy-yaml-validate
# ---------------------------------------------------------------------------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0 # pinned immutable tag
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-yaml
name: YAML syntax (deploy/)
files: ^deploy/.*\.ya?ml$
args: [--allow-multiple-documents]

# ---------------------------------------------------------------------------
# 2. SECRETS DETECTION | target < 5s | always blocking
# Scans all file types (YAML, shell, config) — gosec covers Go only.
# High-confidence findings block; configure .gitleaks.toml for allowlist.
# ---------------------------------------------------------------------------
- repo: https://github.com/gitleaks/gitleaks
rev: v8.18.0 # pinned immutable tag (golden rule 15)
hooks:
- id: gitleaks

# ---------------------------------------------------------------------------
# 3. STATIC ANALYSIS | target < 15s cached | error
# Mirrors ci/prow/lint: go-check exactly (same version + config as CI).
# Linter config: boilerplate/openshift/golang-osd-operator/golangci.yml
# ---------------------------------------------------------------------------
- repo: https://github.com/golangci/golangci-lint
rev: v2.0.2 # pinned immutable tag — must match CI (golden rule 15)
hooks:
- id: golangci-lint
args:
- --config=boilerplate/openshift/golang-osd-operator/golangci.yml
- --timeout=120s # graceful timeout (golden rule 3)

# ---------------------------------------------------------------------------
# Local hooks — compile, dependency, security
#
# TIMEOUT NOTE (golden rule 3)
# Uses portable timeout detection: 'timeout' on Linux, 'gtimeout' on macOS.
# macOS: brew install coreutils
# Linux: timeout is available by default (GNU coreutils)
# ---------------------------------------------------------------------------
- repo: local
hooks:

# -----------------------------------------------------------------------
# 4. COMPILE CHECK | target < 10s cached | error
# Catches import cycles and type errors before golangci-lint runs.
# Note: go build ./... writes no binary to the repo (compile check only).
# Fix: resolve compilation errors reported by go build.
# -----------------------------------------------------------------------
- id: go-build
name: go build
language: system
entry: bash -c 'T=$(command -v timeout || command -v gtimeout || echo); ${T:+$T 30s} go build ./...'
types: [go]
pass_filenames: false

# -----------------------------------------------------------------------
# 5. DEPENDENCY DRIFT | target < 10s | error
# Detects uncommitted go.mod/go.sum changes after go mod tidy.
# Fix: run 'go mod tidy' and stage go.mod and go.sum.
# -----------------------------------------------------------------------
- id: go-mod-tidy
name: go mod tidy
language: system
entry: bash -c 'T=$(command -v timeout || command -v gtimeout || echo); ${T:+$T 60s} go mod tidy && git diff --exit-code go.mod go.sum'
files: '(\.go$|go\.(mod|sum)$)'
exclude: '^vendor/'
pass_filenames: false

# -----------------------------------------------------------------------
# 6. RBAC WILDCARD CHECK | target < 5s | warn-only (blocking after cleanup)
# Rejects wildcard RBAC in deploy/ manifests (verbs/resources: ["*"]
# or multi-line - '*' format). Logic lives in standard.mk target
# 'rbac-wildcard-check' for readability and reuse.
# Fix: replace wildcards with explicit verbs and resource names.
# -----------------------------------------------------------------------
- id: rbac-wildcard-check
name: RBAC wildcard permissions
language: system
entry: bash -c 'make rbac-wildcard-check'
files: ^deploy/.*\.ya?ml$
pass_filenames: false
8 changes: 2 additions & 6 deletions OWNERS_ALIASES
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# =============================================================================
aliases:
srep-functional-team-aurora:
- abyrne55
- AlexSmithGH
- BATMAN-JD
- dakotalongRH
- eth1030
- geowa4
- joshbranham
- luis-falcon
- reedcort
srep-functional-team-fedramp:
- theautoroboto
Expand Down Expand Up @@ -61,7 +61,6 @@ aliases:
- casey-williams-rh
- boranx
srep-functional-team-thor:
- a7vicky
- diakovnec
- MitaliBhalla
- feichashao
Expand All @@ -74,7 +73,6 @@ aliases:
- yiqinzhang
- varunraokadaparthi
srep-functional-leads:
- abyrne55
- clcollins
- bergmannf
- theautoroboto
Expand All @@ -83,7 +81,6 @@ aliases:
- ravitri
srep-team-leads:
- rafael-azevedo
- iamkirkbater
- dustman9000
- bmeng
- typeid
Expand All @@ -92,5 +89,4 @@ aliases:
- maorfr
- rogbas
srep-architects:
- jharrington22
- cblecker
2 changes: 1 addition & 1 deletion boilerplate/_data/backing-image-tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
image-v8.3.4
image-v8.3.6
2 changes: 1 addition & 1 deletion boilerplate/_data/last-boilerplate-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2f25b66747494403fd6c00524e580f97982de853
8fb7c801f68dc7e06e8d2ae138c2a98f0b234b56
7 changes: 6 additions & 1 deletion boilerplate/_lib/container-make
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ if [[ "${CONTAINER_ENGINE##*/}" == "podman" ]] && [[ $OSTYPE == *"linux"* ]]; th
else
CE_OPTS="${CE_OPTS} -v $REPO_ROOT:$CONTAINER_MOUNT"
fi
container_id=$($CONTAINER_ENGINE run -d ${CE_OPTS} $IMAGE_PULL_PATH sleep infinity)
container_id=$($CONTAINER_ENGINE run --rm -d ${CE_OPTS} $IMAGE_PULL_PATH sleep infinity)

if [[ $? -ne 0 ]] || [[ -z "$container_id" ]]; then
err "Couldn't start detached container"
fi

trap "$CONTAINER_ENGINE stop $container_id >/dev/null 2>&1" EXIT

# Now run our `make` command in it with the right UID and working directory
args="exec -it -u $(id -u):0 -w $CONTAINER_MOUNT $container_id"
banner "Running: make $@"
Expand All @@ -52,6 +54,9 @@ if [[ $rc -ne 0 ]]; then
fi
fi

# Disarm the interrupt trap -- normal cleanup handles it from here
trap - EXIT

# Finally, remove the container
banner "Cleaning up the container"
$CONTAINER_ENGINE rm -f $container_id >/dev/null
Expand Down
10 changes: 8 additions & 2 deletions boilerplate/openshift/golang-osd-operator/.codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ coverage:
range: "20...100"

status:
project: no
patch: no
project:
default:
target: 35%
threshold: 1%
patch:
default:
target: 50%
threshold: 1%
changes: no

parsers:
Expand Down
8 changes: 2 additions & 6 deletions boilerplate/openshift/golang-osd-operator/OWNERS_ALIASES
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# =============================================================================
aliases:
srep-functional-team-aurora:
- abyrne55
- AlexSmithGH
- BATMAN-JD
- dakotalongRH
- eth1030
- geowa4
- joshbranham
- luis-falcon
- reedcort
srep-functional-team-fedramp:
- theautoroboto
Expand Down Expand Up @@ -61,7 +61,6 @@ aliases:
- casey-williams-rh
- boranx
srep-functional-team-thor:
- a7vicky
- diakovnec
- MitaliBhalla
- feichashao
Expand All @@ -74,7 +73,6 @@ aliases:
- yiqinzhang
- varunraokadaparthi
srep-functional-leads:
- abyrne55
- clcollins
- bergmannf
- theautoroboto
Expand All @@ -83,7 +81,6 @@ aliases:
- ravitri
srep-team-leads:
- rafael-azevedo
- iamkirkbater
- dustman9000
- bmeng
- typeid
Expand All @@ -92,5 +89,4 @@ aliases:
- maorfr
- rogbas
srep-architects:
- jharrington22
- cblecker
12 changes: 12 additions & 0 deletions boilerplate/openshift/golang-osd-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,18 @@ Checks consist of:
- `go generate`. This is a no-op if you have no `//go:generate`
directives in your code.

## PKO (Package Operator) fixture validation

Operators deployed via [Package Operator](https://package-operator.run/) can define snapshot test fixtures that validate `.gotmpl` template rendering. If `deploy_pko/manifest.yaml` exists and contains a `test:` section, the following targets are available:

- `make validate-pko-fixtures` validates that committed fixtures in `deploy_pko/.test-fixtures/` match the current template output. This runs automatically as part of `make validate` (and therefore `make container-validate`). Repos without PKO test fixtures are silently skipped.
- `make generate-pko-fixtures` regenerates fixtures after intentional changes to `.gotmpl` files or `manifest.yaml` config. Review the diff and commit the updated fixtures alongside the template changes.
- `make container-generate-pko-fixtures` runs fixture generation inside the boilerplate backing container, which has `kubectl-package` pre-installed. Useful if you don't have `kubectl-package` installed locally. The repository is bind-mounted into the container, so the generated fixtures appear directly in your local `deploy_pko/.test-fixtures/` directory — no manual copy step needed.

Both targets require `kubectl-package`. If it is not found, the target fails with installation instructions. The backing container image includes `kubectl-package`, so `make container-validate` and `make container-generate-pko-fixtures` always work.

**Important:** Buildah's `COPY *` includes dotfiles and dotdirs (contrary to standard glob behavior), so `deploy_pko/.test-fixtures/` will be included in the PKO OCI image unless excluded. `make generate-pko-fixtures` automatically creates a `deploy_pko/.dockerignore` with `.test-fixtures` to prevent this. `make validate-pko-fixtures` verifies the exclusion exists. Without it, PKO will see duplicate objects and fail to deploy the ClusterPackage.

## FIPS (Federal Information Processing Standards)

To enable FIPS in your build there is a `make ensure-fips` target.
Expand Down
5 changes: 5 additions & 0 deletions boilerplate/openshift/golang-osd-operator/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ updates:
labels:
- "area/dependency"
- "ok-to-test"
- "lgtm"
- "approved"
schedule:
interval: "weekly"
day: "monday"
time: "03:00"
timezone: "UTC"
ignore:
- dependency-name: "redhat-services-prod/openshift/boilerplate"
# don't upgrade boilerplate via these means
Expand Down
Loading