WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit bbec2b7

Browse files
committed
Migrate to go-sdk
The faas-provider package no longer hosts an SDK / client for OpenFaaS, this moved to a separate go-sdk package with a new interface for giving authentication. Tested with the tester cmd. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
1 parent 49bf422 commit bbec2b7

File tree

7 files changed

+70
-33
lines changed

7 files changed

+70
-33
lines changed

.github/workflows/build.yaml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,19 @@ on:
1010

1111
jobs:
1212
build:
13-
strategy:
14-
matrix:
15-
go-version: [ 1.19.x ]
16-
os: [ ubuntu-latest ]
17-
runs-on: ${{ matrix.os }}
13+
14+
runs-on: ubuntu-latest
1815
steps:
1916
- uses: actions/checkout@master
2017
with:
2118
fetch-depth: 1
2219
- name: Install Go
23-
uses: actions/setup-go@v2
20+
uses: actions/setup-go@master
2421
with:
25-
go-version: ${{ matrix.go-version }}
22+
go-version: "1.23.x"
2623
- name: golangci-lint
27-
uses: golangci/golangci-lint-action@v2
24+
uses: golangci/golangci-lint-action@v6
2825
with:
29-
version: v1.48.0
3026
args: --issues-exit-code=0
3127
- name: Test
3228
run: make test

cmd/tester/main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"time"
1313

1414
"github.com/openfaas/connector-sdk/types"
15-
"github.com/openfaas/faas-provider/auth"
15+
sdk "github.com/openfaas/go-sdk"
1616
)
1717

1818
func main() {
@@ -37,11 +37,6 @@ func main() {
3737
password = lookupPasswordViaKubectl()
3838
}
3939

40-
creds := &auth.BasicAuthCredentials{
41-
User: username,
42-
Password: password,
43-
}
44-
4540
// Set Print* variables to false for production use
4641

4742
config := &types.ControllerConfig{
@@ -52,13 +47,18 @@ func main() {
5247
PrintResponseBody: true,
5348
AsyncFunctionInvocation: false,
5449
ContentType: "text/plain",
55-
UserAgent: "openfaasltd/timer-connector",
50+
UserAgent: "openfaas-ce/timer-connector",
5651
UpstreamTimeout: time.Second * 120,
5752
}
5853

5954
fmt.Printf("Tester connector. Topic: %s, Interval: %s\n", topic, interval)
6055

61-
controller := types.NewController(creds, config)
56+
auth := &sdk.BasicAuth{
57+
Username: username,
58+
Password: password,
59+
}
60+
61+
controller := types.NewController(auth, config)
6262

6363
receiver := ResponseReceiver{}
6464
controller.Subscribe(&receiver)

go.mod

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
11
module github.com/openfaas/connector-sdk
22

3-
go 1.18
3+
go 1.23
44

55
require (
6-
github.com/alexellis/go-execute v0.5.0
7-
github.com/openfaas/faas-provider v0.19.1
6+
github.com/alexellis/go-execute v0.6.0
7+
github.com/openfaas/faas-provider v0.25.4
8+
)
9+
10+
require (
11+
github.com/beorn7/perks v1.0.1 // indirect
12+
github.com/cespare/xxhash/v2 v2.2.0 // indirect
13+
github.com/golang/protobuf v1.5.3 // indirect
14+
github.com/gorilla/mux v1.8.0 // indirect
15+
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
16+
github.com/openfaas/go-sdk v0.2.14 // indirect
17+
github.com/prometheus/client_golang v1.16.0 // indirect
18+
github.com/prometheus/client_model v0.3.0 // indirect
19+
github.com/prometheus/common v0.42.0 // indirect
20+
github.com/prometheus/procfs v0.10.1 // indirect
21+
golang.org/x/sys v0.8.0 // indirect
22+
google.golang.org/protobuf v1.33.0 // indirect
823
)

go.sum

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,17 @@ github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRF
4040
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho=
4141
github.com/alexellis/go-execute v0.5.0 h1:L8kgNlFzNbJov7jrInlaig7i6ZUSz/tYYmqvb8dyD0s=
4242
github.com/alexellis/go-execute v0.5.0/go.mod h1:AgHTcsCF9wrP0mMVTO8N+lFw1Biy71NybBOk8M+qgy8=
43+
github.com/alexellis/go-execute v0.6.0 h1:FVGoudJnWSObwf9qmehbvVuvhK6g1UpKOCBjS+OUXEA=
44+
github.com/alexellis/go-execute v0.6.0/go.mod h1:nlg2F6XdYydUm1xXQMMiuibQCV1mveybBkNWfdNznjk=
4345
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
4446
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
47+
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
4548
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
4649
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
4750
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
4851
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
52+
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
53+
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
4954
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
5055
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
5156
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
@@ -95,6 +100,8 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw
95100
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
96101
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
97102
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
103+
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
104+
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
98105
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
99106
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
100107
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
@@ -119,6 +126,7 @@ github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hf
119126
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
120127
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
121128
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
129+
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
122130
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
123131
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
124132
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
@@ -140,6 +148,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN
140148
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
141149
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
142150
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
151+
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
152+
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
143153
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
144154
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
145155
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
@@ -149,6 +159,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
149159
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
150160
github.com/openfaas/faas-provider v0.19.1 h1:xH8lTWabfDZwzIvC0u1AO48ghD3BNw6Vo231DLqTeI0=
151161
github.com/openfaas/faas-provider v0.19.1/go.mod h1:Farrp+9Med8LeK3aoYpqplMP8f5ebTILbCSLg2LPLZk=
162+
github.com/openfaas/faas-provider v0.25.4 h1:Cly/M8/Q+OOn8qFxxeaZGyC5B2x4f+RSU28hej+1WcM=
163+
github.com/openfaas/faas-provider v0.25.4/go.mod h1:t6RSPCvNfiqYEzf/CtdIj+0OItdyK6IzrOca1EOLNSg=
164+
github.com/openfaas/go-sdk v0.2.14 h1:N3bq0yparYZR6pR1AhZiPGvV8GAmQ1UfjmCOGaZMs68=
165+
github.com/openfaas/go-sdk v0.2.14/go.mod h1:DrKUCQ4F8L2cJOmWHNoX8zB8LQIZc/4hRgAtT4t0s4k=
152166
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
153167
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
154168
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
@@ -158,19 +172,27 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn
158172
github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
159173
github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0=
160174
github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY=
175+
github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8=
176+
github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc=
161177
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
162178
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
163179
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
164180
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
181+
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
182+
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
165183
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
166184
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
167185
github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc=
168186
github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls=
187+
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
188+
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
169189
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
170190
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
171191
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
172192
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
173193
github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
194+
github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg=
195+
github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM=
174196
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
175197
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
176198
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
@@ -312,6 +334,8 @@ golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7w
312334
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
313335
golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
314336
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
337+
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
338+
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
315339
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
316340
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
317341
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -442,6 +466,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
442466
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
443467
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
444468
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
469+
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
470+
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
445471
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
446472
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
447473
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

types/controller.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"sync"
1212
"time"
1313

14-
"github.com/openfaas/faas-provider/auth"
14+
"github.com/openfaas/go-sdk"
1515
)
1616

1717
// Controller is used to invoke functions on a per-topic basis and to subscribe to responses returned by said functions.
@@ -34,8 +34,7 @@ type controller struct {
3434
// Map of which functions subscribe to which topics
3535
TopicMap *TopicMap
3636

37-
// Credentials to access gateway
38-
Credentials *auth.BasicAuthCredentials
37+
Auth sdk.ClientAuth
3938

4039
// Subscribers which can receive messages from invocations.
4140
// See note on ResponseSubscriber interface about blocking/long-running
@@ -47,7 +46,7 @@ type controller struct {
4746
}
4847

4948
// NewController create a new connector SDK controller
50-
func NewController(credentials *auth.BasicAuthCredentials, config *ControllerConfig) Controller {
49+
func NewController(auth sdk.ClientAuth, config *ControllerConfig) Controller {
5150

5251
gatewayFunctionPath := gatewayRoute(config)
5352

@@ -66,7 +65,7 @@ func NewController(credentials *auth.BasicAuthCredentials, config *ControllerCon
6665
Config: config,
6766
Invoker: invoker,
6867
TopicMap: &topicMap,
69-
Credentials: credentials,
68+
Auth: auth,
7069
Subscribers: subs,
7170
lock: &sync.RWMutex{},
7271
}
@@ -116,7 +115,7 @@ func (c *controller) InvokeWithContext(ctx context.Context, topic string, messag
116115
// querying the API gateway.
117116
func (c *controller) BeginMapBuilder() {
118117

119-
lookupBuilder := NewFunctionLookupBuilder(c.Config.GatewayURL, c.Config.TopicAnnotationDelimiter, MakeClient(c.Config.UpstreamTimeout), c.Credentials)
118+
lookupBuilder := NewFunctionLookupBuilder(c.Config.GatewayURL, c.Config.TopicAnnotationDelimiter, MakeClient(c.Config.UpstreamTimeout), c.Auth)
120119

121120
ticker := time.NewTicker(c.Config.RebuildInterval)
122121
go c.synchronizeLookups(ticker, lookupBuilder, c.TopicMap)

types/function_list_builder.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
package types
55

66
import (
7+
"context"
78
"fmt"
89
"net/http"
910
"net/url"
1011
"strings"
1112

1213
"github.com/openfaas/faas-provider/auth"
13-
"github.com/openfaas/faas-provider/sdk"
1414
"github.com/openfaas/faas-provider/types"
15+
sdk "github.com/openfaas/go-sdk"
1516
)
1617

1718
// FunctionLookupBuilder builds a list of OpenFaaS functions
@@ -20,13 +21,13 @@ type FunctionLookupBuilder struct {
2021
Client *http.Client
2122
Credentials *auth.BasicAuthCredentials
2223
TopicDelimiter string
23-
sdk *sdk.SDK
24+
sdk *sdk.Client
2425
}
2526

26-
func NewFunctionLookupBuilder(gatewayURL, topicDelimiter string, client *http.Client, credentials *auth.BasicAuthCredentials) *FunctionLookupBuilder {
27+
func NewFunctionLookupBuilder(gatewayURL, topicDelimiter string, client *http.Client, auth sdk.ClientAuth) *FunctionLookupBuilder {
2728
u, _ := url.Parse(gatewayURL)
2829
return &FunctionLookupBuilder{
29-
sdk: sdk.NewSDK(u, credentials, client),
30+
sdk: sdk.NewClient(u, auth, client),
3031
TopicDelimiter: topicDelimiter,
3132
}
3233
}
@@ -36,7 +37,7 @@ func NewFunctionLookupBuilder(gatewayURL, topicDelimiter string, client *http.Cl
3637
func (s *FunctionLookupBuilder) Build() (map[string][]string, error) {
3738
var err error
3839

39-
namespaces, err := s.sdk.GetNamespaces()
40+
namespaces, err := s.sdk.GetNamespaces(context.TODO())
4041
if err != nil {
4142
return map[string][]string{}, err
4243
}
@@ -48,7 +49,7 @@ func (s *FunctionLookupBuilder) Build() (map[string][]string, error) {
4849
}
4950

5051
for _, namespace := range namespaces {
51-
functions, err := s.sdk.GetFunctions(namespace)
52+
functions, err := s.sdk.GetFunctions(context.TODO(), namespace)
5253
if err != nil {
5354
return map[string][]string{}, fmt.Errorf("unable to get functions in: %s, error: %w", namespace, err)
5455
}

types/function_list_builder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010
"net/url"
1111
"testing"
1212

13-
"github.com/openfaas/faas-provider/sdk"
1413
"github.com/openfaas/faas-provider/types"
14+
sdk "github.com/openfaas/go-sdk"
1515
)
1616

1717
func Test_BuildSingleMatchingFunction(t *testing.T) {

0 commit comments

Comments
 (0)