Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
0c70a26
fix: Add custom predicate to handle deletion timestamp changes
ephico2real2 Dec 8, 2025
1106ffa
feat: Add startup banner with version information
ephico2real2 Dec 8, 2025
464a8bd
build: Add automatic version detection to build system
ephico2real2 Dec 8, 2025
1f44239
docs: Add comprehensive documentation for fixes and code review
ephico2real2 Dec 8, 2025
744d285
chore: Remove REVIEW-REDUNDANCY.md and update .gitignore
ephico2real2 Dec 8, 2025
4da76c7
Add build.sh and run-go.sh scripts for simplified operator development
ephico2real2 Dec 8, 2025
7b2c29e
Add startup banner with version information
ephico2real2 Dec 8, 2025
359537d
Fix controller reconciliation for resources stuck in deletion
ephico2real2 Dec 8, 2025
b5d2f52
Add log level configuration via environment variables
ephico2real2 Dec 8, 2025
07658ec
Add Kyverno policies and local development utilities
ephico2real2 Dec 8, 2025
88434fa
Update build system to support automatic version information
ephico2real2 Dec 8, 2025
2a52a85
Update .gitignore to ignore generated Helm chart artifacts
ephico2real2 Dec 8, 2025
96e6362
Add log level configuration documentation and defaults
ephico2real2 Dec 8, 2025
00d21e0
feat: implement AND logic in template filtering for GroupConfig
ephico2real2 Dec 8, 2025
6d3e659
test: add comprehensive test cases for AND and OR logic
ephico2real2 Dec 8, 2025
de1c07a
docs: add comprehensive test examples and documentation for AND/OR logic
ephico2real2 Dec 8, 2025
97392ef
feat: improve template filtering with AND/OR logic and add comprehens…
ephico2real2 Dec 8, 2025
c309030
fix: improve detection of unrecognized template conditionals
ephico2real2 Dec 8, 2025
98c37f4
docs(issue-194): consolidate docs + add real-time verification; wire …
ephico2real2 Dec 8, 2025
3e40ed7
docs(issue-194): add pr-194.md (PR body) under examples/test-and-logic
ephico2real2 Dec 8, 2025
eecf6de
docs(issue-194): add appendix explaining pseudo-version derivation (v…
ephico2real2 Dec 8, 2025
1157ec1
docs(issue-194): keep only 3 consolidated docs; remove superseded 194…
ephico2real2 Dec 8, 2025
c352ea5
Update local utilities
ephico2real2 Dec 8, 2025
2674941
docs: organize resolved issues into dedicated tracker directory
ephico2real2 Dec 10, 2025
6863e84
docs: enhance monitor-operator-logs.sh documentation with compact-to-…
ephico2real2 Dec 10, 2025
aa95999
fix: prevent 'object has been modified' errors by re-fetching instanc…
ephico2real2 Dec 10, 2025
662d492
Add retry mechanism with exponential backoff for ManageSuccess to han…
ephico2real2 Dec 10, 2025
b70067c
Fix graceful deletion handling to prevent errors when resources are a…
ephico2real2 Dec 10, 2025
f9dbd24
Add deletion tracking logs and retry success logging
ephico2real2 Dec 10, 2025
48efb63
Add deletion tracking test resources and documentation
ephico2real2 Dec 10, 2025
86703a4
Add comprehensive documentation explaining template filtering logs
ephico2real2 Dec 10, 2025
8a324de
Add commands to verify groups exist in cluster
ephico2real2 Dec 10, 2025
ddbee91
Add cluster verification results to template filtering logs documenta…
ephico2real2 Dec 10, 2025
ddf559a
Add V(1) level logging for skipped groups/namespaces/users
ephico2real2 Dec 10, 2025
e45f596
Fix cluster-admin role in test examples
ephico2real2 Dec 10, 2025
22d39bd
Document resolution of issue #134 - Log level configuration
ephico2real2 Dec 10, 2025
e913086
Add issue #134 documentation similar to issue #194
ephico2real2 Dec 10, 2025
510b438
Enhance issue #134 documentation with all logging improvements
ephico2real2 Dec 10, 2025
fd9ecf7
Clarify ZAP_LOG_LEVEL configuration methods: Subscription vs Kyverno
ephico2real2 Dec 10, 2025
1c80bcc
Update issue #134 docs to clarify Subscription vs Kyverno methods
ephico2real2 Dec 10, 2025
982c82a
Add note about Subscription vs Kyverno choice in file list
ephico2real2 Dec 10, 2025
1cde701
Enhance LOG_LEVEL_CONFIGURATION.md with Dockerfile details and config…
ephico2real2 Dec 10, 2025
69cedc3
Create standalone DOCKERFILE_ENHANCEMENTS.md document
ephico2real2 Dec 10, 2025
16499ae
Create MAKEFILE_VERSION_INJECTION.md documentation
ephico2real2 Dec 10, 2025
0c99c4b
Clarify that manual commands are for local builds only
ephico2real2 Dec 10, 2025
102848b
Add note that manual commands are for local builds only in DOCKERFILE…
ephico2real2 Dec 10, 2025
5f61a42
Add note to manual build command section in DOCKERFILE_ENHANCEMENTS.md
ephico2real2 Dec 10, 2025
2e80123
Add version injection to Makefile docker-build and document CI/CD ver…
ephico2real2 Dec 10, 2025
b3bafb1
Clarify which Dockerfile is used in GitHub CI builds
ephico2real2 Dec 10, 2025
d0d9598
Rename and comprehensively update issues-and-resolution.md to FEATURE…
ephico2real2 Dec 10, 2025
cc18860
Remove old issues-and-resolution.md and update references
ephico2real2 Dec 10, 2025
133cbae
Update all references from issues-and-resolution.md to FEATURES_AND_I…
ephico2real2 Dec 10, 2025
41db797
Move FEATURES_AND_ISSUES_RESOLUTION.md to docs/ folder
ephico2real2 Dec 10, 2025
f880eb5
Update all relative paths in FEATURES_AND_ISSUES_RESOLUTION.md for do…
ephico2real2 Dec 10, 2025
01bff9a
Fix remaining path reference in FEATURES_AND_ISSUES_RESOLUTION.md
ephico2real2 Dec 10, 2025
5a2464b
Fix repository documentation audit issues
ephico2real2 Dec 10, 2025
e7ee060
Add real-world deletion tracking example to documentation
ephico2real2 Dec 10, 2025
91fe1d5
Add reconciliation lifecycle logging to all controllers
ephico2real2 Dec 10, 2025
d9f697c
Refactor: Extract common reconciler helpers and add groups/bindings d…
ephico2real2 Dec 10, 2025
a5b1e09
docs: Add comprehensive Issue #50 documentation with test results
ephico2real2 Dec 11, 2025
df4c945
docs: Update Issue #50 status to FIXED
ephico2real2 Dec 11, 2025
4291910
docs: Add explicit FIXED status note to Issue #50 section
ephico2real2 Dec 11, 2025
7e539d2
docs: Update groups-and-bindings-examples.md
ephico2real2 Dec 11, 2025
93350b4
docs: Add NetworkPolicy YAML output showing no operator-added metadata
ephico2real2 Dec 11, 2025
f9b339d
docs: Clean up Issue #50 documentation formatting and remove repetition
ephico2real2 Dec 11, 2025
091f585
Add Kyverno MutatingPolicy (CEL) versions and installation guide
ephico2real2 Mar 16, 2026
2aa2e96
Add git clone installation method to Kyverno guide
ephico2real2 Mar 16, 2026
38df251
Add offline Helm chart and simplify installation guides
ephico2real2 Mar 16, 2026
c86d500
Remove unnecessary OLM-IMAGE-OVERRIDE-GUIDE
ephico2real2 Mar 16, 2026
6f96f5a
Add TLS certificate fix for Kyverno installation
ephico2real2 Mar 16, 2026
d8cc1ef
helm-charts: add kyverno-values.yaml, update README, remove extracted…
ephico2real2 Mar 16, 2026
5c33857
testing new-replace-operator-image-to-dockerhub.yaml
ephico2real2 Mar 16, 2026
65fe585
helm-charts: add OLM CSV image patch hack section to README
ephico2real2 Mar 16, 2026
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: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,6 @@ testbin/*

bundle/
bundle.Dockerfile
charts/
charts/
issues-193.md
WARP.md
246 changes: 246 additions & 0 deletions BUILD-RUN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
# Build and Run Scripts

This document describes the build and run scripts for the namespace-configuration-operator.

## Quick Start

```bash
# Build the operator
./build.sh -o bin/manager main.go

# Build and run the operator
./run-go.sh
```

---

## Build Script (`build.sh`)

Automatically sets version information (VERSION, COMMIT, BUILD_DATE) when building, eliminating the need to manually specify ldflags.

### Usage

```bash
./build.sh -o bin/manager main.go
```

### Automatic Version Detection

The script automatically sets:
- **VERSION**: From `git describe --tags --always --dirty`
- **COMMIT**: From `git rev-parse --short HEAD`
- **BUILD_DATE**: From current UTC timestamp

### Examples

#### Basic Build
```bash
./build.sh -o bin/manager main.go
```

#### Build with Race Detector
```bash
./build.sh -race -o bin/manager main.go
```

#### Override Version
```bash
VERSION=1.0.0 ./build.sh -o bin/manager main.go
```

#### Override All Parameters
```bash
VERSION=2.0.0 COMMIT=abc123 BUILD_DATE=2025-01-01T00:00:00Z ./build.sh -o bin/manager main.go
```

#### Build with Tags
```bash
./build.sh -tags debug -o bin/manager main.go
```

#### Additional Go Build Flags
```bash
./build.sh -ldflags "-s -w" -o bin/manager main.go
```

### Environment Variables

Override any parameter via environment variables:
- `VERSION`: Override version string
- `COMMIT`: Override commit hash
- `BUILD_DATE`: Override build date (ISO 8601 format)

---

## Run Script (`run-go.sh`)

Simple script to build and run the operator locally with proper log configuration.

### Usage

```bash
# Automatic build and run
./run-go.sh

# Skip build if already built manually
./run-go.sh --skip-build

# Stop running operator
./run-go.sh --stop

# Development mode (console logs)
./run-go.sh --dev

# Custom log level
./run-go.sh --log-level debug

# Development mode with debug logs
./run-go.sh --dev --log-level 2

# See help
./run-go.sh --help
```

### Options

- `--log-level <level>`: Set log level (error, info, debug, 0-10) [default: info]
- `--dev`: Enable development mode (console logs) [default: false]
- `--skip-build`: Skip the build step (use existing binary)
- `--stop`: Stop the running operator and exit
- `--help`: Show help message

### Auto-Stop Feature

The script automatically stops any running operator before starting a new one to prevent multiple instances:

```bash
./run-go.sh # Will stop existing operator first if running
```

### Environment Variables

Override log configuration via environment variables:

```bash
ZAP_LOG_LEVEL=debug ZAP_DEVEL=true ./run-go.sh
```

### Test Cases

All options have been tested and verified:

#### Command-Line Options

1. **`--help`**: Shows help message with build.sh reference
```bash
./run-go.sh --help
```

2. **`--log-level error`**: Sets log level to error
```bash
./run-go.sh --skip-build --log-level error
```

3. **`--log-level info`**: Sets log level to info (default)
```bash
./run-go.sh --skip-build --log-level info
```

4. **`--log-level debug`**: Sets log level to debug
```bash
./run-go.sh --skip-build --log-level debug
```

5. **`--log-level 2`**: Sets numeric log level (verbosity level 2)
```bash
./run-go.sh --skip-build --log-level 2
```

6. **`--dev`**: Enables development mode (console logs)
```bash
./run-go.sh --skip-build --dev
```

7. **`--skip-build`**: Skips build when binary exists
```bash
./run-go.sh --skip-build
```

8. **`--skip-build` (missing binary)**: Automatically builds if binary is missing
```bash
rm bin/manager
./run-go.sh --skip-build # Automatically builds using build.sh if binary missing
```

9. **`--stop`**: Stops running operator
```bash
./run-go.sh --stop
```

10. **Auto-stop**: Automatically stops existing operator before starting
```bash
./run-go.sh # Stops existing operator first if running
```

11. **Combinations**: Multiple flags work together
```bash
./run-go.sh --skip-build --dev --log-level debug
```

12. **Invalid option**: Correctly detects and shows error
```bash
./run-go.sh --invalid-option # Shows error message
```

#### Environment Variables

13. **`ZAP_LOG_LEVEL` override**: Environment variable takes precedence
```bash
ZAP_LOG_LEVEL=error ./run-go.sh --skip-build
```

14. **`ZAP_DEVEL` override**: Environment variable works
```bash
ZAP_DEVEL=true ./run-go.sh --skip-build
```

#### Default Behavior

15. **Default run**: Automatically builds using build.sh and runs
```bash
./run-go.sh # Builds and runs with default settings
```

---

## Integration

The `run-go.sh` script automatically calls `build.sh` when needed:

- **Default behavior**: Calls `build.sh` automatically if binary doesn't exist
- **With `--skip-build`**: Skips build if binary exists, auto-builds if missing
- **Version info**: All version information from `build.sh` is correctly embedded
- **Environment overrides**: Build parameters can be overridden via environment variables

### Example Flow

```bash
# First run: builds automatically
./run-go.sh
# β†’ Calls build.sh
# β†’ Sets version info
# β†’ Runs operator

# Subsequent runs: can skip build
./run-go.sh --skip-build
# β†’ Uses existing binary
# β†’ Runs operator

# Missing binary: auto-builds even with --skip-build
rm bin/manager
./run-go.sh --skip-build
# β†’ Detects missing binary
# β†’ Automatically calls build.sh
# β†’ Runs operator
```

25 changes: 23 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,23 @@ RUN go mod download
COPY main.go main.go
COPY api/ api/
COPY controllers/ controllers/
COPY internal/ internal/

# Build
RUN CGO_ENABLED=0 GOOS=linux go build -a -o manager main.go
# Build with version information
# Note: These args should be passed at build time for accurate version info.
# The Makefile handles this automatically. For manual builds, use:
# podman build --build-arg VERSION=$(git describe --tags --always --dirty) \
# --build-arg COMMIT=$(git rev-parse --short HEAD) \
# --build-arg BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
# -t myimage .
ARG VERSION=dev
ARG COMMIT=unknown
ARG BUILD_DATE=unknown
RUN CGO_ENABLED=0 GOOS=linux go build -a \
-ldflags "-X github.com/redhat-cop/namespace-configuration-operator/internal/version.Version=${VERSION} \
-X github.com/redhat-cop/namespace-configuration-operator/internal/version.Commit=${COMMIT} \
-X github.com/redhat-cop/namespace-configuration-operator/internal/version.BuildDate=${BUILD_DATE}" \
-o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand All @@ -24,4 +38,11 @@ WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532

# Set default log level via environment variables
# These can be overridden at runtime via Deployment env section or ConfigMap
# See: https://sdk.operatorframework.io/docs/building-operators/golang/references/logging/
# Production defaults: info level, JSON format (ZAP_DEVEL=false)
ENV ZAP_LOG_LEVEL=info
ENV ZAP_DEVEL=false

ENTRYPOINT ["/manager"]
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,22 @@ kind-setup: kind kubectl helm

.PHONY: build
build: manifests generate fmt vet ## Build manager binary.
go build -o bin/manager main.go
@BUILD_VERSION=$${VERSION:-$$(git describe --tags --always --dirty 2>/dev/null || echo "$(VERSION)")}; \
COMMIT=$$(git rev-parse --short HEAD 2>/dev/null || echo "unknown"); \
BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ"); \
go build -buildvcs -ldflags "-X github.com/redhat-cop/namespace-configuration-operator/internal/version.Version=$$BUILD_VERSION -X github.com/redhat-cop/namespace-configuration-operator/internal/version.Commit=$$COMMIT -X github.com/redhat-cop/namespace-configuration-operator/internal/version.BuildDate=$$BUILD_DATE" -o bin/manager main.go

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker build -t ${IMG} .
@BUILD_VERSION=$${VERSION:-$$(git describe --tags --always --dirty 2>/dev/null || echo "$(VERSION)")}; \
COMMIT=$$(git rev-parse --short HEAD 2>/dev/null || echo "unknown"); \
BUILD_DATE=$$(date -u +"%Y-%m-%dT%H:%M:%SZ"); \
echo "Building with version info: VERSION=$$BUILD_VERSION, COMMIT=$$COMMIT, BUILD_DATE=$$BUILD_DATE"; \
docker build --build-arg VERSION=$$BUILD_VERSION --build-arg COMMIT=$$COMMIT --build-arg BUILD_DATE=$$BUILD_DATE -t ${IMG} .

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
Expand Down
Loading