~sircmpwn/core-go

d99f0983a00d87bd2be911bfa3f30dc6ec0784bd — Simon Ser 5 months ago e81358e
s3: add [objects]s3-insecure

Disables TLS. Useful for local development.
1 files changed, 10 insertions(+), 2 deletions(-)

M s3/middleware.go
M s3/middleware.go => s3/middleware.go +10 -2
@@ 44,20 44,28 @@ func NewClient(conf ini.File) (*minio.Client, error) {
	upstream, _ := conf.Get("objects", "s3-upstream")
	accessKey, _ := conf.Get("objects", "s3-access-key")
	secretKey, _ := conf.Get("objects", "s3-secret-key")
	insecure, _ := conf.Get("objects", "s3-insecure")
	if upstream == "" || accessKey == "" || secretKey == "" {
		return nil, ErrDisabled
	}

	return minio.New(upstream, &minio.Options{
		Creds:  credentials.NewStaticV4(accessKey, secretKey, ""),
		Secure: true,
		Secure: insecure != "yes",
	})
}

func URL(conf ini.File, bucket string) string {
	upstream, _ := conf.Get("objects", "s3-upstream")
	insecure, _ := conf.Get("objects", "s3-insecure")
	if upstream == "" {
		return ""
	}
	return "https://" + upstream

	proto := "https"
	if insecure == "yes" {
		proto = "http"
	}

	return proto + "://" + upstream
}