Skip to content

Commit fb3449d

Browse files
committed
Make sure randomizer-lambda omits bbolt
Also, document that store.Factory is for documentation and should not be imported into other packages.
1 parent 5bf01e1 commit fb3449d

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

cmd/randomizer-lambda/main_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ func TestBannedPackages(t *testing.T) {
4040
if strings.Contains(nmout.String(), "T cloud.google.com/") {
4141
t.Errorf("%s contains Google Cloud packages, even though it's for AWS", name)
4242
}
43+
if strings.Contains(nmout.String(), "T go.etcd.io/bbolt.") {
44+
t.Errorf("%s imports go.etcd.io/bbolt, even though it's for AWS", name)
45+
}
4346
}

internal/store/store.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ import (
1313
)
1414

1515
// Factory represents a type for functions that produce a store for the
16-
// randomizer to use for a given "partition" (e.g. Slack channel).
16+
// randomizer to use for a given "partition" (e.g. Slack channel). Factories
17+
// may panic if a non-empty partition is required and not given.
1718
//
18-
// A Factory may panic if it requires a non-empty partition and no partition is
19-
// given.
19+
// Factory is provided for documentation purposes. Do not import the store
20+
// package just to use this alias; this will link support for all possible
21+
// store backends into the final program, even if this was not intended.
2022
type Factory = func(partition string) randomizer.Store
2123

22-
// FactoryFromEnv constructs and returns a Factory based on available
24+
// FactoryFromEnv constructs and returns a [Factory] based on available
2325
// environment variables. If a known DynamoDB environment variable is set, it
2426
// will return a DynamoDB store. Otherwise, it will return a bbolt store.
2527
func FactoryFromEnv(ctx context.Context) (func(string) randomizer.Store, error) {

0 commit comments

Comments
 (0)