|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Build and Test Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +# Build all packages |
| 9 | +go build ./... |
| 10 | + |
| 11 | +# Run tests |
| 12 | +go test ./... |
| 13 | + |
| 14 | +# Run a single test |
| 15 | +go test -run TestName ./package/... |
| 16 | + |
| 17 | +# Tidy dependencies |
| 18 | +go mod tidy |
| 19 | + |
| 20 | +# Run linter (requires golangci-lint installed) |
| 21 | +golangci-lint run |
| 22 | +``` |
| 23 | + |
| 24 | +## Linting Configuration |
| 25 | + |
| 26 | +The project uses golangci-lint with settings in `.golangci.yaml`: |
| 27 | +- JSON tags use snake_case, YAML tags use camelCase (`tagliatelle` linter) |
| 28 | +- `ioutil.*` functions are forbidden - use `os` and `io` packages instead |
| 29 | +- Enabled linters include: `gofumpt`, `gocritic`, `gosec`, `errcheck`, `govet` |
| 30 | + |
| 31 | +## Architecture Overview |
| 32 | + |
| 33 | +This is a Go SDK for managing Minecraft servers across multiple cloud providers. The SDK follows a provider-agnostic pattern where each cloud provider implements a common interface. |
| 34 | + |
| 35 | +### Core Interfaces |
| 36 | + |
| 37 | +**`automation.Automation`** (`automation/automation.go`) - The central interface all cloud providers must implement: |
| 38 | +- `CreateServer`, `DeleteServer`, `ListServer`, `UpdateServer`, `GetServer`, `UploadPlugin` |
| 39 | + |
| 40 | +**`model.MinecraftResource`** (`model/model.go`) - The configuration model representing a Minecraft server specification with getters for server config, Minecraft edition, SSH settings, etc. |
| 41 | + |
| 42 | +### Package Structure |
| 43 | + |
| 44 | +- **`cloud/`** - Cloud provider implementations. Each subdirectory (akamai, aws, azure, civo, do, exoscale, fuga, gce, hetzner, multipass, oci, openstack, ovh, scaleway, vexxhost, vultr) contains a provider implementing `automation.Automation` |
| 45 | +- **`automation/`** - Interface definitions and shared types (`ServerArgs`, `ResourceResults`) |
| 46 | +- **`model/`** - Data models for Minecraft resource configuration (server spec, SSH, Java settings, etc.) |
| 47 | +- **`template/`** - Go templates for cloud-init and bash scripts used during server provisioning. Templates are embedded via `//go:embed` |
| 48 | +- **`update/`** - Remote server operations via SSH (update server, transfer files, execute commands) |
| 49 | +- **`common/`** - Shared utilities |
| 50 | + |
| 51 | +### Adding a New Cloud Provider |
| 52 | + |
| 53 | +1. Create a new directory under `cloud/` with your provider name |
| 54 | +2. Implement the `automation.Automation` interface |
| 55 | +3. Add provider mapping in `cloud/cloud.go` |
| 56 | +4. Add provider constant in `model/model.go` |
| 57 | + |
| 58 | +### Key Dependencies |
| 59 | + |
| 60 | +- Cloud SDKs: Each provider uses its native SDK (e.g., `aws-sdk-go-v2`, `azure-sdk-for-go`, `gophercloud/v2`, `scaleway-sdk-go`) |
| 61 | +- SSH: `github.com/melbahja/goph` for remote command execution |
| 62 | +- Templates: `github.com/Masterminds/sprig/v3` for template functions |
| 63 | + |
| 64 | +## Commit Requirements |
| 65 | + |
| 66 | +Sign-off commits with `git commit -s` for DCO compliance. |
0 commit comments