feat: add minio support (#1048)

* feat: add minio support

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* feat: add TLS skip for custom https minio endpoint

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

* feat: update cache with the new proto schema

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>

---------

Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
This commit is contained in:
Aris Boutselis
2024-04-19 11:58:41 +01:00
committed by GitHub
parent 3eaf776249
commit e6085d4191
11 changed files with 51 additions and 26 deletions

20
pkg/cache/s3_based.go vendored
View File

@@ -2,7 +2,9 @@ package cache
import (
"bytes"
"crypto/tls"
"log"
"net/http"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
@@ -17,17 +19,16 @@ type S3Cache struct {
}
type S3CacheConfiguration struct {
Region string `mapstructure:"region" yaml:"region,omitempty"`
BucketName string `mapstructure:"bucketname" yaml:"bucketname,omitempty"`
Region string `mapstructure:"region" yaml:"region,omitempty"`
BucketName string `mapstructure:"bucketname" yaml:"bucketname,omitempty"`
Endpoint string `mapstructure:"endpoint" yaml:"endpoint,omitempty"`
InsecureSkipVerify bool `mapstructure:"insecure" yaml:"insecure,omitempty"`
}
func (s *S3Cache) Configure(cacheInfo CacheProvider) error {
if cacheInfo.S3.BucketName == "" {
log.Fatal("Bucket name not configured")
}
if cacheInfo.S3.Region == "" {
log.Fatal("Region not configured")
}
s.bucketName = cacheInfo.S3.BucketName
sess := session.Must(session.NewSessionWithOptions(session.Options{
@@ -36,6 +37,15 @@ func (s *S3Cache) Configure(cacheInfo CacheProvider) error {
Region: aws.String(cacheInfo.S3.Region),
},
}))
if cacheInfo.S3.Endpoint != "" {
sess.Config.Endpoint = &cacheInfo.S3.Endpoint
sess.Config.S3ForcePathStyle = aws.Bool(true)
transport := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: cacheInfo.S3.InsecureSkipVerify},
}
customClient := &http.Client{Transport: transport}
sess.Config.HTTPClient = customClient
}
s3Client := s3.New(sess)