Documentation
¶
Overview ¶
Package sdk is the official Flipt Go SDK. The SDK exposes the various RPC for interfacing with a remote Flipt instance. Both HTTP and gRPC protocols are supported via this unified Go API.
The main entrypoint within this package is New, which takes an instance of Transport and returns an instance of SDK. Transport implementations can be found in the following sub-packages:
GRPC Transport ¶
The following is an example of creating and instance of the SDK using the gRPC transport.
func main() { conn := grpc.Dial("localhost:9090") transport := grpc.NewTransport(conn) sdk := sdk.New(transport) }
Authenticating the SDK ¶
The remote procedure calls mades by this SDK are authenticated via a ClientTokenProvider implementation. This can be supplied to New via the WithClientTokenProvider option.
Currently, there only exists a single implementation StaticClientTokenProvider:
func main() { provider := sdk.StaticClientTokenProvider("some-flipt-token") sdk.New(transport, sdk.WithClientTokenProvider(provider)) }
SDK Services ¶
The Flipt SDK is split into three sections Flipt, Auth and Meta. Each of which provides access to different parts of the Flipt system.
Flipt Service ¶
The Flipt service is the core Flipt API service. This service provides access to evaluate flag configuration within your application. As well as exposing the Flipt resource CRUD APIs.
client := sdk.New(transport).Flipt()
The following demonstrates how to evaluate the state of a flag.
result, err := client.Evaluate(ctx, &flipt.EvaluationRequest{ RequestId: uuid.NewV4().String(), FlagKey: "my_flag_key", EntityId: userID, Context: map[string]string{ "organization": orgName, }, })
Additionally, Flipt resources can be accessed and managed directly.
flag, err := client.GetFlag(ctx, &flipt.GetFlagRequest{Key: "my_flag_key"}) if err != nil { panic(err) } fmt.Println(flag.Name) fmt.Println(flag.Description)
Index ¶
- type Auth
- func (s Auth) AuthenticationMethodKubernetesService() *AuthenticationMethodKubernetesService
- func (s Auth) AuthenticationMethodOIDCService() *AuthenticationMethodOIDCService
- func (s Auth) AuthenticationMethodTokenService() *AuthenticationMethodTokenService
- func (s Auth) AuthenticationService() *AuthenticationService
- func (s Auth) PublicAuthenticationService() *PublicAuthenticationService
- type AuthClient
- type AuthenticationMethodKubernetesService
- type AuthenticationMethodOIDCService
- type AuthenticationMethodTokenService
- type AuthenticationService
- func (x *AuthenticationService) DeleteAuthentication(ctx context.Context, v *auth.DeleteAuthenticationRequest) error
- func (x *AuthenticationService) ExpireAuthenticationSelf(ctx context.Context, v *auth.ExpireAuthenticationSelfRequest) error
- func (x *AuthenticationService) GetAuthentication(ctx context.Context, v *auth.GetAuthenticationRequest) (*auth.Authentication, error)
- func (x *AuthenticationService) GetAuthenticationSelf(ctx context.Context) (*auth.Authentication, error)
- func (x *AuthenticationService) ListAuthentications(ctx context.Context, v *auth.ListAuthenticationsRequest) (*auth.ListAuthenticationsResponse, error)
- type ClientTokenProvider
- type Flipt
- func (x *Flipt) BatchEvaluate(ctx context.Context, v *flipt.BatchEvaluationRequest) (*flipt.BatchEvaluationResponse, error)
- func (x *Flipt) CreateConstraint(ctx context.Context, v *flipt.CreateConstraintRequest) (*flipt.Constraint, error)
- func (x *Flipt) CreateDistribution(ctx context.Context, v *flipt.CreateDistributionRequest) (*flipt.Distribution, error)
- func (x *Flipt) CreateFlag(ctx context.Context, v *flipt.CreateFlagRequest) (*flipt.Flag, error)
- func (x *Flipt) CreateRule(ctx context.Context, v *flipt.CreateRuleRequest) (*flipt.Rule, error)
- func (x *Flipt) CreateSegment(ctx context.Context, v *flipt.CreateSegmentRequest) (*flipt.Segment, error)
- func (x *Flipt) CreateVariant(ctx context.Context, v *flipt.CreateVariantRequest) (*flipt.Variant, error)
- func (x *Flipt) DeleteConstraint(ctx context.Context, v *flipt.DeleteConstraintRequest) error
- func (x *Flipt) DeleteDistribution(ctx context.Context, v *flipt.DeleteDistributionRequest) error
- func (x *Flipt) DeleteFlag(ctx context.Context, v *flipt.DeleteFlagRequest) error
- func (x *Flipt) DeleteRule(ctx context.Context, v *flipt.DeleteRuleRequest) error
- func (x *Flipt) DeleteSegment(ctx context.Context, v *flipt.DeleteSegmentRequest) error
- func (x *Flipt) DeleteVariant(ctx context.Context, v *flipt.DeleteVariantRequest) error
- func (x *Flipt) Evaluate(ctx context.Context, v *flipt.EvaluationRequest) (*flipt.EvaluationResponse, error)
- func (x *Flipt) GetFlag(ctx context.Context, v *flipt.GetFlagRequest) (*flipt.Flag, error)
- func (x *Flipt) GetRule(ctx context.Context, v *flipt.GetRuleRequest) (*flipt.Rule, error)
- func (x *Flipt) GetSegment(ctx context.Context, v *flipt.GetSegmentRequest) (*flipt.Segment, error)
- func (x *Flipt) ListFlags(ctx context.Context, v *flipt.ListFlagRequest) (*flipt.FlagList, error)
- func (x *Flipt) ListRules(ctx context.Context, v *flipt.ListRuleRequest) (*flipt.RuleList, error)
- func (x *Flipt) ListSegments(ctx context.Context, v *flipt.ListSegmentRequest) (*flipt.SegmentList, error)
- func (x *Flipt) OrderRules(ctx context.Context, v *flipt.OrderRulesRequest) error
- func (x *Flipt) UpdateConstraint(ctx context.Context, v *flipt.UpdateConstraintRequest) (*flipt.Constraint, error)
- func (x *Flipt) UpdateDistribution(ctx context.Context, v *flipt.UpdateDistributionRequest) (*flipt.Distribution, error)
- func (x *Flipt) UpdateFlag(ctx context.Context, v *flipt.UpdateFlagRequest) (*flipt.Flag, error)
- func (x *Flipt) UpdateRule(ctx context.Context, v *flipt.UpdateRuleRequest) (*flipt.Rule, error)
- func (x *Flipt) UpdateSegment(ctx context.Context, v *flipt.UpdateSegmentRequest) (*flipt.Segment, error)
- func (x *Flipt) UpdateVariant(ctx context.Context, v *flipt.UpdateVariantRequest) (*flipt.Variant, error)
- type Meta
- type Option
- type PublicAuthenticationService
- type SDK
- type StaticClientTokenProvider
- type Transport
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
func (Auth) AuthenticationMethodKubernetesService ¶
func (s Auth) AuthenticationMethodKubernetesService() *AuthenticationMethodKubernetesService
func (Auth) AuthenticationMethodOIDCService ¶
func (s Auth) AuthenticationMethodOIDCService() *AuthenticationMethodOIDCService
func (Auth) AuthenticationMethodTokenService ¶
func (s Auth) AuthenticationMethodTokenService() *AuthenticationMethodTokenService
func (Auth) AuthenticationService ¶
func (s Auth) AuthenticationService() *AuthenticationService
func (Auth) PublicAuthenticationService ¶
func (s Auth) PublicAuthenticationService() *PublicAuthenticationService
type AuthClient ¶
type AuthClient interface { PublicAuthenticationServiceClient() auth.PublicAuthenticationServiceClient AuthenticationServiceClient() auth.AuthenticationServiceClient AuthenticationMethodTokenServiceClient() auth.AuthenticationMethodTokenServiceClient AuthenticationMethodOIDCServiceClient() auth.AuthenticationMethodOIDCServiceClient AuthenticationMethodKubernetesServiceClient() auth.AuthenticationMethodKubernetesServiceClient }
type AuthenticationMethodKubernetesService ¶
type AuthenticationMethodKubernetesService struct {
// contains filtered or unexported fields
}
func (*AuthenticationMethodKubernetesService) VerifyServiceAccount ¶
func (x *AuthenticationMethodKubernetesService) VerifyServiceAccount(ctx context.Context, v *auth.VerifyServiceAccountRequest) (*auth.VerifyServiceAccountResponse, error)
type AuthenticationMethodOIDCService ¶
type AuthenticationMethodOIDCService struct {
// contains filtered or unexported fields
}
func (*AuthenticationMethodOIDCService) AuthorizeURL ¶
func (x *AuthenticationMethodOIDCService) AuthorizeURL(ctx context.Context, v *auth.AuthorizeURLRequest) (*auth.AuthorizeURLResponse, error)
func (*AuthenticationMethodOIDCService) Callback ¶
func (x *AuthenticationMethodOIDCService) Callback(ctx context.Context, v *auth.CallbackRequest) (*auth.CallbackResponse, error)
type AuthenticationMethodTokenService ¶
type AuthenticationMethodTokenService struct {
// contains filtered or unexported fields
}
func (*AuthenticationMethodTokenService) CreateToken ¶
func (x *AuthenticationMethodTokenService) CreateToken(ctx context.Context, v *auth.CreateTokenRequest) (*auth.CreateTokenResponse, error)
type AuthenticationService ¶
type AuthenticationService struct {
// contains filtered or unexported fields
}
func (*AuthenticationService) DeleteAuthentication ¶
func (x *AuthenticationService) DeleteAuthentication(ctx context.Context, v *auth.DeleteAuthenticationRequest) error
func (*AuthenticationService) ExpireAuthenticationSelf ¶
func (x *AuthenticationService) ExpireAuthenticationSelf(ctx context.Context, v *auth.ExpireAuthenticationSelfRequest) error
func (*AuthenticationService) GetAuthentication ¶
func (x *AuthenticationService) GetAuthentication(ctx context.Context, v *auth.GetAuthenticationRequest) (*auth.Authentication, error)
func (*AuthenticationService) GetAuthenticationSelf ¶
func (x *AuthenticationService) GetAuthenticationSelf(ctx context.Context) (*auth.Authentication, error)
func (*AuthenticationService) ListAuthentications ¶
func (x *AuthenticationService) ListAuthentications(ctx context.Context, v *auth.ListAuthenticationsRequest) (*auth.ListAuthenticationsResponse, error)
type ClientTokenProvider ¶
ClientTokenProvider is a type which when requested provides a client token which can be used to authenticate RPC/API calls invoked through the SDK.
type Flipt ¶
type Flipt struct {
// contains filtered or unexported fields
}
func (*Flipt) BatchEvaluate ¶
func (x *Flipt) BatchEvaluate(ctx context.Context, v *flipt.BatchEvaluationRequest) (*flipt.BatchEvaluationResponse, error)
func (*Flipt) CreateConstraint ¶
func (x *Flipt) CreateConstraint(ctx context.Context, v *flipt.CreateConstraintRequest) (*flipt.Constraint, error)
func (*Flipt) CreateDistribution ¶
func (x *Flipt) CreateDistribution(ctx context.Context, v *flipt.CreateDistributionRequest) (*flipt.Distribution, error)
func (*Flipt) CreateFlag ¶
func (*Flipt) CreateRule ¶
func (*Flipt) CreateSegment ¶
func (*Flipt) CreateVariant ¶
func (*Flipt) DeleteConstraint ¶
func (*Flipt) DeleteDistribution ¶
func (*Flipt) DeleteFlag ¶
func (*Flipt) DeleteRule ¶
func (*Flipt) DeleteSegment ¶
func (*Flipt) DeleteVariant ¶
func (*Flipt) Evaluate ¶
func (x *Flipt) Evaluate(ctx context.Context, v *flipt.EvaluationRequest) (*flipt.EvaluationResponse, error)
func (*Flipt) GetSegment ¶
func (*Flipt) ListSegments ¶
func (x *Flipt) ListSegments(ctx context.Context, v *flipt.ListSegmentRequest) (*flipt.SegmentList, error)
func (*Flipt) OrderRules ¶
func (*Flipt) UpdateConstraint ¶
func (x *Flipt) UpdateConstraint(ctx context.Context, v *flipt.UpdateConstraintRequest) (*flipt.Constraint, error)
func (*Flipt) UpdateDistribution ¶
func (x *Flipt) UpdateDistribution(ctx context.Context, v *flipt.UpdateDistributionRequest) (*flipt.Distribution, error)
func (*Flipt) UpdateFlag ¶
func (*Flipt) UpdateRule ¶
func (*Flipt) UpdateSegment ¶
func (*Flipt) UpdateVariant ¶
type Meta ¶
type Meta struct {
// contains filtered or unexported fields
}
func (*Meta) GetConfiguration ¶
type Option ¶
type Option func(*SDK)
Option is a functional option which configures the Flipt SDK.
func WithClientTokenProvider ¶
func WithClientTokenProvider(p ClientTokenProvider) Option
WithClientTokenProviders returns an Option which configures any supplied SDK with the provided ClientTokenProvider.
type PublicAuthenticationService ¶
type PublicAuthenticationService struct {
// contains filtered or unexported fields
}
func (*PublicAuthenticationService) ListAuthenticationMethods ¶
func (x *PublicAuthenticationService) ListAuthenticationMethods(ctx context.Context) (*auth.ListAuthenticationMethodsResponse, error)
type SDK ¶
type SDK struct {
// contains filtered or unexported fields
}
SDK is the definition of Flipt's Go SDK. It depends on a pluggable transport implementation and exposes a consistent API surface area across both transport implementations. It also provides consistent client-side instrumentation and authentication lifecycle support.
func New ¶
New constructs and configures a Flipt SDK instance from the provided Transport implementation and options.
Example ¶
// see the following subpackages for transport implementations: // - grpc var transport Transport client := New(transport) client.Flipt().GetFlag(context.Background(), &flipt.GetFlagRequest{Key: "my_flag"})
Output:
type StaticClientTokenProvider ¶
type StaticClientTokenProvider string
StaticClientTokenProvider is a string which is supplied as a static client token on each RPC which requires authentication.
func (StaticClientTokenProvider) ClientToken ¶
func (p StaticClientTokenProvider) ClientToken() (string, error)
ClientToken returns the underlying string that is the StaticClientTokenProvider.
type Transport ¶
type Transport interface { AuthClient() AuthClient FliptClient() flipt.FliptClient MetaClient() meta.MetadataServiceClient }