Skip to content

Commit 03ac03f

Browse files
neodinoAleksandar NikolikjQingping Hou
authored
Adding endpoint config to enable minio backend (#6)
adds endpoint and disable ssl config to enable support for minio Co-authored-by: Aleksandar Nikolikj <aleksandar.nikolikj@ericsson.com> Co-authored-by: Qingping Hou <qph@scribd.com>
1 parent 54bad26 commit 03ac03f

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ var (
2626
FlagExclude []string
2727
FlagScratch bool
2828
FlagDefaultFileMode = "0664"
29+
FlagS3Endpoint = ""
30+
FlagDisableSSL = false
2931

3032
metricsSyncTime = prometheus.NewGauge(prometheus.GaugeOpts{
3133
Namespace: "objinsync",
@@ -102,6 +104,8 @@ func main() {
102104
if err != nil {
103105
log.Fatal(err)
104106
}
107+
puller.DisableSSL = FlagDisableSSL
108+
puller.S3Endpoint = FlagS3Endpoint
105109
if FlagExclude != nil {
106110
puller.AddExcludePatterns(FlagExclude)
107111
}
@@ -156,6 +160,8 @@ func main() {
156160

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

173181
rootCmd.AddCommand(pullCmd)
174182
rootCmd.Execute()

pkg/sync/pull.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,10 @@ func uidFromLocalPath(localPath string) (string, error) {
9999
}
100100

101101
type Puller struct {
102-
RemoteUri string
103-
LocalDir string
102+
RemoteUri string
103+
LocalDir string
104+
DisableSSL bool
105+
S3Endpoint string
104106

105107
workingDir string
106108
defaultMode os.FileMode
@@ -308,7 +310,16 @@ func (self *Puller) Pull() string {
308310
}
309311
}
310312

311-
svc := s3.New(sess, aws.NewConfig().WithRegion(region))
313+
s3Config := &aws.Config{Region: aws.String(region)}
314+
if self.DisableSSL {
315+
s3Config.DisableSSL = aws.Bool(true)
316+
}
317+
if self.S3Endpoint != "" {
318+
s3Config.Endpoint = aws.String(self.S3Endpoint)
319+
s3Config.S3ForcePathStyle = aws.Bool(true)
320+
}
321+
svc := s3.New(sess, s3Config)
322+
312323
downloader := s3manager.NewDownloaderWithClient(svc)
313324

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

0 commit comments

Comments
 (0)