Skip to content

Commit 794e52c

Browse files
tiwilliaclaude
andcommitted
docs: Add CLAUDE.md file for AI assistant guidance
Add comprehensive CLAUDE.md documentation to guide Claude Code instances working with this repository. Includes: - Essential build commands (make test, build, lint, fmt, coverage) - Architecture overview of OCM-common shared utilities - Code organization patterns and design principles - Development standards including Ginkgo testing requirements - JIRA integration workflow and commit message conventions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent e8ad796 commit 794e52c

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

CLAUDE.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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+
OCM-Common is a Go library providing shared utility functions for OpenShift Cluster Manager (OCM) clients and services. It eliminates code duplication across OCM codebases by centralizing common functionality for AWS operations, cluster management, validation, and testing utilities.
8+
9+
## Development Commands
10+
11+
### Build and Test
12+
- `make build` - Build the project
13+
- `make test` - Run all unit tests
14+
- `make coverage` - Run tests with coverage report
15+
- `make fmt` - Format code using gofmt
16+
- `make lint` - Run golangci-lint with 5-minute timeout
17+
- `make clean` - Clean build artifacts
18+
19+
### Testing Framework
20+
- Uses Ginkgo for all testing (third-party testing packages are rejected)
21+
- Test files follow `*_test.go` naming convention
22+
- Test suites use `*_suite_test.go` naming convention
23+
24+
## Code Architecture
25+
26+
### Core Package Structure
27+
28+
#### AWS Integration (`pkg/aws/`)
29+
- **aws_client/**: Centralized AWS SDK v2 client with support for multiple AWS services (EC2, Route53, IAM, KMS, CloudFormation, etc.)
30+
- **consts/**: AWS-related constants and default values
31+
- **validations/**: AWS resource validation utilities including IAM helpers and tag validation
32+
- **utils/**: AWS-specific utility functions
33+
34+
#### OCM Integration (`pkg/ocm/`)
35+
- **client/**: Generic OCM client interfaces using Go generics for type-safe resource operations
36+
- `SingleClusterSubResource[T]`: For 1:1 cluster resources (KubeletConfig, ClusterAutoscaler)
37+
- `CollectionClusterSubResource[T, S]`: For 1:many cluster resources (MachinePools, NodePools)
38+
- **config/**: OCM configuration and token management
39+
- **connection-builder/**: OCM connection establishment utilities
40+
41+
#### Validation Framework (`pkg/*/validations/`)
42+
- Distributed validation utilities across multiple packages
43+
- Common patterns for resource validation (cluster nodes, passwords, KMS ARNs)
44+
- Reusable validation helpers and error handling
45+
46+
#### Utility Components
47+
- **utils/parser/**: Parsing utilities including SQL parser, state machines, and string parsing
48+
- **test/**: Testing utilities for VPC operations, KMS key management, and mock interfaces
49+
- **log/**: Centralized logging utilities
50+
- **deprecation/**: HTTP transport wrapper for handling deprecation headers
51+
52+
### Key Design Patterns
53+
54+
#### Generic Client Interfaces
55+
The OCM client package uses Go generics to provide type-safe, reusable client interfaces:
56+
```go
57+
type SingleClusterSubResource[T any] interface {
58+
Get(ctx context.Context, clusterId string) (*T, error)
59+
Create(ctx context.Context, clusterId string, instance *T) (*T, error)
60+
Update(ctx context.Context, clusterId string, instance *T) (*T, error)
61+
Delete(ctx context.Context, clusterId string) error
62+
}
63+
```
64+
65+
#### AWS Client Factory
66+
Centralized AWS client creation with support for multiple credential sources:
67+
- Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
68+
- Shared credentials file
69+
- AWS profiles
70+
- IAM roles
71+
72+
## Development Standards
73+
74+
### Commit Message Format
75+
Follow conventional commits with JIRA ticket integration:
76+
```
77+
<type>[JIRA-TICKET] | [TYPE]: <MESSAGE>
78+
79+
[optional BODY]
80+
81+
[optional FOOTER(s)]
82+
```
83+
84+
Types: `feat`, `fix`, `build`, `ci`, `docs`, `perf`, `refactor`, `style`, `test`
85+
86+
### Code Requirements
87+
- All code must be covered by tests using Ginkgo
88+
- Follow existing code patterns and conventions
89+
- Use existing AWS SDK v2 and OCM SDK patterns
90+
- Maintain backward compatibility for shared utilities
91+
92+
### JIRA Integration
93+
- All changes require JIRA tickets in the OCM project
94+
- Link PRs with `JIRA: OCM-xxxx` format
95+
- Follow sprint workflow: Todo → In Progress → Code Review → Review → Done
96+
97+
## Testing Strategy
98+
99+
### Mock Generation
100+
- Use `go.uber.org/mock` for mock generation
101+
- Mock files located in `*/test/` directories
102+
- OCM client mocks available in `pkg/ocm/client/test/`
103+
104+
### Test Organization
105+
- Unit tests alongside source code (`*_test.go`)
106+
- Test suites for package-level setup (`*_suite_test.go`)
107+
- Integration test utilities in dedicated `test/` packages
108+
109+
## Common Patterns
110+
111+
### Error Handling
112+
- Use structured logging via `pkg/log`
113+
- Return detailed error information for AWS operations
114+
- Handle HTTP status codes appropriately (404 for non-existent resources)
115+
116+
### Resource Management
117+
- Context-aware operations throughout
118+
- Proper cleanup of AWS resources in tests
119+
- Pagination support for list operations
120+
121+
### Configuration
122+
- Support multiple AWS credential methods
123+
- Environment variable configuration where appropriate
124+
- Default values defined in constants packages

0 commit comments

Comments
 (0)