Go client library for the Terrakube API.
go get github.com/terrakube-io/terrakube-gopackage main
import (
"context"
"fmt"
"log"
terrakube "github.com/terrakube-io/terrakube-go"
)
func main() {
client, err := terrakube.NewClient(
terrakube.WithEndpoint("https://terrakube.example.com"),
terrakube.WithToken("your-api-token"),
)
if err != nil {
log.Fatal(err)
}
orgs, err := client.Organizations.List(context.Background(), nil)
if err != nil {
log.Fatal(err)
}
for _, org := range orgs {
fmt.Printf("Organization: %s (%s)\n", org.Name, org.ID)
}
}| Resource | Service Field | Scope |
|---|---|---|
| Organization | Organizations |
Top-level |
| Workspace | Workspaces |
Organization |
| Module | Modules |
Organization |
| Module Version | ModuleVersions |
Module |
| Team | Teams |
Organization |
| Team Token | TeamTokens |
Organization |
| Template | Templates |
Organization |
| Tag | Tags |
Organization |
| VCS | VCS |
Organization |
| SSH | SSH |
Organization |
| Agent | Agents |
Organization |
| Collection | Collections |
Organization |
| Collection Item | CollectionItems |
Collection |
| Collection Reference | CollectionReferences |
Collection |
| Variable | Variables |
Workspace |
| Organization Variable | OrganizationVariables |
Organization |
| Workspace Tag | WorkspaceTags |
Workspace |
| Workspace Access | WorkspaceAccess |
Workspace |
| Workspace Schedule | WorkspaceSchedules |
Workspace |
| Webhook | Webhooks |
Workspace |
| Webhook Event | WebhookEvents |
Webhook |
| History | History |
Workspace |
| Job | Jobs |
Organization |
| Action | Actions |
Top-level |
| Step | Steps |
Job |
| Address | Addresses |
Job |
| Project | Projects |
Organization |
| Project Access | ProjectAccess |
Project |
| Federated | Federated |
Top-level |
| Federated Claim | FederatedClaims |
Federated |
| Provider | Providers |
Organization |
| Provider Version | ProviderVersions |
Provider |
| Implementation | Implementations |
Provider Version |
| GitHub App Token | GithubAppTokens |
Top-level |
The APIVersion constant tracks which Terrakube OpenAPI specification version this library targets.
fmt.Println(terrakube.APIVersion) // "2.27.0"| Option | Description | Required |
|---|---|---|
WithEndpoint(url) |
Terrakube server URL | Yes |
WithToken(token) |
API bearer token | Yes |
WithHTTPClient(client) |
Custom *http.Client
|
No |
WithInsecureTLS() |
Skip TLS verification | No |
WithUserAgent(ua) |
Custom User-Agent header | No |
org, err := client.Organizations.Get(ctx, "org-id")
if err != nil {
if terrakube.IsNotFound(err) {
// handle 404
}
if terrakube.IsUnauthorized(err) {
// handle 401
}
// handle other errors
}Requires Go 1.26+ and mise.
mise install # install tools
mise run test # run tests
mise run lint # run linter
mise run check # vet + lint + test
mise run coverage # test with coverage reportFull API reference is available on pkg.go.dev. This README covers quickstart and configuration basics.
Apache 2.0 - see LICENSE.