Skip to content

Commit ec103a7

Browse files
add AGENTS.md and also updated API documentation
1 parent 754a055 commit ec103a7

File tree

3 files changed

+353
-30
lines changed

3 files changed

+353
-30
lines changed

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CLAUDE.md

CLAUDE.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Commands
6+
7+
### Testing
8+
```bash
9+
# Run all tests with race detection (requires MinIO server at localhost:9000)
10+
SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 MINT_MODE=full go test -race -v ./...
11+
12+
# Run tests without race detection
13+
go test ./...
14+
15+
# Run short tests only (no functional tests)
16+
go test -short -race ./...
17+
18+
# Run functional tests
19+
go build -race functional_tests.go
20+
SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=1 MINT_MODE=full ./functional_tests
21+
22+
# Run functional tests without TLS
23+
SERVER_ENDPOINT=localhost:9000 ACCESS_KEY=minioadmin SECRET_KEY=minioadmin ENABLE_HTTPS=0 MINT_MODE=full ./functional_tests
24+
```
25+
26+
### Linting and Code Quality
27+
```bash
28+
# Run all checks (lint, vet, test, examples, functional tests)
29+
make checks
30+
31+
# Run linter only
32+
make lint
33+
34+
# Run vet and staticcheck
35+
make vet
36+
37+
# Alternative: run golangci-lint directly
38+
golangci-lint run --timeout=5m --config ./.golangci.yml
39+
```
40+
41+
### Building Examples
42+
```bash
43+
# Build all examples
44+
make examples
45+
46+
# Build a specific example
47+
cd examples/s3 && go build -mod=mod putobject.go
48+
```
49+
50+
## Architecture
51+
52+
### Core Client Structure
53+
The MinIO Go SDK is organized around a central `Client` struct (api.go:52) that implements Amazon S3 compatible methods. Key architectural patterns:
54+
55+
1. **Modular API Organization**: API methods are split into logical files:
56+
- `api-bucket-*.go`: Bucket operations (lifecycle, encryption, versioning, etc.)
57+
- `api-object-*.go`: Object operations (legal hold, retention, tagging, etc.)
58+
- `api-get-*.go`, `api-put-*.go`: GET and PUT operations
59+
- `api-list.go`: Listing operations
60+
- `api-stat.go`: Status/info operations
61+
62+
2. **Credential Management**: The `pkg/credentials/` package provides various credential providers:
63+
- Static credentials
64+
- Environment variables (AWS/MinIO)
65+
- IAM roles
66+
- STS (Security Token Service) variants
67+
- File-based credentials
68+
- Chain provider for fallback mechanisms
69+
70+
3. **Request Signing**: The `pkg/signer/` package handles AWS signature versions:
71+
- V2 signatures (legacy)
72+
- V4 signatures (standard)
73+
- Streaming signatures for large uploads
74+
75+
4. **Transport Layer**: Custom HTTP transport with:
76+
- Retry logic with configurable max retries
77+
- Health status monitoring
78+
- Tracing support via httptrace
79+
- Bucket location caching (`bucketLocCache`)
80+
- Session caching for credentials
81+
82+
5. **Helper Packages**:
83+
- `pkg/encrypt/`: Server-side encryption utilities
84+
- `pkg/notification/`: Event notification handling
85+
- `pkg/policy/`: Bucket policy management
86+
- `pkg/lifecycle/`: Object lifecycle rules
87+
- `pkg/tags/`: Object and bucket tagging
88+
- `pkg/s3utils/`: S3 utility functions
89+
- `pkg/kvcache/`: Key-value caching
90+
- `pkg/singleflight/`: Deduplication of concurrent requests
91+
92+
### Testing Strategy
93+
- Unit tests alongside implementation files (`*_test.go`)
94+
- Comprehensive functional tests in `functional_tests.go` requiring a live MinIO server
95+
- Example programs in `examples/` directory demonstrating API usage
96+
- Build tag `//go:build mint` for integration tests
97+
98+
### Error Handling
99+
- Custom error types in `api-error-response.go`
100+
- HTTP status code mapping
101+
- Retry logic for transient failures
102+
- Detailed error context preservation
103+
104+
## Important Patterns
105+
106+
1. **Context Usage**: All API methods accept `context.Context` for cancellation and timeout control
107+
2. **Options Pattern**: Methods use Options structs for optional parameters (e.g., `PutObjectOptions`, `GetObjectOptions`)
108+
3. **Streaming Support**: Large file operations use io.Reader/Writer interfaces for memory efficiency
109+
4. **Bucket Lookup Types**: Supports both path-style and virtual-host-style S3 URLs
110+
5. **MD5/SHA256 Hashing**: Configurable hash functions for integrity checks via `md5Hasher` and `sha256Hasher`

0 commit comments

Comments
 (0)