-
Notifications
You must be signed in to change notification settings - Fork 76
Add CLAUDE.md onboarding guide #1272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
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
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| # CLAUDE.md β uaa-release | ||
|
|
||
| ## System Overview | ||
|
|
||
| `uaa-release` is a **BOSH release** that packages and deploys [Cloud Foundry UAA](https://github.com/cloudfoundry/uaa) (the OAuth2/SSO identity provider for Cloud Foundry) as a set of VMs/jobs on a BOSH-managed platform. This repo does not contain UAA's application logic β that lives in the `src/uaa` git submodule (a separate Java/Spring Boot codebase) β it contains the **deployment glue**: ERB templates, packaging scripts, BOSH job/package specs, and Ruby/Go tests that turn the UAA WAR file into a runnable, configurable BOSH job. Architecturally this is a **BOSH release (packaging + deployment orchestration)** around a monolithic Java web application (Tomcat or embedded Spring Boot Tomcat), not a microservices system. | ||
|
|
||
| ## Core Tech Stack & Tools | ||
|
|
||
| - **Deployment framework**: [BOSH](https://bosh.io) release format (`jobs/`, `packages/`, `spec` files, `.final_builds`/`.dev_builds`) | ||
| - **Application runtime** (packaged, not authored here): Java (BellSoft JDK, see `jdk-25.0.3/`), Apache Tomcat (`apache-tomcat-*.tar.gz`), Spring Boot (embedded Tomcat mode) | ||
| - **Templating**: ERB (`*.erb` files under `jobs/*/templates`) rendered by BOSH into job configs (`uaa.yml`, `bpm.yml`, `log4j2.properties`, `tomcat/server.xml`, etc.) | ||
| - **Config/process supervision**: [BPM](https://github.com/cloudfoundry/bpm-release) (`config/bpm.yml.erb`), Monit (`jobs/*/monit`) | ||
| - **Test frameworks**: | ||
| - Ruby / RSpec (`bundle exec rake` or `rspec spec`) β validates ERB template rendering against fixture manifests (`spec/input/*.yml` β `spec/compare/*`) | ||
| - Go / Ginkgo (`src/acceptance_tests`) β end-to-end acceptance tests run as a BOSH errand job against a live deployment | ||
| - **Dependency management**: Bundler (`Gemfile`/`Gemfile.lock`) for Ruby, Go modules (`go.mod`/`go.sum`) for acceptance tests, git submodule for `src/uaa` | ||
| - **CI**: GitHub Actions (`.github/`) | ||
| - **Backup/restore**: [BBR](https://github.com/cloudfoundry-incubator/bosh-backup-and-restore) scripts for the UAA database (`jobs/bbr-uaadb`) | ||
|
|
||
| ## Repository Directory Structure | ||
|
|
||
| ``` | ||
| uaa-release/ | ||
| βββ jobs/ # BOSH job definitions β one per deployable role | ||
| β βββ uaa/ # The UAA app itself | ||
| β β βββ spec # Job spec: properties, templates, provides/consumes links | ||
| β β βββ monit # Process supervision config | ||
| β β βββ templates/ # ERB templates rendered at deploy time | ||
| β β βββ bin/ # start/stop/health-check/pre-start scripts | ||
| β β βββ config/ # uaa.yml, bpm.yml, log4j2, tomcat server.xml, etc. | ||
| β β βββ bbr/ # backup/restore lock scripts | ||
| β βββ bbr-uaadb/ # Errand job: backup/restore of the UAA database via BBR | ||
| β βββ acceptance-tests/ # Errand job: runs the Go/Ginkgo acceptance suite on-network | ||
| β βββ templates/run.erb # entrypoint invoked by `bosh run-errand` | ||
| βββ packages/ # BOSH packages β how binaries are compiled/assembled | ||
| β βββ uaa/ | ||
| β β βββ packaging # Bash script: unpacks JDK + Tomcat, drops in the UAA WAR | ||
| β β βββ spec # Declares source files (uaa/**/*, JDK tarball, Tomcat tarball) | ||
| β βββ acceptance-tests/ # Packaging for the Go acceptance test binary | ||
| βββ src/ | ||
| β βββ uaa/ # GIT SUBMODULE β github.com/cloudfoundry/uaa (Java/Spring app) | ||
| β β # UAA's actual application code lives here, NOT in this repo | ||
| β βββ acceptance_tests/ # Go source for the Ginkgo acceptance suite (not a submodule) | ||
| βββ spec/ # Ruby RSpec tests for this release's ERB templates | ||
| β βββ *_spec.rb # e.g. uaa-release.erb_spec.rb, tomcat.server.xml.erb_spec.rb | ||
| β βββ input/ # sample BOSH manifests used as spec fixtures | ||
| β βββ compare/ # expected rendered output, diffed against actual render | ||
| β βββ support/ # custom matchers (e.g. yaml_eq) | ||
| βββ config/ # Release-level blob/final-version tracking (blobs.yml, final.yml) | ||
| βββ scripts/ # Dev workflow scripts: create-dev-release, run-locally, test-runner, etc. | ||
| βββ bin/ # CI/release helper scripts (build/deploy, show version, licenses) | ||
| βββ docs/ # Legacy bosh-micro-cli era docs | ||
| βββ releases/uaa/ # Finalized release manifests (*.yml) tracked per version | ||
| βββ .dev_builds/ , .final_builds/# BOSH-managed blob storage for compiled dev/final releases | ||
| βββ Rakefile, Gemfile # Ruby test runner entrypoint (`rake` β runs spec/**/*_spec.rb) | ||
| βββ manifest*.yml, opsfile.yml # Example/working BOSH deployment manifests + an ops-file | ||
| ``` | ||
|
|
||
| ## Key Architecture & Data Flow | ||
|
|
||
| **Build/package time** (`bosh create-release` / CI): | ||
| `packages/uaa/spec` (declares inputs: `src/uaa` submodule output, JDK tarball, Tomcat tarball) β `packages/uaa/packaging` (bash script compiles/assembles: unpacks JDK, unpacks Tomcat, copies in `cloudfoundry-identity-uaa.war` as `ROOT.war`, copies the statsd WAR and Tomcat listener jar) β a versioned, immutable **compiled package** blob. | ||
|
|
||
| **Deploy time** (`bosh deploy`): | ||
| Operator-supplied BOSH manifest properties β `jobs/uaa/spec` (declares/validates properties, and BOSH links like `uaa_db`, `uaa_keys`, `router`, `database`) β ERB templates under `jobs/uaa/templates/` are rendered with those properties β produces `config/uaa.yml`, `config/bpm.yml`, `config/tomcat/server.xml`, `config/log4j2.properties`, `bin/pre-start`, `bin/health_check`, etc. on the target VM β **Monit** starts the job via **BPM**, which launches either Tomcat (WAR deployment, `runtime.tomcat.enabled=true`) or the embedded Spring Boot runtime β the running UAA app talks to the UAA database (via the `uaa_db`/`database` BOSH link) and optionally an LDAP/SAML IdP per configured properties. | ||
|
|
||
| **Errand jobs** run on-demand via `bosh run-errand`: | ||
| - `acceptance-tests` β deployed alongside UAA on the same network, shells out to `bosh ssh`/`bosh scp` and makes HTTP calls directly to the UAA instance (deliberately avoids jumpboxes, per the comment in `jobs/acceptance-tests/spec`). | ||
|
duanemay marked this conversation as resolved.
|
||
| - `bbr-uaadb` β invoked by BOSH Backup and Restore to lock/dump/restore the UAA database. | ||
|
|
||
| **Verification loop** (this repo's own tests, not UAA's): RSpec renders each ERB template against fixture manifests in `spec/input/*.yml` and diffs the output against golden files in `spec/compare/*`, catching template regressions before a real deploy. | ||
|
|
||
| ## Development Setup & Crucial Commands | ||
|
|
||
| **Requirements**: Ruby + Bundler (template tests), Go (acceptance tests), a BOSH director + `bosh` CLI (real deploys), git submodules initialized (`src/uaa`). | ||
|
|
||
| | Task | Command | | ||
| |---|---| | ||
| | Clone with submodules | `git clone --recursive <repo>` or `git submodule update --init` | | ||
| | Install Ruby deps | `bundle install` | | ||
| | Run all template specs | `bundle exec rake` (or `bundle exec rspec spec`) | | ||
| | Run a single template spec | `bundle exec rspec spec/uaa-release.erb_spec.rb` | | ||
| | Run Ruby template tests (explicit) | `scripts/run-template-tests.rb` | | ||
| | Shellcheck the release's scripts | `scripts/shellcheck.sh` | | ||
| | Create a dev release (local blob) | `scripts/create-dev-release.sh` | | ||
| | Deploy locally against bosh-lite/local director | `scripts/run-locally.sh` | | ||
| | Run acceptance tests locally (Docker) | `./scripts/run-locally.sh` then `go run github.com/onsi/ginkgo/ginkgo -v --progress --trace -r .` inside `src/acceptance_tests` (see `src/acceptance_tests/README.md`; do **not** use Docker for Mac β it's broken for this flow) | | ||
|
duanemay marked this conversation as resolved.
|
||
| | Run acceptance tests via BOSH errand | `bosh run-errand acceptance-tests` | | ||
| | Perform an official release | `scripts/perform-release.sh` | | ||
| | Refresh a local uaa-release deployment | `scripts/refresh-uaa-deployment.sh` | | ||
| | Tear down local BOSH env | `scripts/teardown-local.sh` | | ||
|
|
||
| ## Guardrails & Design Patterns | ||
|
|
||
| - **Never edit UAA application code in this repo.** `src/uaa` is a pinned git submodule tracking `github.com/cloudfoundry/uaa`. Application/business-logic changes belong in that upstream repo and land here only as a submodule SHA bump (see recent commit history: `Bump UAA to <sha>`). This repo owns *packaging and deployment*, not app behavior. | ||
| - **Every property exposed to operators must be declared in the job `spec` file** (`jobs/uaa/spec`, `jobs/bbr-uaadb/spec`, `jobs/acceptance-tests/spec`) before it can be referenced in an ERB template β BOSH validates templates against the spec's `properties:` block. | ||
| - **Template changes require a corresponding RSpec fixture/golden-file update.** Any change to a file under `jobs/*/templates` should have a matching case in `spec/*_spec.rb`, an input manifest in `spec/input/`, and expected output in `spec/compare/`. Run `bundle exec rake` before considering a template change done. | ||
| - **Deprecated properties must keep working.** See `spec/input/deprecated-properties-still-work.yml` β this release maintains backward compatibility for renamed/deprecated manifest properties rather than breaking existing deployments. | ||
| - **Packaging scripts (`packages/*/packaging`) run with `set -e -x`** β treat them as fail-fast; don't suppress errors, and any added step should preserve strict-mode safety (check exit codes explicitly where subshells are involved, as the existing JDK/Tomcat unpack steps do). | ||
| - **Errand jobs run on-network deliberately.** The `acceptance-tests` job's placement is a documented workaround (see comment block in `jobs/acceptance-tests/spec`) for jumpbox/SOCKS5 timeouts and read-only `/etc/hosts` on Concourse workers β don't "simplify" this back onto an off-network worker without re-reading that rationale. | ||
| - **Two build stages exist for blobs**: `.dev_builds/` (local, iterative) vs `.final_builds/` (official, versioned) β tracked via `config/blobs.yml`/`config/final.yml`. Don't hand-edit blob directories; use the `scripts/`/`bosh create-release --final` flow. | ||
| - **Repo-root scratch/diagnostic files are not part of the release.** Files like `check-*.sh`, `find-*.sh`, `*-diagnostics.md`, `tomcat-troubleshooting-guide.md`, `manifest-*.yml` variants, and the `apache-tomcat-*.tar.gz`/`jdk-25.0.3/` directories at repo root are local working/debug artifacts, not tracked release inputs β the canonical manifest inputs are `manifest.yml`/`opsfile.yml` and the `jobs/`/`packages/` specs. | ||
|
duanemay marked this conversation as resolved.
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.