@@ -24,6 +24,7 @@ import (
24
24
"github.com/creachadair/gocache/cachedir"
25
25
"github.com/creachadair/taskgroup"
26
26
"github.com/goproxy/goproxy"
27
+ "github.com/tailscale/go-cache-plugin/internal/s3util"
27
28
"github.com/tailscale/go-cache-plugin/s3cache"
28
29
"github.com/tailscale/go-cache-plugin/s3proxy"
29
30
"tailscale.com/tsweb"
@@ -43,7 +44,7 @@ var flags struct {
43
44
DebugLog bool `flag:"debug,default=$GOCACHE_DEBUG,Enable detailed per-request debug logging (noisy)"`
44
45
}
45
46
46
- func initCacheServer (env * command.Env ) (* gocache.Server , * s3 .Client , error ) {
47
+ func initCacheServer (env * command.Env ) (* gocache.Server , * s3util .Client , error ) {
47
48
switch {
48
49
case flags .CacheDir == "" :
49
50
return nil , nil , env .Usagef ("you must provide a --cache-dir" )
@@ -67,10 +68,13 @@ func initCacheServer(env *command.Env) (*gocache.Server, *s3.Client, error) {
67
68
68
69
vprintf ("local cache directory: %s" , flags .CacheDir )
69
70
vprintf ("S3 cache bucket %q (%s)" , flags .S3Bucket , region )
71
+ client := & s3util.Client {
72
+ Client : s3 .NewFromConfig (cfg ),
73
+ Bucket : flags .S3Bucket ,
74
+ }
70
75
cache := & s3cache.Cache {
71
76
Local : dir ,
72
- S3Client : s3 .NewFromConfig (cfg ),
73
- S3Bucket : flags .S3Bucket ,
77
+ S3Client : client ,
74
78
KeyPrefix : flags .KeyPrefix ,
75
79
MinUploadSize : flags .MinUploadSize ,
76
80
UploadConcurrency : flags .S3Concurrency ,
@@ -94,7 +98,7 @@ func initCacheServer(env *command.Env) (*gocache.Server, *s3.Client, error) {
94
98
LogRequests : flags .DebugLog ,
95
99
}
96
100
expvar .Publish ("gocache_server" , s .Metrics ().Get ("server" ))
97
- return s , cache . S3Client , nil
101
+ return s , client , nil
98
102
}
99
103
100
104
// runDirect runs a cache communicating on stdin/stdout, for use as a direct
@@ -162,7 +166,6 @@ func runServe(env *command.Env) error {
162
166
cacher := & s3proxy.Cacher {
163
167
Local : modCachePath ,
164
168
S3Client : s3c ,
165
- S3Bucket : flags .S3Bucket ,
166
169
KeyPrefix : path .Join (flags .KeyPrefix , "module" ),
167
170
MaxTasks : flags .S3Concurrency ,
168
171
LogRequests : flags .DebugLog ,
0 commit comments