|
1 | | -package awsssm |
2 | | - |
3 | | -import ( |
4 | | - "context" |
5 | | - |
6 | | - "github.com/aws/aws-sdk-go-v2/aws" |
7 | | - "github.com/open-feature/go-sdk/openfeature" |
8 | | -) |
9 | | - |
10 | | -type Provider struct { |
11 | | - svc *awsService |
12 | | -} |
13 | | - |
14 | | -type ProviderOption func(*Provider) |
15 | | - |
16 | | -func NewProvider(cfg aws.Config, opts ...ProviderOption) (*Provider, error) { |
17 | | - svc := newAWSService(cfg) |
18 | | - |
19 | | - return &Provider{ |
20 | | - svc: svc, |
21 | | - }, nil |
22 | | -} |
23 | | - |
24 | | -func (p *Provider) Metadata() openfeature.Metadata { |
25 | | - return openfeature.Metadata{ |
26 | | - Name: "AWS System Manager Provider", |
27 | | - } |
28 | | -} |
29 | | - |
30 | | -func (p *Provider) Hooks() []openfeature.Hook { |
31 | | - return []openfeature.Hook{} |
32 | | -} |
33 | | - |
34 | | -func WithDecryption() ProviderOption { |
35 | | - return func(p *Provider) { |
36 | | - p.svc.decryption = true |
37 | | - } |
38 | | -} |
39 | | - |
40 | | -func (p *Provider) BooleanEvaluation(ctx context.Context, flag string, defaultValue bool, flatCtx openfeature.FlattenedContext) openfeature.BoolResolutionDetail { |
41 | | - return p.svc.ResolveBoolean(ctx, flag, defaultValue, flatCtx) |
42 | | -} |
43 | | - |
44 | | -func (p *Provider) StringEvaluation(ctx context.Context, flag string, defaultValue string, flatCtx openfeature.FlattenedContext) openfeature.StringResolutionDetail { |
45 | | - return p.svc.ResolveString(ctx, flag, defaultValue, flatCtx) |
46 | | -} |
47 | | - |
48 | | -func (p *Provider) FloatEvaluation(ctx context.Context, flag string, defaultValue float64, flatCtx openfeature.FlattenedContext) openfeature.FloatResolutionDetail { |
49 | | - return p.svc.ResolveFloat(ctx, flag, defaultValue, flatCtx) |
50 | | -} |
51 | | - |
52 | | -func (p *Provider) IntEvaluation(ctx context.Context, flag string, defaultValue int64, flatCtx openfeature.FlattenedContext) openfeature.IntResolutionDetail { |
53 | | - return p.svc.ResolveInt(ctx, flag, defaultValue, flatCtx) |
54 | | -} |
55 | | - |
56 | | -func (p *Provider) ObjectEvaluation(ctx context.Context, flag string, defaultValue any, flatCtx openfeature.FlattenedContext) openfeature.InterfaceResolutionDetail { |
57 | | - return p.svc.ResolveObject(ctx, flag, defaultValue, flatCtx) |
58 | | -} |
| 1 | +package awsssm |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + |
| 6 | + "github.com/aws/aws-sdk-go-v2/aws" |
| 7 | + "github.com/open-feature/go-sdk/openfeature" |
| 8 | +) |
| 9 | + |
| 10 | +type Provider struct { |
| 11 | + svc *awsService |
| 12 | +} |
| 13 | + |
| 14 | +type ProviderOption func(*Provider) |
| 15 | + |
| 16 | +func NewProvider(cfg aws.Config, opts ...ProviderOption) (*Provider, error) { |
| 17 | + |
| 18 | + p := &Provider{ |
| 19 | + svc: newAWSService(cfg), |
| 20 | + } |
| 21 | + |
| 22 | + for _, opt := range opts { |
| 23 | + opt(p) |
| 24 | + } |
| 25 | + |
| 26 | + return p, nil |
| 27 | +} |
| 28 | + |
| 29 | +func (p *Provider) Metadata() openfeature.Metadata { |
| 30 | + return openfeature.Metadata{ |
| 31 | + Name: "AWS System Manager Provider", |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | +func (p *Provider) Hooks() []openfeature.Hook { |
| 36 | + return []openfeature.Hook{} |
| 37 | +} |
| 38 | + |
| 39 | +func WithDecryption() ProviderOption { |
| 40 | + return func(p *Provider) { |
| 41 | + p.svc.decryption = true |
| 42 | + } |
| 43 | +} |
| 44 | + |
| 45 | +func (p *Provider) BooleanEvaluation(ctx context.Context, flag string, defaultValue bool, flatCtx openfeature.FlattenedContext) openfeature.BoolResolutionDetail { |
| 46 | + return p.svc.ResolveBoolean(ctx, flag, defaultValue, flatCtx) |
| 47 | +} |
| 48 | + |
| 49 | +func (p *Provider) StringEvaluation(ctx context.Context, flag string, defaultValue string, flatCtx openfeature.FlattenedContext) openfeature.StringResolutionDetail { |
| 50 | + return p.svc.ResolveString(ctx, flag, defaultValue, flatCtx) |
| 51 | +} |
| 52 | + |
| 53 | +func (p *Provider) FloatEvaluation(ctx context.Context, flag string, defaultValue float64, flatCtx openfeature.FlattenedContext) openfeature.FloatResolutionDetail { |
| 54 | + return p.svc.ResolveFloat(ctx, flag, defaultValue, flatCtx) |
| 55 | +} |
| 56 | + |
| 57 | +func (p *Provider) IntEvaluation(ctx context.Context, flag string, defaultValue int64, flatCtx openfeature.FlattenedContext) openfeature.IntResolutionDetail { |
| 58 | + return p.svc.ResolveInt(ctx, flag, defaultValue, flatCtx) |
| 59 | +} |
| 60 | + |
| 61 | +func (p *Provider) ObjectEvaluation(ctx context.Context, flag string, defaultValue any, flatCtx openfeature.FlattenedContext) openfeature.InterfaceResolutionDetail { |
| 62 | + return p.svc.ResolveObject(ctx, flag, defaultValue, flatCtx) |
| 63 | +} |
0 commit comments