Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Harness provider #348

Merged
merged 4 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/component_owners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ components:
providers/unleash:
- liran2000
- sighphyre
providers/harness:
- liran2000
- davejohnston

ignored-authors:
- renovate-bot
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"providers/flagsmith": "0.1.4",
"providers/launchdarkly": "0.1.3",
"providers/unleash": "0.0.2-alpha",
"providers/harness": "0.0.1-alpha",
"tests/flagd": "1.3.1"
}
Empty file.
65 changes: 65 additions & 0 deletions providers/harness/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Unofficial Harness OpenFeature GO Provider

[Harness](https://developer.harness.io/docs/feature-flags) OpenFeature Provider can provide usage for Harness via OpenFeature GO SDK.

# Installation

To use the Harness provider, you'll need to install [Harness Go client](github.com/harness/ff-golang-server-sdk) and Harness provider. You can install the packages using the following command

```shell
go get github.com/harness/ff-golang-server-sdk
go get github.com/open-feature/go-sdk-contrib/providers/harness
```

## Concepts
* Provider Object evaluation gets Harness JSON evaluation.
* Other provider types evaluation gets Harness matching type evaluation.

## Usage
Harness OpenFeature Provider is using Harness GO SDK.

## Usage Example

```go
import (
harness "github.com/harness/ff-golang-server-sdk/client"
harnessProvider "github.com/open-feature/go-sdk-contrib/providers/harness/pkg"
)

providerConfig := harnessProvider.ProviderConfig{
Options: []harness.ConfigOption{
harness.WithWaitForInitialized(true),
harness.WithURL(URL),
harness.WithStreamEnabled(false),
harness.WithHTTPClient(http.DefaultClient),
harness.WithStoreEnabled(false),
},
SdkKey: ValidSDKKey,
}

provider, err := harnessProvider.NewProvider(providerConfig)
if err != nil {
t.Fail()
}
err = provider.Init(of.EvaluationContext{})
if err != nil {
t.Fail()
}

ctx := context.Background()

target := map[string]interface{}{
toddbaert marked this conversation as resolved.
Show resolved Hide resolved
"Identifier": "john",
"Firstname": "John",
"Lastname": "Doe",
"Email": "[email protected]",
}

resolution := provider.BooleanEvaluation(ctx, "TestTrueOn", false, target)
if resolution.Value != true {
t.Fatalf("Expected one of the variant payloads")
}
toddbaert marked this conversation as resolved.
Show resolved Hide resolved

```
See [provider_test.go](./pkg/provider_test.go) for more information.

50 changes: 50 additions & 0 deletions providers/harness/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module github.com/open-feature/go-sdk-contrib/providers/harness

go 1.19

require (
github.com/harness/ff-golang-server-sdk v0.1.13
github.com/open-feature/go-sdk v1.7.0
github.com/stretchr/testify v1.8.4
github.com/jarcoal/httpmock v1.0.8
)

require (
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deepmap/oapi-codegen v1.11.0 // indirect
github.com/getkin/kin-openapi v0.94.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-retryablehttp v0.6.8 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.3.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/r3labs/sse v0.0.0-20201126193848-34e640891548 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/twmb/murmur3 v1.1.5 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.16.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.12.0 // indirect
gopkg.in/cenkalti/backoff.v1 v1.1.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
257 changes: 257 additions & 0 deletions providers/harness/go.sum

Large diffs are not rendered by default.

Loading
Loading