@@ -18,25 +18,22 @@ import (
18
18
"github.com/gitpod-io/gitpod/content-service/pkg/storage"
19
19
)
20
20
21
- const (
22
- usageReportBucketName = "usage-reports"
23
- )
24
-
25
21
// UsageReportService implements UsageReportServiceServer
26
22
type UsageReportService struct {
27
- cfg config.StorageConfig
28
- s storage.PresignedAccess
23
+ cfg config.StorageConfig
24
+ s storage.PresignedAccess
25
+ bucketName string
29
26
30
27
api.UnimplementedUsageReportServiceServer
31
28
}
32
29
33
30
// NewUsageReportService create a new usagereport service
34
- func NewUsageReportService (cfg config.StorageConfig ) (res * UsageReportService , err error ) {
31
+ func NewUsageReportService (cfg config.StorageConfig , bucketName string ) (res * UsageReportService , err error ) {
35
32
s , err := storage .NewPresignedAccess (& cfg )
36
33
if err != nil {
37
34
return nil , err
38
35
}
39
- return & UsageReportService {cfg : cfg , s : s }, nil
36
+ return & UsageReportService {cfg : cfg , s : s , bucketName : bucketName }, nil
40
37
}
41
38
42
39
// UploadURL provides a URL to which clients can upload the content via HTTP PUT.
@@ -45,17 +42,17 @@ func (us *UsageReportService) UploadURL(ctx context.Context, req *api.UsageRepor
45
42
span .SetTag ("name" , req .Name )
46
43
defer tracing .FinishSpan (span , & err )
47
44
48
- err = us .s .EnsureExists (ctx , usageReportBucketName )
45
+ err = us .s .EnsureExists (ctx , us . bucketName )
49
46
if err != nil {
50
47
return nil , status .Error (codes .NotFound , err .Error ())
51
48
}
52
49
53
- info , err := us .s .SignUpload (ctx , usageReportBucketName , req .Name , & storage.SignedURLOptions {
50
+ info , err := us .s .SignUpload (ctx , us . bucketName , req .Name , & storage.SignedURLOptions {
54
51
ContentType : "*/*" ,
55
52
})
56
53
if err != nil {
57
54
log .WithField ("name" , req .Name ).
58
- WithField ("bucket" , usageReportBucketName ).
55
+ WithField ("bucket" , us . bucketName ).
59
56
WithError (err ).
60
57
Error ("Error getting UsageReport SignUpload URL" )
61
58
return nil , status .Error (codes .Unknown , err .Error ())
0 commit comments