internal/worker: change name of gcs directory with binaries
binaryDir identifier is also used as a local variable in quite a few
places, which can lead to some confusion.
Change-Id: Ic461ceaa5e1b7442975c7e466ccd091de3860fe5
Reviewed-on: https://go-review.googlesource.com/c/pkgsite-metrics/+/475195
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Zvonimir Pavlinovic <zpavlinovic@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
diff --git a/internal/worker/vulncheck_enqueue.go b/internal/worker/vulncheck_enqueue.go
index 96ab8c2..1eca9e9 100644
--- a/internal/worker/vulncheck_enqueue.go
+++ b/internal/worker/vulncheck_enqueue.go
@@ -110,8 +110,8 @@
return mode, nil
}
-// binaryDir is the directory in the GCS bucket that contains binaries that should be scanned.
-const binaryDir = "binaries"
+// gcsBinaryDir is the directory in the GCS bucket that contains binaries that should be scanned.
+const gcsBinaryDir = "binaries"
func readBinaries(ctx context.Context, bucketName string) (reqs []*ivulncheck.Request, err error) {
defer derrors.Wrap(&err, "readBinaries(%q)", bucketName)
@@ -123,7 +123,7 @@
if err != nil {
return nil, err
}
- iter := c.Bucket(bucketName).Objects(ctx, &storage.Query{Prefix: binaryDir})
+ iter := c.Bucket(bucketName).Objects(ctx, &storage.Query{Prefix: gcsBinaryDir})
for {
attrs, err := iter.Next()
if err == iterator.Done {
@@ -132,7 +132,7 @@
if err != nil {
return nil, err
}
- mp, err := scan.ParseModuleURLPath(strings.TrimPrefix(attrs.Name, binaryDir+"/"))
+ mp, err := scan.ParseModuleURLPath(strings.TrimPrefix(attrs.Name, gcsBinaryDir+"/"))
if err != nil {
return nil, err
}
diff --git a/internal/worker/vulncheck_scan.go b/internal/worker/vulncheck_scan.go
index 9ff3c93..ae1a882 100644
--- a/internal/worker/vulncheck_scan.go
+++ b/internal/worker/vulncheck_scan.go
@@ -425,7 +425,7 @@
}
// Copy the binary from GCS to the local disk, because vulncheck.Binary
// requires a ReaderAt and GCS doesn't provide that.
- gcsPathname := fmt.Sprintf("%s/%s@%s/%s", binaryDir, modulePath, version, binDir)
+ gcsPathname := fmt.Sprintf("%s/%s@%s/%s", gcsBinaryDir, modulePath, version, binDir)
const destDir = "/bundle/rootfs/binaries"
log.Debug(ctx, "copying",
"from", gcsPathname,
@@ -496,7 +496,7 @@
}
// Copy the binary from GCS to the local disk, because vulncheck.Binary
// requires a ReaderAt and GCS doesn't provide that.
- gcsPathname := fmt.Sprintf("%s/%s@%s/%s", binaryDir, modulePath, version, binDir)
+ gcsPathname := fmt.Sprintf("%s/%s@%s/%s", gcsBinaryDir, modulePath, version, binDir)
log.Debug(ctx, "copying to temp dir",
"from", gcsPathname, "module", modulePath, "version", version, "dir", binDir)
localPathname := filepath.Join(tempDir, "binary")