This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
go-octopusdeploy is the official Go API client library for Octopus Deploy, providing programmatic access to the Octopus REST API. The library is hypermedia-driven, meaning API operations are configured at runtime based on Octopus API responses.
Module path: github.com/OctopusDeploy/go-octopusdeploy/v2
# Build
go build -a -race -v ./...
# Run all tests
go test -v ./...
# Run a single test
go test -v ./pkg/accounts -run TestAccountServiceAdd
# Run tests in a specific package
go test -v ./pkg/accounts/...
# Vet
go vet -v ./...Integration tests require a live Octopus Deploy instance. Create a .env file at the repo root:
OCTOPUS_HOST=http://your-octopus-instance-url
OCTOPUS_API_KEY=API-YOURAPIKEY
For VS Code, add to .vscode/settings.json:
{
"go.testEnvFile": "${workspaceFolder}/.env"
}The central Client struct aggregates 70+ domain-specific services (e.g., client.Accounts, client.Projects, client.Deployments). Initialize with:
client, err := client.NewClient(nil, apiURL, apiKey, spaceID)All API services implement the IService interface with standardized CRUD operations:
Add,GetByID,Update,DeleteByID- Services use URI templates for hypermedia-driven API navigation
pkg/client/- Main client entry pointpkg/services/- Base service infrastructurepkg/resources/- Generic response wrappers with pagination (Resources[T])pkg/constants/- Service names, operations, URI templatespkg/[domain]/- Domain-specific packages (accounts, projects, deployments, etc.)
Use factory functions for consistent errors:
internal.CreateInvalidParameterError(operation, parameter)internal.CreateRequiredParameterIsEmptyOrNilError(parameter)
When adding enum values, regenerate string representations with enumer:
go install github.com/dmarkham/enumer@latest
# From the package directory containing the enum:
enumer -type=FilterType -json -output filter_type_string.goUnit tests use stretchr/testify/require for assertions. Service tests typically follow this structure:
func createAccountService(t *testing.T) *AccountService {
service := NewAccountService(nil, constants.TestURIAccounts)
require.NotNil(t, service)
return service
}
func TestAccountServiceGetByID(t *testing.T) {
service := createAccountService(t)
resource, err := service.GetByID("")
require.Equal(t, internal.CreateInvalidParameterError(...), err)
require.Nil(t, resource)
}Use Conventional Commits: feat:, fix:, refactor:, test:, docs:
Create a git tag in format v[major].[minor].[patch] (e.g., v1.0.0). Release automation via goreleaser triggers on tag creation.