# Packages
No description provided by the author
# README
Unofficial Harness OpenFeature GO Provider
Harness 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 and Harness provider. You can install the packages using the following command
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.
Evaluation Context
Evaluation Context is mapped to Harness target. OpenFeature targetingKey is mapped to Identifier, Name is mapped to Name and other fields are mapped to Attributes fields.
Usage Example
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()
of.SetProvider(provider)
ofClient := of.NewClient("my-app")
evalCtx := of.NewEvaluationContext(
"john",
map[string]interface{}{
"Firstname": "John",
"Lastname": "Doe",
"Email": "[email protected]",
},
)
enabled, err := ofClient.BooleanValue(context.Background(), "TestTrueOn", false, evalCtx)
if enabled == false {
t.Fatalf("Expected feature to be enabled")
}
See provider_test.go for more information.