No description
  • Go 99.9%
  • Shell 0.1%
Find a file
Madhu S 8a053428f5 feat: [PL-31818]: Terraform support for force deletion of connectors & secrets. (#697)
* 2383d5 feat: [PL-31818]: cleaning code

* d4bbc2 feat: [PL-31818]: cleaning code

* c61ca2 feat: [PL-31818]: Terraform support for force deletion of connectors & secrets.
2025-12-08 05:53:39 +00:00
.chglog Added changelog setup 2022-03-09 01:31:12 -05:00
.github Update codeOwner for client.go 2025-10-16 14:00:12 +05:30
.harness Update codeOwner for client.go 2025-10-16 14:00:12 +05:30
docs feat:[CDS-57089]: added Jira Pat auth type 2023-06-22 18:21:32 +05:30
harness feat: [PL-31818]: Terraform support for force deletion of connectors & secrets. (#697) 2025-12-08 05:53:39 +00:00
logging Fixed Masking of API Key In Debug Console 2023-03-16 18:33:55 +05:30
tools Docker test fixes (#100) 2022-04-13 16:26:22 -04:00
.envrc Format Files + add golangci-lint (#26) 2021-07-01 19:04:21 -04:00
.gitignore Format Files + add golangci-lint (#26) 2021-07-01 19:04:21 -04:00
.golangci.yaml Updated tooling configuration 2022-03-09 00:14:14 -05:00
.tool-versions UPDATES updated golang to 1.17 2022-03-10 00:30:14 -05:00
CHANGELOG.md Release v0.4.22 2024-12-17 03:36:39 +00:00
go.mod chore: [CHAOS-6882]: Added Chaos resources including client for registerInfraV2 API (#585) 2024-10-16 13:27:51 +05:30
go.sum chore: [CHAOS-6882]: Added Chaos resources including client for registerInfraV2 API (#585) 2024-10-16 13:27:51 +05:30
LICENSE.md Added license and updated readme 2021-09-30 08:55:25 -04:00
Makefile Config as code environments (#28) 2021-08-07 19:02:39 -04:00
README.md docs: add status badges for release, docs and license to README 2025-08-27 13:52:05 +05:30
sdk.go Updated tooling configuration 2022-03-09 00:14:14 -05:00

Harness SDK for Go

Latest Release Go Reference License

This project is a Harness SDK for the go programming language. It provides go client for interacting with the current gen GraphQL and Config-as-Code API's.

Disclaimer

This product is not supported by the Harness Customer support team. If you have any questions please open a new issue or join our slack channel.

Getting Started

Installing

Use go get to retrieve the SDK to add it to your GOPATH workspace, or project's Go module dependencies.

go get github.com/harness/harness-go-sdk

To update the SDK use go get -u to retrieve the latest version of the SDK.

go get -u github.com/harness/harness-go-sdk

Dependencies

The metadata of the SDK's dependencies can be found in the Go module file go.mod.

Go Modules

If you are using Go modules, your go get will default to the latest tagged release version of the SDK. To get a specific release version of the SDK use @<tag> in your go get command.

go get github.com/harness/harness-go-sdk@v0.2.11

To get the latest SDK repository change use @latest.

go get github.com/harness/harness-go-sdk@latest

Quick Examples

Get an application by name

client := NewClient()
app, err := client.ApplicationClient.GetApplicationByName("my-app)

Create a Service

svc, _ := ServiceFactory(app.Id, serviceName, cac.DeploymentTypes.Kubernetes, cac.ArtifactTypes.Docker)
svc.ApplicationId = app.Id

newService, err := client.Services().UpsertService(svc)

Configuration

There are a few environment variables you can set to configure the api client.

  • HARNESS_ACCOUNT_ID: (required) The ID of the harness account you are connecting to.
  • HARNESS_API_KEY: (required) The API Key used for authentication.
  • HARNESS_BEARER_TOKEN: (optional) The authentication bearer token. This is needed for certain API calls to the config-as-code API's. This will be deprecated in the near future once those endpoints are updated.
  • HARNESS_ENDPOINT: (optional) The FQDN for contacting the Harness managers. Defaults to https://app.harness.io.

If you need to provide additional configuration you can create a client object from scratch.

client := &Client{
    UserAgent:   getUserAgentString(),
    Endpoint:    utils.GetEnv(envvar.Endpoint, utils.DefaultApiUrl),
    AccountId:   os.Getenv(envvar.AccountId),
    APIKey:      os.Getenv(envvar.ApiKey),
    BearerToken: os.Getenv(envvar.BearerToken),
    HTTPClient: &retryablehttp.Client{
        RetryMax:     10,
        RetryWaitMin: 5 * time.Second,
        RetryWaitMax: 10 * time.Second,
        HTTPClient: &http.Client{
            Timeout: 10 * time.Second,
        },
        Backoff:    retryablehttp.DefaultBackoff,
        CheckRetry: retryablehttp.DefaultRetryPolicy,
    },
}

The github.com/hashicorp/go-retryablehttp is essentially a drop-in replacement for the http package and is used to handle retries when getting rate limited.