From e19bb6f290b8c7335935fce3a7e94cb903507470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Thu, 6 Aug 2026 21:33:41 +0400 Subject: [PATCH] =?UTF-8?q?go-container:=20S3=5FPREFIX,=20VERSION=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B3=D0=BB=D0=B0=D0=B2=D0=BD=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/main.go | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/server/main.go b/server/main.go index 754f90d..7ea1c39 100644 --- a/server/main.go +++ b/server/main.go @@ -20,8 +20,11 @@ var ( s3Client *s3.Client bucketName = "terraform-registry" // Default hostname = os.Getenv("REGISTRY_HOSTNAME") + s3Prefix = os.Getenv("S3_PREFIX") // S3 key prefix (may differ from hostname) ) +const VERSION = "1.0.0" + // Terraform Registry Protocol Structs type Discovery struct { ProvidersV1 string `json:"providers.v1"` @@ -70,6 +73,9 @@ func main() { if hostname == "" { hostname = "localhost:8080" } + if s3Prefix == "" { + s3Prefix = hostname + } endpoint := os.Getenv("S3_ENDPOINT") accessKeyID := os.Getenv("S3_ACCESS_KEY") @@ -97,7 +103,7 @@ func main() { http.HandleFunc("/healthz", healthzHandler) http.HandleFunc("/readyz", readyzHandler) - port := os.Getenv("PORT") + port := os.Getenv("PORT") if port == "" { port = "5000" } @@ -111,12 +117,12 @@ func rootHandler(w http.ResponseWriter, r *http.Request) { return } w.Header().Set("Content-Type", "text/html; charset=utf-8") - fmt.Fprint(w, ` + fmt.Fprintf(w, ` -Terra Registry +Terra Registry v`+VERSION+` -

Terra Registry & Documentation Server

+

Terra Registry & Documentation Server v`+VERSION+`

Status: ONLINE


Powered by Nubes Cloud S3 Storage

@@ -181,7 +187,7 @@ func router(w http.ResponseWriter, r *http.Request) { } func listVersions(w http.ResponseWriter, r *http.Request, namespace, pType string) { - prefix := fmt.Sprintf("%s/%s/%s/", hostname, namespace, pType) + prefix := fmt.Sprintf("%s/%s/%s/", s3Prefix, namespace, pType) ctx := context.Background() versions := []Version{} seenVersions := map[string]*Version{} @@ -235,7 +241,7 @@ func listVersions(w http.ResponseWriter, r *http.Request, namespace, pType strin } func downloadVersion(w http.ResponseWriter, r *http.Request, namespace, pType, version, osType, arch string) { - basePath := fmt.Sprintf("%s/%s/%s/%s", hostname, namespace, pType, version) + basePath := fmt.Sprintf("%s/%s/%s/%s", s3Prefix, namespace, pType, version) filename := fmt.Sprintf("terraform-provider-%s_%s_%s_%s.zip", pType, version, osType, arch) fullKey := fmt.Sprintf("%s/%s", basePath, filename) shasumsKey := fmt.Sprintf("%s/terraform-provider-%s_%s_SHA256SUMS", basePath, pType, version)