Skip to content

Commit 17d920a

Browse files
fsouzaclaude
andcommitted
docs: add CLAUDE.md for Claude Code guidance
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7516075 commit 17d920a

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

CLAUDE.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
fake-gcs-server is a Google Cloud Storage API emulator that can be used as:
8+
1. A Go library (`github.com/fsouza/fake-gcs-server/fakestorage`) for integration tests
9+
2. A standalone binary/Docker container for testing GCS-dependent applications in any language
10+
11+
## Common Commands
12+
13+
### Build
14+
```bash
15+
go build
16+
```
17+
18+
### Run Tests
19+
```bash
20+
# Run all tests with race detection
21+
go test -race -vet all -mod readonly ./...
22+
23+
# Run a single test
24+
go test -race -vet all -mod readonly ./fakestorage -run TestName
25+
26+
# Run tests in a specific package
27+
go test -race -vet all -mod readonly ./internal/backend
28+
```
29+
30+
### Lint
31+
```bash
32+
golangci-lint run
33+
staticcheck ./...
34+
```
35+
36+
### Run the Server
37+
```bash
38+
# Default HTTPS on port 4443
39+
./fake-gcs-server
40+
41+
# HTTP mode
42+
./fake-gcs-server -scheme http
43+
44+
# Both HTTP and HTTPS
45+
./fake-gcs-server -scheme both
46+
47+
# With seed data
48+
./fake-gcs-server -data /path/to/seed/data
49+
50+
# See all flags
51+
./fake-gcs-server -help
52+
```
53+
54+
## Architecture
55+
56+
### Package Structure
57+
58+
- **main.go**: CLI entry point, handles server startup with HTTP/HTTPS/both schemes and gRPC multiplexing
59+
- **fakestorage/**: Public Go library package
60+
- `server.go`: Core server implementation, HTTP routing via gorilla/mux
61+
- `object.go`, `bucket.go`: GCS resource handlers
62+
- `upload.go`: Resumable and multipart upload handling
63+
- **internal/backend/**: Storage abstraction layer
64+
- `storage.go`: `Storage` interface definition
65+
- `memory.go`: In-memory backend implementation
66+
- `fs.go`: Filesystem-based backend implementation
67+
- **internal/grpc/**: gRPC server implementation sharing the same backend as HTTP
68+
- **internal/notification/**: Pub/Sub event notifications
69+
- **internal/config/**: CLI configuration parsing
70+
71+
### Key Design Patterns
72+
73+
1. **Backend Abstraction**: The `backend.Storage` interface allows swapping between memory and filesystem storage. Both HTTP and gRPC servers share the same backend instance.
74+
75+
2. **HTTP/gRPC Multiplexing**: The main server multiplexes HTTP and gRPC on the same port by checking the Content-Type header for `application/grpc`.
76+
77+
3. **Public Library API**: The `fakestorage` package is designed for use in Go tests - `Server.Client()` returns a pre-configured `*storage.Client` that talks to the fake server.
78+
79+
### API Endpoints
80+
81+
The server implements:
82+
- JSON API at `/storage/v1/...`
83+
- XML API for public object access
84+
- Upload API at `/upload/storage/v1/...`
85+
- Internal endpoints: `/_internal/healthcheck`, `/_internal/config`, `/_internal/reseed`

0 commit comments

Comments
 (0)