|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Development Commands |
| 6 | + |
| 7 | +### Testing |
| 8 | +```bash |
| 9 | +# Run acceptance tests (requires QUAY_URL and QUAY_TOKEN environment variables) |
| 10 | +make testacc |
| 11 | +# OR |
| 12 | +TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120m |
| 13 | +``` |
| 14 | + |
| 15 | +### Code Generation |
| 16 | +```bash |
| 17 | +# Generate documentation after code changes |
| 18 | +go generate . |
| 19 | + |
| 20 | +# Generate Quay API client from OpenAPI spec |
| 21 | +make generate-quay-api |
| 22 | +``` |
| 23 | + |
| 24 | +### Build and Formatting |
| 25 | +```bash |
| 26 | +# Format Go code |
| 27 | +gofmt -w . |
| 28 | + |
| 29 | +# Build the provider |
| 30 | +go build . |
| 31 | +``` |
| 32 | + |
| 33 | +## Architecture Overview |
| 34 | + |
| 35 | +This is a Terraform provider for the Quay container registry. The codebase follows standard Terraform provider patterns using the HashiCorp Plugin Framework. |
| 36 | + |
| 37 | +### Core Components |
| 38 | + |
| 39 | +- **Provider Definition**: `internal/provider/provider.go` - Main provider configuration with support for token-based and OAuth2 authentication |
| 40 | +- **Generated API Client**: `quay_api/` - Auto-generated Go client from Quay's OpenAPI specification |
| 41 | +- **Resources & Data Sources**: `internal/provider/*_resource.go` and `internal/provider/*_data_source.go` - Manual implementations |
| 42 | +- **Generated Resources**: `internal/resource_*/` and `internal/datasource_*/` - Auto-generated resource implementations |
| 43 | + |
| 44 | +### Authentication |
| 45 | +The provider supports two authentication methods: |
| 46 | +1. Bearer token authentication (`QUAY_TOKEN`) |
| 47 | +2. OAuth2 password grant flow (`QUAY_OAUTH2_USERNAME`, `QUAY_OAUTH2_PASSWORD`, `QUAY_OAUTH2_CLIENT_ID`, `QUAY_OAUTH2_TOKEN_URL`) |
| 48 | + |
| 49 | +### Code Generation Strategy |
| 50 | +The provider uses a hybrid approach: |
| 51 | +- API client is generated from `code_generator/quay_api.json` using openapi-generator |
| 52 | +- Some resources have both manual implementations (in `internal/provider/`) and generated versions (in `internal/resource_*/`) |
| 53 | +- Configuration files in `code_generator/` drive the generation process |
| 54 | + |
| 55 | +### Resource Types |
| 56 | +- Organizations: Create and manage Quay organizations |
| 57 | +- Teams: Manage organization teams and permissions |
| 58 | +- Robots: Service accounts for automated access |
| 59 | +- Repositories: Container repositories within organizations |
| 60 | + |
| 61 | +### Environment Variables for Testing |
| 62 | +- `QUAY_URL`: Quay instance URL (e.g., https://quay.example.com) |
| 63 | +- `QUAY_TOKEN`: Authentication token for testing |
0 commit comments