Skip to content

Commit 4eb3f44

Browse files
authored
Merge pull request #18 from twharmon/sfn
Add sfn to provided services
2 parents 7b36e33 + 751fa8c commit 4eb3f44

File tree

4 files changed

+51
-6
lines changed

4 files changed

+51
-6
lines changed

.github/workflows/test.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
on: [push, pull_request]
1+
on:
2+
push:
3+
branches:
4+
- main
5+
pull_request:
6+
branches:
7+
- main
28
name: Test
39
jobs:
410
test:
@@ -7,15 +13,13 @@ jobs:
713
go-version: [1.18]
814
platform: [ubuntu-latest]
915
runs-on: ${{ matrix.platform }}
10-
env:
11-
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1216
steps:
1317
- name: Install Go
14-
uses: actions/setup-go@v2
18+
uses: actions/setup-go@v3
1519
with:
1620
go-version: ${{ matrix.go-version }}
1721
- name: Checkout code
18-
uses: actions/checkout@v2
22+
uses: actions/checkout@v3
1923
- name: Run coverage
2024
run: go test -race -coverprofile=coverage.out -covermode=atomic
2125
- name: Upload coverage to Codecov

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Golamb
22

3-
![](https://github.com/twharmon/golamb/workflows/Test/badge.svg) [![](https://goreportcard.com/badge/github.com/twharmon/golamb)](https://goreportcard.com/report/github.com/twharmon/golamb) [![codecov](https://codecov.io/gh/twharmon/golamb/branch/main/graph/badge.svg?token=K0P59TPRAL)](https://codecov.io/gh/twharmon/golamb)
3+
[![Go Reference](https://pkg.go.dev/badge/github.com/twharmon/golamb.svg)](https://pkg.go.dev/github.com/twharmon/golamb) ![](https://github.com/twharmon/golamb/workflows/Test/badge.svg) [![](https://goreportcard.com/badge/github.com/twharmon/golamb)](https://goreportcard.com/report/github.com/twharmon/golamb) [![codecov](https://codecov.io/gh/twharmon/golamb/branch/main/graph/badge.svg?token=K0P59TPRAL)](https://codecov.io/gh/twharmon/golamb)
44

55
Golamb makes it easier to write AWS Lambda functions in Go that are invoked by API Gateway Http APIs.
66

fakes/aws.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
55
"github.com/aws/aws-sdk-go/service/s3/s3iface"
66
"github.com/aws/aws-sdk-go/service/ses/sesiface"
7+
"github.com/aws/aws-sdk-go/service/sfn/sfniface"
78
"github.com/aws/aws-sdk-go/service/ssm/ssmiface"
89
"github.com/aws/aws-sdk-go/service/sts/stsiface"
910
)
@@ -15,6 +16,7 @@ type AWS struct {
1516
s3 s3iface.S3API
1617
sts stsiface.STSAPI
1718
ssm ssmiface.SSMAPI
19+
sfn sfniface.SFNAPI
1820
}
1921

2022
// NewAWS creates a value that implements the
@@ -48,6 +50,11 @@ func (a *AWS) SSM() ssmiface.SSMAPI {
4850
return a.ssm
4951
}
5052

53+
// SFN implements the golamb.AWSServiceProvider interface.
54+
func (a *AWS) SFN() sfniface.SFNAPI {
55+
return a.sfn
56+
}
57+
5158
// WithDynamoDB sets the dynamodb client of the AWSServiceProvider.
5259
func (a *AWS) WithDynamoDB(svc dynamodbiface.DynamoDBAPI) *AWS {
5360
a.dynamodb = svc
@@ -77,3 +84,9 @@ func (a *AWS) WithSSM(svc ssmiface.SSMAPI) *AWS {
7784
a.ssm = svc
7885
return a
7986
}
87+
88+
// WithSFN sets the sfn client of the AWSServiceProvider.
89+
func (a *AWS) WithSFN(svc sfniface.SFNAPI) *AWS {
90+
a.sfn = svc
91+
return a
92+
}

serviceprovider.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/aws/aws-sdk-go/service/s3/s3iface"
1010
"github.com/aws/aws-sdk-go/service/ses"
1111
"github.com/aws/aws-sdk-go/service/ses/sesiface"
12+
"github.com/aws/aws-sdk-go/service/sfn"
13+
"github.com/aws/aws-sdk-go/service/sfn/sfniface"
1214
"github.com/aws/aws-sdk-go/service/ssm"
1315
"github.com/aws/aws-sdk-go/service/ssm/ssmiface"
1416
"github.com/aws/aws-sdk-go/service/sts"
@@ -23,6 +25,7 @@ type awsServiceProvider struct {
2325
s3 *s3.S3
2426
sts *sts.STS
2527
ssm *ssm.SSM
28+
sfn *sfn.SFN
2629
}
2730

2831
// AWSServiceProviderConfig holds config information for the AWS
@@ -34,6 +37,7 @@ type AWSServiceProviderConfig struct {
3437
S3 *aws.Config
3538
STS *aws.Config
3639
SSM *aws.Config
40+
SFN *aws.Config
3741
}
3842

3943
// AWSServiceProvider provides some common AWS service clients.
@@ -52,6 +56,9 @@ type AWSServiceProvider interface {
5256

5357
// SSM provides a SSM client
5458
SSM() ssmiface.SSMAPI
59+
60+
// SFN provides a SFN client
61+
SFN() sfniface.SFNAPI
5562
}
5663

5764
func (sp *awsServiceProvider) loadSession() {
@@ -145,6 +152,22 @@ func (sp *awsServiceProvider) loadSTS() {
145152
sp.sts = sts.New(sp.session)
146153
}
147154

155+
func (sp *awsServiceProvider) loadSFN() {
156+
if sp.sfn != nil {
157+
return
158+
}
159+
sp.loadSession()
160+
if sp.config.SFN != nil {
161+
sp.sfn = sfn.New(sp.session, sp.config.SFN)
162+
return
163+
}
164+
if sp.config.Default != nil {
165+
sp.sfn = sfn.New(sp.session, sp.config.Default)
166+
return
167+
}
168+
sp.sfn = sfn.New(sp.session)
169+
}
170+
148171
func (sp *awsServiceProvider) DynamoDB() dynamodbiface.DynamoDBAPI {
149172
sp.loadDynamoDB()
150173
return sp.dynamodb
@@ -169,3 +192,8 @@ func (sp *awsServiceProvider) SSM() ssmiface.SSMAPI {
169192
sp.loadSSM()
170193
return sp.ssm
171194
}
195+
196+
func (sp *awsServiceProvider) SFN() sfniface.SFNAPI {
197+
sp.loadSFN()
198+
return sp.sfn
199+
}

0 commit comments

Comments
 (0)