Skip to content

Commit

Permalink
Adding endpoint config to enable minio backend (#6)
Browse files Browse the repository at this point in the history
adds endpoint and disable ssl config to enable support for minio

Co-authored-by: Aleksandar Nikolikj <[email protected]>
Co-authored-by: Qingping Hou <[email protected]>
  • Loading branch information
3 people authored Apr 3, 2020
1 parent 54bad26 commit 03ac03f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var (
FlagExclude []string
FlagScratch bool
FlagDefaultFileMode = "0664"
FlagS3Endpoint = ""
FlagDisableSSL = false

metricsSyncTime = prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: "objinsync",
Expand Down Expand Up @@ -102,6 +104,8 @@ func main() {
if err != nil {
log.Fatal(err)
}
puller.DisableSSL = FlagDisableSSL
puller.S3Endpoint = FlagS3Endpoint
if FlagExclude != nil {
puller.AddExcludePatterns(FlagExclude)
}
Expand Down Expand Up @@ -156,6 +160,8 @@ func main() {

pullCmd.PersistentFlags().BoolVarP(
&FlagRunOnce, "once", "o", false, "run action once and then exit")
pullCmd.PersistentFlags().BoolVarP(
&FlagDisableSSL, "disable-ssl", "", false, "disable SSL for object storage connection")
pullCmd.PersistentFlags().StringVarP(
&FlagStatusAddr, "status-addr", "s", ":8087", "binding address for status endpoint")
pullCmd.PersistentFlags().StringSliceVarP(
Expand All @@ -169,6 +175,8 @@ func main() {
)
pullCmd.PersistentFlags().StringVarP(
&FlagDefaultFileMode, "default-file-mode", "m", "0664", "default mode to use for creating local file")
pullCmd.PersistentFlags().StringVarP(
&FlagS3Endpoint, "s3-endpoint", "", "", "override endpoint to use for remote object store (e.g. minio)")

rootCmd.AddCommand(pullCmd)
rootCmd.Execute()
Expand Down
18 changes: 15 additions & 3 deletions pkg/sync/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,10 @@ func uidFromLocalPath(localPath string) (string, error) {
}

type Puller struct {
RemoteUri string
LocalDir string
RemoteUri string
LocalDir string
DisableSSL bool
S3Endpoint string

workingDir string
defaultMode os.FileMode
Expand Down Expand Up @@ -308,7 +310,16 @@ func (self *Puller) Pull() string {
}
}

svc := s3.New(sess, aws.NewConfig().WithRegion(region))
s3Config := &aws.Config{Region: aws.String(region)}
if self.DisableSSL {
s3Config.DisableSSL = aws.Bool(true)
}
if self.S3Endpoint != "" {
s3Config.Endpoint = aws.String(self.S3Endpoint)
s3Config.S3ForcePathStyle = aws.Bool(true)
}
svc := s3.New(sess, s3Config)

downloader := s3manager.NewDownloaderWithClient(svc)

if err := self.SetupWorkingDir(); err != nil {
Expand Down Expand Up @@ -460,6 +471,7 @@ func NewPuller(remoteUri string, localDir string) (*Puller, error) {
return &Puller{
RemoteUri: remoteUri,
LocalDir: localDir,
DisableSSL: false,
workingDir: filepath.Join(localDir, ".objinsync"),
defaultMode: 0664,
workerCnt: 5,
Expand Down

0 comments on commit 03ac03f

Please sign in to comment.