Repository: buchgr/bazel-remote
Pull request #223 (2020-03-10 11:42:15)

rename proxy backend packages to be of the form fooproxy
This makes a clear distinction between the disk cache package and the proxy backends, and avoids http_test.go ambiguity in go test error log messages (we previously had two http_test.go files).


Patch:
diff --git a/BUILD.bazel b/BUILD.bazel
index 0fe79e8..12c1603 100644
--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -21,9 +21,9 @@ go_library(
     deps = [
         "//cache:go_default_library",
         "//cache/disk:go_default_library",
-        "//cache/gcs:go_default_library",
-        "//cache/http:go_default_library",
-        "//cache/s3:go_default_library",
+        "//cache/gcsproxy:go_default_library",
+        "//cache/httpproxy:go_default_library",
+        "//cache/s3proxy:go_default_library",
         "//config:go_default_library",
         "//server:go_default_library",
         "@com_github_abbot_go_http_auth//:go_default_library",
diff --git a/cache/disk/BUILD.bazel b/cache/disk/BUILD.bazel
index 36a81ff..26b31f2 100644
--- a/cache/disk/BUILD.bazel
+++ b/cache/disk/BUILD.bazel
@@ -27,7 +27,7 @@ go_test(
     embed = [":go_default_library"],
     deps = [
         "//cache:go_default_library",
-        "//cache/http:go_default_library",
+        "//cache/httpproxy:go_default_library",
         "//utils:go_default_library",
     ],
 )
diff --git a/cache/gcs/BUILD.bazel b/cache/gcsproxy/BUILD.bazel
similarity index 68%
rename from cache/gcs/BUILD.bazel
rename to cache/gcsproxy/BUILD.bazel
index 588aaa3..0e8a0a1 100644
--- a/cache/gcs/BUILD.bazel
+++ b/cache/gcsproxy/BUILD.bazel
@@ -2,12 +2,12 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
 
 go_library(
     name = "go_default_library",
-    srcs = ["gcs.go"],
-    importpath = "github.com/buchgr/bazel-remote/cache/gcs",
+    srcs = ["gcsproxy.go"],
+    importpath = "github.com/buchgr/bazel-remote/cache/gcsproxy",
     visibility = ["//visibility:public"],
     deps = [
         "//cache:go_default_library",
-        "//cache/http:go_default_library",
+        "//cache/httpproxy:go_default_library",
         "@org_golang_x_oauth2//:go_default_library",
         "@org_golang_x_oauth2//google:go_default_library",
     ],
diff --git a/cache/gcs/gcs.go b/cache/gcsproxy/gcsproxy.go
similarity index 92%
rename from cache/gcs/gcs.go
rename to cache/gcsproxy/gcsproxy.go
index 61c3e5b..a47b30a 100644
--- a/cache/gcs/gcs.go
+++ b/cache/gcsproxy/gcsproxy.go
@@ -1,6 +1,6 @@
 // Package gcs provides cache implementation that proxies requests to/from
 // Google Cloud Storage (GCS).
-package gcs
+package gcsproxy
 
 import (
 	"fmt"
@@ -9,7 +9,7 @@ import (
 	"net/url"
 
 	"github.com/buchgr/bazel-remote/cache"
-	cachehttp "github.com/buchgr/bazel-remote/cache/http"
+	"github.com/buchgr/bazel-remote/cache/httpproxy"
 
 	"golang.org/x/oauth2"
 	"golang.org/x/oauth2/google"
@@ -53,5 +53,5 @@ func New(bucket string, useDefaultCredentials bool, jsonCredentialsFile string,
 		Path:   bucket,
 	}
 
-	return cachehttp.New(&baseURL, remoteClient, accessLogger, errorLogger), nil
+	return httpproxy.New(&baseURL, remoteClient, accessLogger, errorLogger), nil
 }
diff --git a/cache/http/BUILD.bazel b/cache/httpproxy/BUILD.bazel
similarity index 82%
rename from cache/http/BUILD.bazel
rename to cache/httpproxy/BUILD.bazel
index 200717d..c252723 100644
--- a/cache/http/BUILD.bazel
+++ b/cache/httpproxy/BUILD.bazel
@@ -2,8 +2,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
 
 go_library(
     name = "go_default_library",
-    srcs = ["http.go"],
-    importpath = "github.com/buchgr/bazel-remote/cache/http",
+    srcs = ["httpproxy.go"],
+    importpath = "github.com/buchgr/bazel-remote/cache/httpproxy",
     visibility = ["//visibility:public"],
     deps = [
         "//cache:go_default_library",
@@ -14,7 +14,7 @@ go_library(
 
 go_test(
     name = "go_default_test",
-    srcs = ["http_test.go"],
+    srcs = ["httpproxy_test.go"],
     embed = [":go_default_library"],
     deps = [
         "//cache:go_default_library",
diff --git a/cache/http/http.go b/cache/httpproxy/httpproxy.go
similarity index 99%
rename from cache/http/http.go
rename to cache/httpproxy/httpproxy.go
index 4a00d9a..01abec5 100644
--- a/cache/http/http.go
+++ b/cache/httpproxy/httpproxy.go
@@ -1,6 +1,6 @@
 // Package http is a cache implementation that can proxy artifacts from/to another
 // HTTP-based remote cache
-package http
+package httpproxy
 
 import (
 	"errors"
diff --git a/cache/s3/BUILD.bazel b/cache/s3proxy/BUILD.bazel
similarity index 85%
rename from cache/s3/BUILD.bazel
rename to cache/s3proxy/BUILD.bazel
index 5ddece2..e759723 100644
--- a/cache/s3/BUILD.bazel
+++ b/cache/s3proxy/BUILD.bazel
@@ -2,8 +2,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
 
 go_library(
     name = "go_default_library",
-    srcs = ["s3.go"],
-    importpath = "github.com/buchgr/bazel-remote/cache/s3",
+    srcs = ["s3proxy.go"],
+    importpath = "github.com/buchgr/bazel-remote/cache/s3proxy",
     visibility = ["//visibility:public"],
     deps = [
         "//cache:go_default_library",
diff --git a/cache/s3/minio-test-setup.md b/cache/s3proxy/minio-test-setup.md
similarity index 100%
rename from cache/s3/minio-test-setup.md
rename to cache/s3proxy/minio-test-setup.md
diff --git a/cache/s3/s3.go b/cache/s3proxy/s3proxy.go
similarity index 99%
rename from cache/s3/s3.go
rename to cache/s3proxy/s3proxy.go
index 772b41a..fbabad2 100644
--- a/cache/s3/s3.go
+++ b/cache/s3proxy/s3proxy.go
@@ -1,4 +1,4 @@
-package s3
+package s3proxy
 
 import (
 	"errors"
diff --git a/main.go b/main.go
index cb23537..2225bde 100644
--- a/main.go
+++ b/main.go
@@ -16,10 +16,10 @@ import (
 	auth "github.com/abbot/go-http-auth"
 	"github.com/buchgr/bazel-remote/cache"
 	"github.com/buchgr/bazel-remote/cache/disk"
-	"github.com/buchgr/bazel-remote/cache/gcs"
-	"github.com/buchgr/bazel-remote/cache/s3"
+	"github.com/buchgr/bazel-remote/cache/gcsproxy"
+	"github.com/buchgr/bazel-remote/cache/s3proxy"
 
-	cachehttp "github.com/buchgr/bazel-remote/cache/http"
+	"github.com/buchgr/bazel-remote/cache/httpproxy"
 
 	"github.com/buchgr/bazel-remote/config"
 	"github.com/buchgr/bazel-remote/server"
@@ -237,7 +237,7 @@ func main() {
 
 		var proxyCache cache.CacheProxy
 		if c.GoogleCloudStorage != nil {
-			proxyCache, err = gcs.New(c.GoogleCloudStorage.Bucket,
+			proxyCache, err = gcsproxy.New(c.GoogleCloudStorage.Bucket,
 				c.GoogleCloudStorage.UseDefaultCredentials, c.GoogleCloudStorage.JSONCredentialsFile,
 				accessLogger, errorLogger)
 			if err != nil {
@@ -250,10 +250,10 @@ func main() {
 			if err != nil {
 				log.Fatal(err)
 			}
-			proxyCache = cachehttp.New(baseURL,
+			proxyCache = httpproxy.New(baseURL,
 				httpClient, accessLogger, errorLogger)
 		} else if c.S3CloudStorage != nil {
-			proxyCache = s3.New(c.S3CloudStorage, accessLogger, errorLogger)
+			proxyCache = s3proxy.New(c.S3CloudStorage, accessLogger, errorLogger)
 		}
 
 		diskCache := disk.New(c.Dir, int64(c.MaxSize)*1024*1024*1024, proxyCache)


Test patch:
diff --git a/cache/disk/disk_test.go b/cache/disk/disk_test.go
index 2f93522..ab2e295 100644
--- a/cache/disk/disk_test.go
+++ b/cache/disk/disk_test.go
@@ -18,7 +18,7 @@ import (
 	"time"
 
 	"github.com/buchgr/bazel-remote/cache"
-	cachehttp "github.com/buchgr/bazel-remote/cache/http"
+	"github.com/buchgr/bazel-remote/cache/httpproxy"
 	"github.com/buchgr/bazel-remote/utils"
 
 	pb "github.com/bazelbuild/remote-apis/build/bazel/remote/execution/v2"
@@ -543,7 +543,7 @@ func TestHttpProxyBackend(t *testing.T) {
 	accessLogger := testutils.NewSilentLogger()
 	errorLogger := testutils.NewSilentLogger()
 
-	proxy := cachehttp.New(url, &http.Client{}, accessLogger, errorLogger)
+	proxy := httpproxy.New(url, &http.Client{}, accessLogger, errorLogger)
 
 	cacheDir := testutils.TempDir(t)
 	defer os.RemoveAll(cacheDir)
diff --git a/cache/http/http_test.go b/cache/httpproxy/httpproxy_test.go
similarity index 99%
rename from cache/http/http_test.go
rename to cache/httpproxy/httpproxy_test.go
index b993564..35073e7 100644
--- a/cache/http/http_test.go
+++ b/cache/httpproxy/httpproxy_test.go
@@ -1,4 +1,4 @@
-package http
+package httpproxy
 
 import (
 	"bytes"