dpb587 / metalink-repository-resource

A Concourse resource for managing versions/files in a Metalink repository.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow for private bucket usage

luan opened this issue · comments

Once dpb587/metalink#2 or similar is implemented, this resource should also receive something like the following to support the option:

diff --git a/factory/url_loader_factory.go b/factory/url_loader_factory.go
index cc66e88..0acadec 100644
--- a/factory/url_loader_factory.go
+++ b/factory/url_loader_factory.go
@@ -3,13 +3,13 @@ package factory
 import (
        "fmt"

+       "github.com/dpb587/metalink-repository-resource/api"
+       "github.com/dpb587/metalink/file/url"
        fileurl "github.com/dpb587/metalink/file/url/file"
        ftpurl "github.com/dpb587/metalink/file/url/ftp"
        httpurl "github.com/dpb587/metalink/file/url/http"
        s3url "github.com/dpb587/metalink/file/url/s3"
        "github.com/dpb587/metalink/file/url/urlutil"
-       "github.com/dpb587/metalink/file/url"
-       "github.com/dpb587/metalink-repository-resource/api"
 )

 func GetURLLoader(handlers []api.HandlerSource) url.Loader {
@@ -40,6 +40,15 @@ func GetURLLoader(handlers []api.HandlerSource) url.Loader {
                                opts.SecretKey = valStr
                        }

+                       if val, ok := handlerSource.Options["private"]; ok {
+                               valBool, ok := val.(bool)
+                               if !ok {
+                                       panic("unsupported handler option: s3: private: expected bool")
+                               }
+
+                               opts.Private = valBool
+                       }
+
                        handlerLoader = s3url.NewLoader(opts)
                default:
                        panic(fmt.Errorf("unsupported handler: %s", handlerSource.Type))

Not sending a PR yet because of the vendor race, but figured we'd create a tracking issue.