rollout / cloudbees-openfeature-provider-go

CloudBees Feature Management provider for OpenFeature SDK for golang
Apache License 2.0
0 stars 0 forks source link

CloudBees Feature Management provider for OpenFeature

a OpenFeature Specification OpenFeature SDK CloudBees Rox SDK

This is the CloudBees provider implementation for OpenFeature for the Go SDK.

OpenFeature provides a vendor-agnostic abstraction layer on Feature Flag management.

This provider allows the use of CloudBees Feature Management as a backend for Feature Flag configurations.

Requirements

Installation

Add it to your build

go get github.com/rollout/cloudbees-openfeature-provider-go

Configuration

Follow the instructions on the Go SDK project for how to use the Go SDK.

You can configure the CloudBees provider by doing the following:

package main

import (
    "context"
    "fmt"

    "github.com/open-feature/go-sdk/pkg/openfeature"
    "github.com/rollout/cloudbees-openfeature-provider-go/pkg/cloudbees"
)

func main() {
    appKey := "INSERT_APP_KEY_HERE"
    if provider, err := cloudbees.NewProvider(appKey); err == nil {
        openfeature.SetProvider(provider)
        client := openfeature.NewClient("app")
        value, err := client.BooleanValue(context.Background(), "enableTutorial", false, openfeature.EvaluationContext{})
        fmt.Printf("flag value: %v, error: %v", value, err)
    } else {
        fmt.Printf("error creating client %v", err)
    }
}