|
| 1 | +# Repository Conventions |
| 2 | + |
| 3 | +This document defines the naming and structural conventions for the Stellar-K8s repository. |
| 4 | +Following these conventions keeps the directory tree easy to skim and reduces surprises for |
| 5 | +contributors navigating the codebase for the first time. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Directory Layout |
| 10 | + |
| 11 | +``` |
| 12 | +Stellar-K8s/ |
| 13 | +├── assets/ Logo and static images |
| 14 | +├── benchmarks/ k6 performance tests and baseline results |
| 15 | +├── bundle/ OLM bundle (generated — do not hand-edit) |
| 16 | +├── charts/ Helm charts |
| 17 | +│ └── stellar-operator/ |
| 18 | +├── config/ Kubernetes manifests and CRDs (see config/README.md) |
| 19 | +│ ├── crd/ Generated CRD YAML files |
| 20 | +│ ├── samples/ Example resources for testing |
| 21 | +│ ├── manifests/ OLM CSV bases and Gatekeeper policies |
| 22 | +│ └── dev/ Local dev kubeconfigs (not for production) |
| 23 | +├── docs/ All project documentation (see docs/README.md) |
| 24 | +├── examples/ Ready-to-use StellarNode manifests |
| 25 | +├── monitoring/ Grafana dashboards and Prometheus alert rules |
| 26 | +├── policy/ CEL and OPA policies |
| 27 | +├── schemas/ JSON schemas |
| 28 | +├── scripts/ Operational scripts |
| 29 | +│ ├── dev-utils/ Development helper utilities |
| 30 | +│ ├── lib/ Shared script library functions |
| 31 | +│ └── archive/ Historical one-off scripts (not part of normal workflow) |
| 32 | +├── security/ Security policies and SBOM |
| 33 | +├── src/ Rust source code |
| 34 | +├── tests/ Integration and E2E tests |
| 35 | +└── tools/ CLI and utility tools |
| 36 | +``` |
| 37 | + |
| 38 | +Each top-level directory has a single, obvious purpose. If a new directory is needed, add it |
| 39 | +here and keep its name lowercase with hyphens (`kebab-case`). |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## Naming Rules |
| 44 | + |
| 45 | +### Rust source files and modules |
| 46 | + |
| 47 | +| Element | Convention | Example | |
| 48 | +|---|---|---| |
| 49 | +| File names | `snake_case.rs` | `disk_scaler.rs` | |
| 50 | +| Module directories | `snake_case/` | `rest_api/` | |
| 51 | +| Public types and traits | `UpperCamelCase` | `StellarNode` | |
| 52 | +| Public functions | `snake_case` | `reconcile_node` | |
| 53 | +| Constants | `SCREAMING_SNAKE_CASE` | `STELLAR_NODE_FINALIZER` | |
| 54 | +| Feature flags (`#[cfg]`) | `kebab-case` | `rest-api`, `metrics` | |
| 55 | + |
| 56 | +### Documentation files |
| 57 | + |
| 58 | +| Element | Convention | Example | |
| 59 | +|---|---|---| |
| 60 | +| File names | `kebab-case.md` | `disk-scaling.md` | |
| 61 | +| Directory names | `kebab-case/` | `deployment-guides/` | |
| 62 | +| Root-level docs | ALL-CAPS.md for repo meta | `README.md`, `CONTRIBUTING.md` | |
| 63 | + |
| 64 | +Documentation files that belong to a topic area go in the matching `docs/<topic>/` subdirectory. |
| 65 | +Root-level files (`README.md`, `DEVELOPMENT.md`, `CONTRIBUTING.md`, `CONVENTIONS.md`) are |
| 66 | +entry points only — detailed content belongs in `docs/`. |
| 67 | + |
| 68 | +### Shell scripts |
| 69 | + |
| 70 | +| Element | Convention | Example | |
| 71 | +|---|---|---| |
| 72 | +| File names | `kebab-case.sh` | `setup-mac.sh` | |
| 73 | +| Operational scripts | live in `scripts/` | `scripts/validate.sh` | |
| 74 | +| Historical / one-off | move to `scripts/archive/` | `scripts/archive/create_batch_2_issues.sh` | |
| 75 | + |
| 76 | +Every script must pass `shellcheck -S error` before merging. |
| 77 | + |
| 78 | +### Kubernetes manifests |
| 79 | + |
| 80 | +| Element | Convention | Example | |
| 81 | +|---|---|---| |
| 82 | +| CRD files | `stellar{feature}-crd.yaml` | `stellarnode-crd.yaml` | |
| 83 | +| Sample files | descriptive, lowercase, hyphens | `test-stellarnode.yaml` | |
| 84 | +| Example files | feature-based, no issue numbers | `validator-mainnet.yaml` | |
| 85 | +| Helm chart values | `values.yaml` (defaults), `values-ha.yaml` (variants) | — | |
| 86 | + |
| 87 | +**CRD naming**: All CRD YAML files under `config/crd/` follow the `stellar{feature}-crd.yaml` |
| 88 | +pattern. The resource kind in the file itself uses `UpperCamelCase` (e.g. `StellarNode`). |
| 89 | + |
| 90 | +**Example manifests**: Files in `examples/` use descriptive, feature-based names. Issue numbers |
| 91 | +must not appear in filenames — use the feature name instead |
| 92 | +(e.g. `advanced-features-compliance-upgrade-scaling.yaml`, not `advanced-features-500-503.yaml`). |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +## File Placement Rules |
| 97 | + |
| 98 | +1. **Source files**: Go in the most specific module directory under `src/`. Do not place new |
| 99 | + `.rs` files directly in `src/` unless they are top-level entry points (`main.rs`, `lib.rs`, |
| 100 | + `error.rs`, `cli.rs`). |
| 101 | + |
| 102 | +2. **Documentation files**: Go in the matching `docs/<topic>/` subdirectory. New files must be |
| 103 | + linked from `docs/README.md` under the appropriate section. |
| 104 | + |
| 105 | +3. **Config files**: Go under `config/` with a clear subdirectory. Use `config/crd/` for CRDs, |
| 106 | + `config/samples/` for test resources, and `config/manifests/` for OLM bases. |
| 107 | + |
| 108 | +4. **Scripts**: Operational scripts go in `scripts/`. One-off or historical scripts go in |
| 109 | + `scripts/archive/`. Scripts must not live at the repository root. |
| 110 | + |
| 111 | +5. **Generated files**: Never hand-edit generated files. Always regenerate from source. |
| 112 | + See the [Regenerating Manifests](DEVELOPMENT.md#regenerating-manifests) table. |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | +## Generated vs Hand-Written Files |
| 117 | + |
| 118 | +| File or directory | Hand-written? | Source of truth | |
| 119 | +|---|---|---| |
| 120 | +| `config/crd/*.yaml` | No | `src/crd/` Rust types | |
| 121 | +| `bundle/manifests/*.yaml` | No | `config/manifests/bases/` + operator-sdk | |
| 122 | +| `docs/api-reference.md` | No | `src/crd/` + `make generate-api-docs` | |
| 123 | +| Shell completions | No | `src/cli.rs` + `make completions` | |
| 124 | +| `charts/stellar-operator/values.yaml` | Yes | — | |
| 125 | +| `config/operator-config.yaml` | Yes | — | |
| 126 | +| `docs/**/*.md` (other than api-reference) | Yes | — | |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## Enforcement |
| 131 | + |
| 132 | +These conventions are enforced by: |
| 133 | + |
| 134 | +- **Pre-commit hooks** (`shellcheck`, `cargo fmt`, `yamllint`) — run `make pre-commit-install` |
| 135 | +- **CI lint step** (`cargo clippy`, `make fmt-check`) — runs on every PR |
| 136 | +- **PR checklist** in [CONTRIBUTING.md](CONTRIBUTING.md#9-repo-health-checklist) |
| 137 | + |
| 138 | +If you find a file that violates these conventions and is not covered by the checklist, open |
| 139 | +a PR to fix it or add it to the checklist. |
0 commit comments