{"id":19149834,"url":"https://github.com/harness/harness-go-sdk","last_synced_at":"2026-04-14T08:02:48.121Z","repository":{"id":38183738,"uuid":"377696242","full_name":"harness/harness-go-sdk","owner":"harness","description":"An SDK written in Go for interacting with the Harness API's","archived":false,"fork":false,"pushed_at":"2025-05-06T09:50:41.000Z","size":6376,"stargazers_count":14,"open_issues_count":18,"forks_count":14,"subscribers_count":55,"default_branch":"main","last_synced_at":"2025-05-07T04:45:22.034Z","etag":null,"topics":["cd","ci","golang","harness","sdk"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harness.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-06-17T03:42:31.000Z","updated_at":"2025-05-05T01:53:47.000Z","dependencies_parsed_at":"2023-12-22T05:27:29.186Z","dependency_job_id":"917034b5-9aa6-4c1b-a352-0a356c06d582","html_url":"https://github.com/harness/harness-go-sdk","commit_stats":null,"previous_names":["harness-io/harness-go-sdk"],"tags_count":234,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fharness-go-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fharness-go-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fharness-go-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harness%2Fharness-go-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harness","download_url":"https://codeload.github.com/harness/harness-go-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252816520,"owners_count":21808702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cd","ci","golang","harness","sdk"],"created_at":"2024-11-09T08:09:47.811Z","updated_at":"2026-04-14T08:02:48.039Z","avatar_url":"https://github.com/harness.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Harness Go SDK\n\n[![Latest Release](https://img.shields.io/github/v/release/harness/harness-go-sdk)](https://github.com/harness/harness-go-sdk/releases/latest)\n[![Go Reference](https://pkg.go.dev/badge/github.com/harness/harness-go-sdk.svg)](https://pkg.go.dev/github.com/harness/harness-go-sdk)\n[![License](https://img.shields.io/github/license/harness/harness-go-sdk)](LICENSE.md)\n\nThe official Go SDK for the [Harness Platform](https://harness.io). This SDK provides programmatic access to Harness services including CI/CD pipelines, feature flags, cloud cost management, chaos engineering, and more.\n\n## Disclaimer\n\nThis product is not supported by the Harness Customer support team. If you have any questions please open a [new issue](https://github.com/harness/harness-go-sdk/issues/new) or join our slack [channel](https://harnesscommunity.slack.com/archives/C02G9CUNF1S).\n\n## Installation\n\n```bash\ngo get github.com/harness/harness-go-sdk\n```\n\nTo update to the latest version:\n\n```bash\ngo get -u github.com/harness/harness-go-sdk@latest\n```\n\n## Package Overview\n\nThe SDK is organized into the following packages:\n\n| Package | Description | Documentation |\n|---------|-------------|---------------|\n| [`harness/nextgen`](https://pkg.go.dev/github.com/harness/harness-go-sdk/harness/nextgen) | NextGen Platform APIs (pipelines, connectors, secrets, GitOps, etc.) | [API Docs](https://apidocs.harness.io/) |\n| [`harness/cd`](https://pkg.go.dev/github.com/harness/harness-go-sdk/harness/cd) | FirstGen Continuous Delivery APIs | [FirstGen Docs](https://developer.harness.io/docs/first-gen/) |\n| [`harness/chaos`](https://pkg.go.dev/github.com/harness/harness-go-sdk/harness/chaos) | Chaos Engineering APIs | [Chaos Docs](https://developer.harness.io/docs/chaos-engineering/) |\n| [`harness/code`](https://pkg.go.dev/github.com/harness/harness-go-sdk/harness/code) | Code Repository APIs | [Code Docs](https://developer.harness.io/docs/code-repository/) |\n| [`harness/split`](https://pkg.go.dev/github.com/harness/harness-go-sdk/harness/split) | Split Admin API (Feature Flags / FME) with rate-limit retry | [Split API Reference](https://docs.split.io/reference/) |\n| [`harness/helpers`](https://pkg.go.dev/github.com/harness/harness-go-sdk/harness/helpers) | Common helper utilities | - |\n| [`harness/utils`](https://pkg.go.dev/github.com/harness/harness-go-sdk/harness/utils) | Utility functions | - |\n| [`logging`](https://pkg.go.dev/github.com/harness/harness-go-sdk/logging) | Logging utilities | - |\n\n## Quick Start\n\n### NextGen Platform (Recommended)\n\nMost users should use the `nextgen` package for interacting with the Harness Platform:\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"fmt\"\n    \"os\"\n\n    \"github.com/harness/harness-go-sdk/harness/nextgen\"\n)\n\nfunc main() {\n    // Create configuration\n    cfg := nextgen.NewConfiguration()\n    cfg.BasePath = \"https://app.harness.io/gateway\"\n    cfg.AddDefaultHeader(\"x-api-key\", os.Getenv(\"HARNESS_API_KEY\"))\n\n    // Create client\n    client := nextgen.NewAPIClient(cfg)\n\n    // List organizations\n    accountId := os.Getenv(\"HARNESS_ACCOUNT_ID\")\n    resp, _, err := client.OrganizationApi.GetOrganizationList(\n        context.Background(),\n        accountId,\n        \u0026nextgen.OrganizationApiGetOrganizationListOpts{},\n    )\n    if err != nil {\n        panic(err)\n    }\n\n    for _, org := range resp.Data.Content {\n        fmt.Println(org.Organization.Name)\n    }\n}\n```\n\n### FirstGen (Legacy)\n\nFor FirstGen Harness, use the `cd` package:\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"os\"\n\n    \"github.com/harness/harness-go-sdk/harness/cd\"\n)\n\nfunc main() {\n    // Create client\n    client, err := cd.NewClient(\u0026cd.Config{\n        AccountId: os.Getenv(\"HARNESS_ACCOUNT_ID\"),\n        APIKey:    os.Getenv(\"HARNESS_API_KEY\"),\n        Endpoint:  \"https://app.harness.io\",\n    })\n    if err != nil {\n        panic(err)\n    }\n\n    // Get application by name\n    app, err := client.ApplicationClient.GetApplicationByName(\"my-app\")\n    if err != nil {\n        panic(err)\n    }\n    fmt.Println(app.Id, app.Name)\n}\n```\n\n## Configuration\n\n### Environment Variables\n\n| Variable | Required | Description |\n|----------|----------|-------------|\n| `HARNESS_ACCOUNT_ID` | Yes | Your Harness account identifier |\n| `HARNESS_API_KEY` | Yes | API key for authentication |\n| `HARNESS_ENDPOINT` | No | API endpoint (default: `https://app.harness.io`) |\n| `HARNESS_BEARER_TOKEN` | No | Bearer token for certain FirstGen APIs (deprecated) |\n\n### Generating an API Key\n\n1. Go to the [Harness Platform](https://app.harness.io/)\n2. Navigate to **Account Settings** → **Access Control** → **API Keys**\n3. Click **+ API Key** and create a new key\n4. Save the token securely - it won't be shown again\n\n## Common Examples\n\n### Create a Connector\n\n```go\nconnector := nextgen.Connector{\n    Name:       \"my-github-connector\",\n    Identifier: \"my_github_connector\",\n    Type_:      \"Github\",\n    Spec: map[string]interface{}{\n        \"url\": \"https://github.com/myorg\",\n        \"authentication\": map[string]interface{}{\n            \"type\": \"Http\",\n            \"spec\": map[string]interface{}{\n                \"type\": \"UsernameToken\",\n                \"spec\": map[string]interface{}{\n                    \"username\":     \"myuser\",\n                    \"tokenRef\":     \"account.github_token\",\n                },\n            },\n        },\n    },\n}\n\nresp, _, err := client.ConnectorsApi.CreateConnector(\n    context.Background(),\n    connector,\n    accountIdentifier,\n    nil,\n)\n```\n\n### Create a Secret\n\n```go\nsecret := nextgen.Secret{\n    Name:       \"my-secret\",\n    Identifier: \"my_secret\",\n    Type_:      \"SecretText\",\n    Spec: map[string]interface{}{\n        \"valueType\":       \"Inline\",\n        \"value\":           \"my-secret-value\",\n        \"secretManagerIdentifier\": \"harnessSecretManager\",\n    },\n}\n\nresp, _, err := client.SecretsApi.CreateSecret(\n    context.Background(),\n    secret,\n    accountIdentifier,\n    nil,\n)\n```\n\n### List Pipelines\n\n```go\nresp, _, err := client.PipelinesApi.GetPipelineList(\n    context.Background(),\n    accountIdentifier,\n    orgIdentifier,\n    projectIdentifier,\n    \u0026nextgen.PipelinesApiGetPipelineListOpts{\n        PageIndex: optional.NewInt32(0),\n        PageSize:  optional.NewInt32(20),\n    },\n)\n```\n\n## Error Handling\n\nAPI errors include the HTTP response for additional context:\n\n```go\nresp, httpResp, err := client.OrganizationApi.GetOrganization(\n    context.Background(),\n    orgIdentifier,\n    accountIdentifier,\n    nil,\n)\nif err != nil {\n    if httpResp != nil {\n        fmt.Printf(\"HTTP Status: %d\\n\", httpResp.StatusCode)\n        body, _ := io.ReadAll(httpResp.Body)\n        fmt.Printf(\"Response: %s\\n\", string(body))\n    }\n    return err\n}\n```\n\n## Pagination\n\nList endpoints support pagination:\n\n```go\nopts := \u0026nextgen.OrganizationApiGetOrganizationListOpts{\n    PageIndex: optional.NewInt32(0),\n    PageSize:  optional.NewInt32(50),\n}\nresp, _, err := client.OrganizationApi.GetOrganizationList(ctx, accountId, opts)\n\n// Check for more pages\nif resp.Data.TotalPages \u003e 1 {\n    // Fetch additional pages...\n}\n```\n\n## Advanced Configuration\n\n### Custom HTTP Client\n\n```go\nimport (\n    \"net/http\"\n    \"time\"\n\n    retryablehttp \"github.com/hashicorp/go-retryablehttp\"\n)\n\n// Create a retryable HTTP client\nretryClient := retryablehttp.NewClient()\nretryClient.RetryMax = 3\nretryClient.RetryWaitMin = 1 * time.Second\nretryClient.RetryWaitMax = 5 * time.Second\n\ncfg := nextgen.NewConfiguration()\ncfg.HTTPClient = retryClient.StandardClient()\n```\n\n### Debug Logging\n\nEnable debug logging for troubleshooting:\n\n```go\nimport \"github.com/harness/harness-go-sdk/logging\"\n\nlogger := logging.NewLogger()\nlogger.SetLevel(log.DebugLevel)\n\n// Use with FirstGen client\nclient, _ := cd.NewClient(\u0026cd.Config{\n    AccountId:    accountId,\n    APIKey:       apiKey,\n    DebugLogging: true,\n    Logger:       logger,\n})\n```\n\n## Go Modules\n\nThis SDK uses Go modules. To get a specific version:\n\n```bash\ngo get github.com/harness/harness-go-sdk@v0.7.0\n```\n\n## Contributing\n\nContributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.\n\n## Resources\n\n- [Harness Developer Hub](https://developer.harness.io/)\n- [API Reference](https://apidocs.harness.io/)\n- [Harness Community Slack](https://harnesscommunity.slack.com/)\n\n## License\n\nThis SDK is licensed under the Apache 2.0 License. See [LICENSE.md](LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharness%2Fharness-go-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharness%2Fharness-go-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharness%2Fharness-go-sdk/lists"}