Skip to content

Commit 1c4c86b

Browse files
committed
Add Copilot instructions for fluent-operator
1 parent 9c0a98c commit 1c4c86b

1 file changed

Lines changed: 105 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Copilot Instructions for fluent-operator
2+
3+
## Project Summary
4+
5+
Fluent Operator is a Kubernetes operator (written in Go) that manages Fluent Bit and Fluentd deployments via Custom Resource Definitions (CRDs). It is built with **kubebuilder v3** and **controller-runtime**. The Go module path is `github.com/fluent/fluent-operator/v3`.
6+
7+
- **Language**: Go (version specified in `go.mod`, currently 1.26.2)
8+
- **Framework**: kubebuilder / controller-runtime
9+
- **License**: Apache 2.0
10+
- **Default branch**: `master`
11+
12+
## Build, Test, and Lint Commands
13+
14+
Always run `go mod download` before building or testing.
15+
16+
| Task | Command | Notes |
17+
|---|---|---|
18+
| **Download deps** | `go mod download` | Run first |
19+
| **Generate deepcopy** | `make generate` | Regenerates `zz_generated.deepcopy.go` files |
20+
| **Generate CRDs & manifests** | `make manifests` | Requires `kubectl` on PATH for kustomize steps |
21+
| **Build binaries** | `make build` | Runs generate + fmt + vet, outputs to `bin/` |
22+
| **Build only (no codegen)** | `make binary` | Builds `bin/fb-manager`, `bin/fb-watcher`, `bin/fd-watcher` |
23+
| **Run unit tests** | `make test` | Runs manifests + generate + fmt + vet + envtest setup, then `go test` with race detector. Excludes `/e2e` tests. |
24+
| **Run linter** | `make lint` | Uses golangci-lint v2 with config in `.golangci.yml` |
25+
| **Lint fix** | `make lint-fix` | Auto-fixes lint issues |
26+
| **Update API docs** | `make docs-update` | Runs `go run ./cmd/doc-gen/main.go` |
27+
| **Verify CRDs match** | `make verify` | Runs `hack/verify-crds.sh` and `hack/verify-codegen.sh` |
28+
| **Format** | `go fmt ./...` | |
29+
| **Vet** | `go vet ./...` | |
30+
31+
### Important: After changing any API type in `apis/`
32+
33+
Always run in this order:
34+
1. `make generate` — regenerates DeepCopy methods
35+
2. `make manifests` — regenerates CRD YAML files in `config/crd/bases/`, `charts/fluent-operator/crds/`, `charts/fluent-operator-crds/templates/`, and `manifests/setup/`
36+
3. `make docs-update` — regenerates API documentation
37+
38+
CI will fail if generated files are out of date (`git diff --exit-code` is checked).
39+
40+
### Tool versions (auto-installed to `./bin/`)
41+
42+
- controller-gen: v0.18.0
43+
- kustomize: v5.6.0
44+
- golangci-lint: v2.6.2
45+
- ginkgo: v2.27.2
46+
- kind: v0.30.0
47+
48+
## Repository Layout
49+
50+
```
51+
apis/ # CRD type definitions (the most commonly edited area)
52+
fluentbit/v1alpha2/ # Fluent Bit CRDs — types, plugins, webhook
53+
plugins/ # Plugin type definitions (input, filter, output, parser)
54+
fluentd/v1alpha1/ # Fluentd CRDs — types, plugins
55+
plugins/ # Fluentd plugin types (input, filter, output)
56+
generated/ # Generated client code
57+
cmd/
58+
fluent-manager/ # Main operator binary entrypoint (main.go)
59+
fluent-watcher/fluentbit/ # Fluent Bit watcher binary + Dockerfile
60+
fluent-watcher/fluentd/ # Fluentd watcher binary + Dockerfile
61+
doc-gen/ # API doc generation tool
62+
controllers/ # Reconciler implementations
63+
fluentbit_controller.go
64+
fluentbitconfig_controller.go
65+
fluentd_controller.go
66+
fluentdconfig_controller.go
67+
collector_controller.go
68+
pkg/
69+
operator/ # Kubernetes resource builders for DaemonSet/StatefulSet
70+
fluentd/ # Fluentd config rendering
71+
utils/ # Shared utilities
72+
config/ # kubebuilder/kustomize config (RBAC, CRD bases, webhooks)
73+
charts/ # Helm charts (fluent-operator, fluent-operator-crds)
74+
manifests/ # YAML manifests for kubectl-based deployment
75+
hack/ # Shell scripts for verification and CRD mutation
76+
tests/ # E2E test scripts and specs
77+
```
78+
79+
## CI Checks (run on every PR)
80+
81+
1. **Lint** (`.github/workflows/lint.yml`): `golangci-lint run` — runs on all pushes/PRs.
82+
2. **Tests** (`.github/workflows/test.yml`): `go mod tidy && make test` — runs on all pushes/PRs.
83+
3. **Main CI** (`.github/workflows/main.yaml`): Triggered on changes to Go/API/controller files:
84+
- `make generate manifests docs-update` then `git diff --exit-code` (generated code must be committed)
85+
- `make shellcheck` (shell script linting via Docker)
86+
- `make test`
87+
- `make verify` (CRDs and codegen match)
88+
- `make binary` (binary build)
89+
4. **Helm CI** (`.github/workflows/helm-ci.yaml`): Helm chart linting and testing.
90+
91+
## Coding Conventions
92+
93+
- All API types use kubebuilder markers (`+kubebuilder:...`) for validation, defaulting, and CRD generation.
94+
- New Go files must include the Apache 2.0 license header (see `hack/boilerplate.go.txt`).
95+
- Commits require DCO sign-off (`Signed-off-by` line).
96+
- Linter config is in `.golangci.yml` — enabled linters include: errcheck, govet, staticcheck, revive, misspell, unused, ginkgolinter, and others.
97+
- Tests use Ginkgo/Gomega and envtest for controller tests.
98+
99+
## Tips
100+
101+
- Trust these instructions first. Only search the repo if information here is incomplete or incorrect.
102+
- The `make test` target handles envtest binary setup automatically.
103+
- When adding a new Fluent Bit or Fluentd plugin, add the type in `apis/fluentbit/v1alpha2/plugins/` or `apis/fluentd/v1alpha1/plugins/`, then wire it into the relevant config type and run all three generation steps.
104+
- The `manifests/setup/setup.yaml` file is auto-generated — never edit it directly.
105+
- CRD files in `config/crd/bases/` and `charts/` are auto-generated — never edit them directly.

0 commit comments

Comments
 (0)