From eb6123f5eda25dd530b3fb5a160e23e79adfcb2a Mon Sep 17 00:00:00 2001 From: Ankur Kothiwal Date: Tue, 7 May 2024 17:03:12 +0200 Subject: [PATCH] fix logic for handling regionEndpoint With the current logic we only verifies the region and return if it's empty; we were not validating the regionEndpoint parameter. Signed-off-by: Ankur Kothiwal --- registry/storage/driver/s3-aws/s3.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/registry/storage/driver/s3-aws/s3.go b/registry/storage/driver/s3-aws/s3.go index 71b7b793ae..dab51d481a 100644 --- a/registry/storage/driver/s3-aws/s3.go +++ b/registry/storage/driver/s3-aws/s3.go @@ -223,12 +223,13 @@ func FromParameters(ctx context.Context, parameters map[string]interface{}) (*Dr } regionName := parameters["region"] - if regionName == nil || fmt.Sprint(regionName) == "" { - return nil, fmt.Errorf("no region parameter provided") - } region := fmt.Sprint(regionName) + // Don't check the region value if a custom endpoint is provided. if regionEndpoint == "" { + if regionName == nil || region == "" { + return nil, fmt.Errorf("no region parameter provided") + } if _, ok := validRegions[region]; !ok { return nil, fmt.Errorf("invalid region provided: %v", region) }