Skip to content
This repository was archived by the owner on Jul 12, 2023. It is now read-only.

Commit 759e99b

Browse files
authored
Update deps to use generics (#2346)
1 parent a70c0dc commit 759e99b

File tree

10 files changed

+56
-79
lines changed

10 files changed

+56
-79
lines changed

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/golang-migrate/migrate/v4 v4.15.1
1717
github.com/golangci/golangci-lint v1.45.2
1818
github.com/gonum/matrix v0.0.0-20181209220409-c518dec07be9
19-
github.com/google/exposure-notifications-server v1.9.0
19+
github.com/google/exposure-notifications-server v1.9.1-0.20220502192432-162cbaadfd29
2020
github.com/google/go-cmp v0.5.7
2121
github.com/google/uuid v1.3.0
2222
github.com/gorilla/handlers v1.5.1
@@ -115,6 +115,7 @@ require (
115115
github.com/davecgh/go-spew v1.1.1 // indirect
116116
github.com/denis-tingaikin/go-header v0.4.3 // indirect
117117
github.com/dimchansky/utfbom v1.1.1 // indirect
118+
github.com/docker/docker v20.10.14+incompatible // indirect
118119
github.com/docker/go-connections v0.4.0 // indirect
119120
github.com/docker/go-units v0.4.0 // indirect
120121
github.com/esimonov/ifshort v1.0.4 // indirect
@@ -140,6 +141,7 @@ require (
140141
github.com/gobwas/pool v0.2.1 // indirect
141142
github.com/gobwas/ws v1.1.0 // indirect
142143
github.com/gofrs/flock v0.8.1 // indirect
144+
github.com/gofrs/uuid v4.2.0+incompatible // indirect
143145
github.com/golang-jwt/jwt/v4 v4.4.1 // indirect
144146
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
145147
github.com/golang/protobuf v1.5.2 // indirect
@@ -289,6 +291,7 @@ require (
289291
github.com/yeya24/promlinter v0.1.1-0.20210918184747-d757024714a1 // indirect
290292
gitlab.com/bosi/decorder v0.2.1 // indirect
291293
go.uber.org/atomic v1.9.0 // indirect
294+
go.uber.org/goleak v1.1.12 // indirect
292295
go.uber.org/multierr v1.8.0 // indirect
293296
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
294297
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect

go.sum

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,8 +487,9 @@ github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TT
487487
github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
488488
github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug=
489489
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
490-
github.com/docker/docker v20.10.9+incompatible h1:JlsVnETOjM2RLQa0Cc1XCIspUdXW3Zenq9P54uXBm6k=
491490
github.com/docker/docker v20.10.9+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
491+
github.com/docker/docker v20.10.14+incompatible h1:+T9/PRYWNDo5SZl5qS1r9Mo/0Q8AwxKKPtu9S1yxM0w=
492+
github.com/docker/docker v20.10.14+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
492493
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
493494
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
494495
github.com/docker/go-events v0.0.0-20170721190031-9461782956ad/go.mod h1:Uw6UezgYA44ePAFQYUehOuCzmy5zmg/+nl2ZfMWGkpA=
@@ -665,8 +666,9 @@ github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5x
665666
github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw=
666667
github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU=
667668
github.com/gofrs/uuid v3.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
668-
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
669669
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
670+
github.com/gofrs/uuid v4.2.0+incompatible h1:yyYWMnhkhrKwwr8gAOcOCYxOOscHgDS9yZgBrnJfGa0=
671+
github.com/gofrs/uuid v4.2.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
670672
github.com/gogo/googleapis v1.2.0/go.mod h1:Njal3psf3qN6dwBtQfUmBZh2ybovJ0tlu3o/AC7HYjU=
671673
github.com/gogo/googleapis v1.4.0/go.mod h1:5YRNX2z1oM5gXdAkurHa942MDgEJyk02w4OecKY87+c=
672674
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
@@ -765,8 +767,8 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z
765767
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
766768
github.com/google/certificate-transparency-go v1.0.21/go.mod h1:QeJfpSbVSfYc7RgB3gJFj9cbuQMMchQxrWXz8Ruopmg=
767769
github.com/google/certificate-transparency-go v1.1.1/go.mod h1:FDKqPvSXawb2ecErVRrD+nfy23RCzyl7eqVCEmlT1Zs=
768-
github.com/google/exposure-notifications-server v1.9.0 h1:/fhehXwmFP4mOU8XR8kdZ+eO3G18bO4l2nhgVresH7E=
769-
github.com/google/exposure-notifications-server v1.9.0/go.mod h1:Ws5vVVc7e+CqrSWEj3yd8DFeYm/QVcLXu4Fn1xobnvo=
770+
github.com/google/exposure-notifications-server v1.9.1-0.20220502192432-162cbaadfd29 h1:zppZkpyL21AvnWUFTJIrKWNXwhKIZar+xXo7n5DPNS4=
771+
github.com/google/exposure-notifications-server v1.9.1-0.20220502192432-162cbaadfd29/go.mod h1:Ws5vVVc7e+CqrSWEj3yd8DFeYm/QVcLXu4Fn1xobnvo=
770772
github.com/google/flatbuffers v2.0.0+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
771773
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
772774
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
@@ -1734,8 +1736,9 @@ go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
17341736
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
17351737
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
17361738
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
1737-
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
17381739
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
1740+
go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=
1741+
go.uber.org/goleak v1.1.12/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
17391742
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
17401743
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
17411744
go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=

pkg/controller/certapi/certapi.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ type Controller struct {
3838
db *database.Database
3939
cacher vcache.Cacher
4040
h *render.Renderer
41-
pubKeyCache *keyutils.PublicKeyCache // Cache of public keys for verification token verification.
42-
signerCache *cache.Cache // Cache signers on a per-realm basis.
41+
pubKeyCache *keyutils.PublicKeyCache // Cache of public keys for verification token verification.
42+
signerCache *cache.Cache[*SignerInfo] // Cache signers on a per-realm basis.
4343
kms keys.KeyManager
4444
}
4545

@@ -50,7 +50,7 @@ func New(ctx context.Context, config *config.APIServerConfig, db *database.Datab
5050
}
5151

5252
// This has to be in-memory because the signer has state and connection pools.
53-
signerCache, err := cache.New(config.CertificateSigning.SignerCacheDuration)
53+
signerCache, err := cache.New[*SignerInfo](config.CertificateSigning.SignerCacheDuration)
5454
if err != nil {
5555
return nil, fmt.Errorf("cannot create signer cache, likely invalid duration: %w", err)
5656
}

pkg/controller/certapi/signers.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ func (c *Controller) getSignerForAuthApp(ctx context.Context, authApp *database.
4040

4141
// GetSignerForRealm gets the certificate signer info for the given realm.
4242
func GetSignerForRealm(ctx context.Context, realmID uint,
43-
cfg config.CertificateSigningConfig, cache *cache.Cache, db *database.Database, kms keys.KeyManager) (*SignerInfo, error) {
44-
signerCache, err := cache.WriteThruLookup(fmt.Sprintf("%d", realmID),
45-
func() (interface{}, error) {
43+
cfg config.CertificateSigningConfig, cache *cache.Cache[*SignerInfo], db *database.Database, kms keys.KeyManager) (*SignerInfo, error) {
44+
signer, err := cache.WriteThruLookup(fmt.Sprintf("%d", realmID),
45+
func() (*SignerInfo, error) {
4646
realm, err := db.FindRealm(realmID)
4747
if err != nil {
4848
return nil, fmt.Errorf("unable to load realm settings: %w", err)
@@ -85,9 +85,5 @@ func GetSignerForRealm(ctx context.Context, realmID uint,
8585
if err != nil {
8686
return nil, fmt.Errorf("unable to get signer for realmID: %d: %w", realmID, err)
8787
}
88-
signer, ok := signerCache.(*SignerInfo)
89-
if !ok {
90-
return nil, fmt.Errorf("certificate signer in wrong format for realmID: %d: %w", realmID, err)
91-
}
9288
return signer, nil
9389
}

pkg/controller/issueapi/controller.go

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,36 @@ import (
2727
"github.com/google/exposure-notifications-verification-server/pkg/config"
2828
"github.com/google/exposure-notifications-verification-server/pkg/database"
2929
"github.com/google/exposure-notifications-verification-server/pkg/render"
30+
"github.com/google/exposure-notifications-verification-server/pkg/sms"
3031

3132
"github.com/google/exposure-notifications-server/pkg/cache"
3233
"github.com/sethvargo/go-limiter"
3334
"go.opencensus.io/tag"
3435
)
3536

3637
type Controller struct {
37-
config config.IssueAPIConfig
38-
db *database.Database
39-
localCache *cache.Cache
40-
limiter limiter.Store
41-
smsSigner keys.KeyManager
42-
h *render.Renderer
38+
config config.IssueAPIConfig
39+
db *database.Database
40+
smsSignerCache *cache.Cache[*cachedSMSSigner]
41+
smsProviderCache *cache.Cache[sms.Provider]
42+
limiter limiter.Store
43+
smsSigner keys.KeyManager
44+
h *render.Renderer
4345
}
4446

4547
// New creates a new IssueAPI controller.
4648
func New(cfg config.IssueAPIConfig, db *database.Database, limiter limiter.Store, smsSigner keys.KeyManager, h *render.Renderer) *Controller {
47-
localCache, _ := cache.New(30 * time.Second)
49+
smsSignerCache, _ := cache.New[*cachedSMSSigner](30 * time.Second)
50+
smsProviderCache, _ := cache.New[sms.Provider](30 * time.Second)
4851

4952
return &Controller{
50-
config: cfg,
51-
db: db,
52-
localCache: localCache,
53-
limiter: limiter,
54-
smsSigner: smsSigner,
55-
h: h,
53+
config: cfg,
54+
db: db,
55+
smsSignerCache: smsSignerCache,
56+
smsProviderCache: smsProviderCache,
57+
limiter: limiter,
58+
smsSigner: smsSigner,
59+
h: h,
5660
}
5761
}
5862

pkg/controller/issueapi/issue.go

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -199,22 +199,18 @@ func (c *Controller) smsProviderFor(ctx context.Context, realm *database.Realm,
199199
}
200200

201201
key := fmt.Sprintf("realm:%d:sms_provider:user_report:%v", realm.ID, appendKey)
202-
result, err := c.localCache.WriteThruLookup(key, func() (interface{}, error) {
202+
result, err := c.smsProviderCache.WriteThruLookup(key, func() (sms.Provider, error) {
203203
return realm.SMSProvider(c.db, opts...)
204204
})
205205
if err != nil {
206206
return nil, err
207207
}
208+
return result, nil
209+
}
208210

209-
if result == nil {
210-
return nil, nil
211-
}
212-
typ, ok := result.(sms.Provider)
213-
if !ok {
214-
return nil, fmt.Errorf("invalid type %T", result)
215-
}
216-
217-
return typ, nil
211+
type cachedSMSSigner struct {
212+
signer crypto.Signer
213+
keyID string
218214
}
219215

220216
// smsSignerFor returns the sms signer for the given realm. It pulls the value
@@ -225,13 +221,8 @@ func (c *Controller) smsSignerFor(ctx context.Context, realm *database.Realm) (c
225221
return nil, "", nil
226222
}
227223

228-
type cachedSMSSigner struct {
229-
signer crypto.Signer
230-
keyID string
231-
}
232-
233224
key := fmt.Sprintf("realm:%d:sms_signer", realm.ID)
234-
result, err := c.localCache.WriteThruLookup(key, func() (interface{}, error) {
225+
result, err := c.smsSignerCache.WriteThruLookup(key, func() (*cachedSMSSigner, error) {
235226
signingKey, err := realm.CurrentSMSSigningKey(c.db)
236227
if err != nil {
237228
return nil, fmt.Errorf("failed to get current sms signing key: %w", err)
@@ -250,16 +241,10 @@ func (c *Controller) smsSignerFor(ctx context.Context, realm *database.Realm) (c
250241
if err != nil {
251242
return nil, "", err
252243
}
253-
254244
if result == nil {
255245
return nil, "", nil
256246
}
257-
typ, ok := result.(*cachedSMSSigner)
258-
if !ok {
259-
return nil, "", fmt.Errorf("invalid type %T", result)
260-
}
261-
262-
return typ.signer, typ.keyID, nil
247+
return result.signer, result.keyID, nil
263248
}
264249

265250
// errorAll sets the ErrorReturn on all results to the provided value.

pkg/controller/middleware/chaff.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func ChaffHeaderDetector() chaff.Detector {
4444
//
4545
// cache.New only returns an error if the duration is negative, so we ignore the
4646
// error here.
47-
var localChaffCache, _ = cache.New(48 * time.Hour)
47+
var localChaffCache, _ = cache.New[*struct{}](48 * time.Hour)
4848

4949
// ProcessChaff injects the chaff processing middleware. If chaff requests send
5050
// a value of "daily" (case-insensitive), they will be counted toward the
@@ -76,7 +76,7 @@ func recordChaffEvent(ctx context.Context, t time.Time, realm *database.Realm, d
7676
}
7777

7878
key := fmt.Sprintf("%s:%d", t.Format("2006-01-02"), realm.ID)
79-
if _, err := localChaffCache.WriteThruLookup(key, func() (interface{}, error) {
79+
if _, err := localChaffCache.WriteThruLookup(key, func() (*struct{}, error) {
8080
if err := realm.RecordChaffEvent(db, t); err != nil {
8181
return nil, err
8282
}

pkg/controller/statspuller/statspull.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/google/exposure-notifications-server/pkg/keys"
2323
"github.com/google/exposure-notifications-verification-server/internal/clients"
2424
"github.com/google/exposure-notifications-verification-server/pkg/config"
25+
"github.com/google/exposure-notifications-verification-server/pkg/controller/certapi"
2526
"github.com/google/exposure-notifications-verification-server/pkg/database"
2627
"github.com/google/exposure-notifications-verification-server/pkg/render"
2728
)
@@ -33,13 +34,13 @@ type Controller struct {
3334
db *database.Database
3435
h *render.Renderer
3536
kms keys.KeyManager
36-
signerCache *cache.Cache
37+
signerCache *cache.Cache[*certapi.SignerInfo]
3738
}
3839

3940
// New creates a new stats-pull controller.
4041
func New(cfg *config.StatsPullerConfig, db *database.Database, client *clients.KeyServerClient, kms keys.KeyManager, h *render.Renderer) (*Controller, error) {
4142
// This has to be in-memory because the signer has state and connection pools.
42-
signerCache, err := cache.New(cfg.CertificateSigning.SignerCacheDuration)
43+
signerCache, err := cache.New[*certapi.SignerInfo](cfg.CertificateSigning.SignerCacheDuration)
4344
if err != nil {
4445
return nil, fmt.Errorf("cannot create signer cache, likely invalid duration: %w", err)
4546
}

pkg/controller/userreport/controller.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import (
2929
"github.com/google/exposure-notifications-verification-server/pkg/database"
3030
"github.com/google/exposure-notifications-verification-server/pkg/render"
3131

32-
memcache "github.com/google/exposure-notifications-server/pkg/cache"
3332
"github.com/google/exposure-notifications-server/pkg/keys"
3433

3534
"github.com/sethvargo/go-limiter"
@@ -40,7 +39,6 @@ type Controller struct {
4039
cacher cache.Cacher
4140
config *config.RedirectConfig
4241
db *database.Database
43-
localCache *memcache.Cache
4442
httpClient *http.Client
4543
limiter limiter.Store
4644
smsSigner keys.KeyManager
@@ -58,8 +56,6 @@ func New(locales *i18n.LocaleMap, cacher cache.Cacher, cfg *config.RedirectConfi
5856

5957
issueController := issueapi.New(cfg, db, limiter, smsSigner, h)
6058

61-
localCache, _ := memcache.New(30 * time.Second)
62-
6359
httpClient := &http.Client{
6460
Timeout: 10 * time.Second,
6561
Transport: project.DefaultHTTPTransport(),
@@ -70,7 +66,6 @@ func New(locales *i18n.LocaleMap, cacher cache.Cacher, cfg *config.RedirectConfi
7066
cacher: cacher,
7167
config: cfg,
7268
db: db,
73-
localCache: localCache,
7469
httpClient: httpClient,
7570
limiter: limiter,
7671
smsSigner: smsSigner,

pkg/database/secretresolver.go

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,24 @@ type SecretResolver struct {
2828
// TTL-based cache that exists to limit load on the database. It maps a secret
2929
// type to the result from the database query.
3030
//
31-
// database(cookie_key) -> projects/p/secrets/s/versions/1
31+
// database(cookie_key) -> []string{projects/p/secrets/s/versions/1}
3232
//
33-
referencesCache *cache.Cache
33+
referencesCache *cache.Cache[[]string]
3434

3535
// valuesCache maps the references to their actual secret values. Since secret
3636
// versions are immutable, this is a long-running cache.
3737
//
38-
// projects/p/secrets/s/versions/1 -> abcd1234
38+
// projects/p/secrets/s/versions/1 -> []byte(abcd1234)
3939
//
40-
valuesCache *cache.Cache
40+
valuesCache *cache.Cache[[]byte]
4141
}
4242

4343
// NewSecretResolver makes a new secret resolver using the provided database and
4444
// secret manager instance.
4545
func NewSecretResolver() *SecretResolver {
4646
// These only return an error if the duration is < 0.
47-
referencesCache, _ := cache.New(60 * time.Second)
48-
valuesCache, _ := cache.New(120 * time.Minute)
47+
referencesCache, _ := cache.New[[]string](60 * time.Second)
48+
valuesCache, _ := cache.New[[]byte](120 * time.Minute)
4949

5050
return &SecretResolver{
5151
referencesCache: referencesCache,
@@ -77,7 +77,7 @@ func (r *SecretResolver) Resolve(ctx context.Context, db *Database, sm secrets.S
7777
// ResolveReferences resolves the database references for the given secret type,
7878
// handling caching where appropriate.
7979
func (r *SecretResolver) ResolveReferences(db *Database, typ SecretType) ([]string, error) {
80-
iface, err := r.referencesCache.WriteThruLookup(string(typ), func() (interface{}, error) {
80+
list, err := r.referencesCache.WriteThruLookup(string(typ), func() ([]string, error) {
8181
records, err := db.ListSecretsForType(typ)
8282
if err != nil {
8383
return nil, fmt.Errorf("failed to list secrets for %s: %w", typ, err)
@@ -92,17 +92,12 @@ func (r *SecretResolver) ResolveReferences(db *Database, typ SecretType) ([]stri
9292
if err != nil {
9393
return nil, err
9494
}
95-
96-
list, ok := iface.([]string)
97-
if !ok {
98-
return nil, fmt.Errorf("result for %s is not []string: %T", typ, iface)
99-
}
10095
return list, nil
10196
}
10297

10398
// ResolveValue resolves a single secret, taking caching into account.
10499
func (r *SecretResolver) ResolveValue(ctx context.Context, sm secrets.SecretManager, ref string) ([]byte, error) {
105-
iface, err := r.valuesCache.WriteThruLookup(ref, func() (interface{}, error) {
100+
typ, err := r.valuesCache.WriteThruLookup(ref, func() ([]byte, error) {
106101
result, err := sm.GetSecretValue(ctx, ref)
107102
if err != nil {
108103
return nil, fmt.Errorf("failed to get secret value %s: %w", ref, err)
@@ -112,11 +107,6 @@ func (r *SecretResolver) ResolveValue(ctx context.Context, sm secrets.SecretMana
112107
if err != nil {
113108
return nil, err
114109
}
115-
116-
typ, ok := iface.([]byte)
117-
if !ok {
118-
return nil, fmt.Errorf("result for %s is not []byte: %T", ref, iface)
119-
}
120110
return typ, nil
121111
}
122112

0 commit comments

Comments
 (0)