From 8ba6261e18b0f571a12ab503846d8175d1cbfd1f Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 28 Apr 2015 12:50:44 -0700 Subject: [PATCH 1/2] Make getURL - getExpandedURL --- cmd-access.go | 2 +- cmd-cat.go | 2 +- cmd-cp.go | 2 +- cmd-ls.go | 2 +- cmd-mb.go | 2 +- cmd_test.go | 32 ++++++++++++++++---------------- url.go | 10 +++++----- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/cmd-access.go b/cmd-access.go index 2604f4fc..1166b11a 100644 --- a/cmd-access.go +++ b/cmd-access.go @@ -39,7 +39,7 @@ func runAccessCmd(ctx *cli.Context) { } targetURLConfigMap := make(map[string]*hostConfig) - targetURLs, err := getURLs(ctx.Args(), config.Aliases) + targetURLs, err := getExpandedURLs(ctx.Args(), config.Aliases) if err != nil { switch e := iodine.ToError(err).(type) { case errUnsupportedScheme: diff --git a/cmd-cat.go b/cmd-cat.go index a4d29741..e7bdb28e 100644 --- a/cmd-cat.go +++ b/cmd-cat.go @@ -41,7 +41,7 @@ func runCatCmd(ctx *cli.Context) { } // Convert arguments to URLs: expand alias, fix format... - urls, err := getURLs(ctx.Args(), config.Aliases) + urls, err := getExpandedURLs(ctx.Args(), config.Aliases) if err != nil { switch e := iodine.ToError(err).(type) { case errUnsupportedScheme: diff --git a/cmd-cp.go b/cmd-cp.go index 10e4977c..625ca846 100644 --- a/cmd-cp.go +++ b/cmd-cp.go @@ -37,7 +37,7 @@ func runCopyCmd(ctx *cli.Context) { } // Convert arguments to URLs: expand alias, fix format... - urls, err := getURLs(ctx.Args(), config.Aliases) + urls, err := getExpandedURLs(ctx.Args(), config.Aliases) if err != nil { switch e := iodine.ToError(err).(type) { case errUnsupportedScheme: diff --git a/cmd-ls.go b/cmd-ls.go index b419aec5..7f50cdbc 100644 --- a/cmd-ls.go +++ b/cmd-ls.go @@ -39,7 +39,7 @@ func runListCmd(ctx *cli.Context) { } targetURLConfigMap := make(map[string]*hostConfig) for _, arg := range ctx.Args() { - targetURL, err := getURL(arg, config.Aliases) + targetURL, err := getExpandedURL(arg, config.Aliases) if err != nil { switch iodine.ToError(err).(type) { case errUnsupportedScheme: diff --git a/cmd-mb.go b/cmd-mb.go index 4a2a4a2c..a6900b51 100644 --- a/cmd-mb.go +++ b/cmd-mb.go @@ -38,7 +38,7 @@ func runMakeBucketCmd(ctx *cli.Context) { console.Fatalf("Unable to read config file [%s].\n", mustGetMcConfigPath()) } targetURLConfigMap := make(map[string]*hostConfig) - targetURLs, err := getURLs(ctx.Args(), config.Aliases) + targetURLs, err := getExpandedURLs(ctx.Args(), config.Aliases) if err != nil { switch e := iodine.ToError(err).(type) { case errUnsupportedScheme: diff --git a/cmd_test.go b/cmd_test.go index 72cf4c87..7e7df9fc 100644 --- a/cmd_test.go +++ b/cmd_test.go @@ -48,7 +48,7 @@ var _ = Suite(&CmdTestSuite{}) func (s *CmdTestSuite) TestCopyToSingleTarget(c *C) { methods := &MockclientMethods{} - sourceURL, err := getURL("foo", nil) + sourceURL, err := getExpandedURL("foo", nil) c.Assert(err, IsNil) data := "Hello World" @@ -56,7 +56,7 @@ func (s *CmdTestSuite) TestCopyToSingleTarget(c *C) { hexMd5 := hex.EncodeToString(md5Sum[:]) dataLength := int64(len(data)) - targetURL, err := getURL("bar", nil) + targetURL, err := getExpandedURL("bar", nil) c.Assert(err, IsNil) sourceReader, sourceWriter := io.Pipe() @@ -93,10 +93,10 @@ func (s *CmdTestSuite) TestCopyToSingleTarget(c *C) { } func (s *CmdTestSuite) TestCopyRecursive(c *C) { - sourceURL, err := getURL("http://example.com/bucket1/", nil) + sourceURL, err := getExpandedURL("http://example.com/bucket1/", nil) c.Assert(err, IsNil) - targetURL, err := getURL("http://example.com/bucket2/", nil) + targetURL, err := getExpandedURL("http://example.com/bucket2/", nil) c.Assert(err, IsNil) methods := &MockclientMethods{} @@ -192,10 +192,10 @@ func (c *failClose) Close() error { func (s *CmdTestSuite) TestCopyCmdFailures(c *C) { methods := &MockclientMethods{} - sourceURL, err := getURL("foo", nil) + sourceURL, err := getExpandedURL("foo", nil) c.Assert(err, IsNil) - targetURL, err := getURL("bar", nil) + targetURL, err := getExpandedURL("bar", nil) c.Assert(err, IsNil) var nilReadCloser io.ReadCloser @@ -269,7 +269,7 @@ func (s *CmdTestSuite) TestCopyCmdFailures(c *C) { } func (s *CmdTestSuite) TestLsCmdWithBucket(c *C) { - sourceURL, err := getURL("http://example.com/bucket1/", nil) + sourceURL, err := getExpandedURL("http://example.com/bucket1/", nil) c.Assert(err, IsNil) methods := &MockclientMethods{} @@ -312,7 +312,7 @@ func (s *CmdTestSuite) TestLsCmdWithBucket(c *C) { } func (s *CmdTestSuite) TestLsCmdWithFilePath(c *C) { - sourceURL, err := getURL("foo", nil) + sourceURL, err := getExpandedURL("foo", nil) c.Assert(err, IsNil) methods := &MockclientMethods{} @@ -356,7 +356,7 @@ func (s *CmdTestSuite) TestLsCmdWithFilePath(c *C) { } func (s *CmdTestSuite) TestLsCmdListsBuckets(c *C) { - sourceURL, err := getURL("http://example.com", nil) + sourceURL, err := getExpandedURL("http://example.com", nil) c.Assert(err, IsNil) methods := &MockclientMethods{} @@ -393,7 +393,7 @@ func (s *CmdTestSuite) TestLsCmdListsBuckets(c *C) { } func (s *CmdTestSuite) TestMbCmd(c *C) { - sourceURL, err := getURL("http://example.com/bucket1", nil) + sourceURL, err := getExpandedURL("http://example.com/bucket1", nil) c.Assert(err, IsNil) methods := &MockclientMethods{} @@ -416,7 +416,7 @@ func (s *CmdTestSuite) TestMbCmd(c *C) { } func (s *CmdTestSuite) TestMbCmdFailures(c *C) { - sourceURL, err := getURL("http://example.com/bucket1", nil) + sourceURL, err := getExpandedURL("http://example.com/bucket1", nil) c.Assert(err, IsNil) methods := &MockclientMethods{} @@ -461,7 +461,7 @@ func (s *CmdTestSuite) TestMbCmdFailures(c *C) { } func (s *CmdTestSuite) TestMbCmdOnFile(c *C) { - sourceURL, err := getURL("bucket1", nil) + sourceURL, err := getExpandedURL("bucket1", nil) c.Assert(err, IsNil) methods := &MockclientMethods{} @@ -484,9 +484,9 @@ func (s *CmdTestSuite) TestMbCmdOnFile(c *C) { } func (s *CmdTestSuite) TestCatCmdObject(c *C) { - sourceURL, err := getURL("http://example.com/bucket1/object1", nil) + sourceURL, err := getExpandedURL("http://example.com/bucket1/object1", nil) c.Assert(err, IsNil) - targetURL, err := getURL("object1", nil) + targetURL, err := getExpandedURL("object1", nil) c.Assert(err, IsNil) methods := &MockclientMethods{} @@ -537,9 +537,9 @@ func (s *CmdTestSuite) TestCatCmdObject(c *C) { } func (s *CmdTestSuite) TestCatCmdFile(c *C) { - sourceURL, err := getURL("object1", nil) + sourceURL, err := getExpandedURL("object1", nil) c.Assert(err, IsNil) - targetURL, err := getURL("object2", nil) + targetURL, err := getExpandedURL("object2", nil) c.Assert(err, IsNil) methods := &MockclientMethods{} diff --git a/url.go b/url.go index 3c0ba64f..a6ca55ba 100644 --- a/url.go +++ b/url.go @@ -35,8 +35,8 @@ func isURLRecursive(urlStr string) bool { return strings.HasSuffix(urlStr, recursiveSeparator) } -// getURL - extracts URL string from a single cmd-line argument -func getURL(arg string, aliases map[string]string) (urlStr string, err error) { +// getExpandedURL - extracts URL string from a single cmd-line argument +func getExpandedURL(arg string, aliases map[string]string) (urlStr string, err error) { _, err = url.Parse(arg) if err != nil { // Not a valid URL. Return error @@ -56,10 +56,10 @@ func getURL(arg string, aliases map[string]string) (urlStr string, err error) { return urlStr, nil } -// getURLs - extracts multiple URL strings from a single cmd-line argument -func getURLs(args []string, aliases map[string]string) (urls []string, err error) { +// getExpandedURLs - extracts multiple URL strings from a single cmd-line argument +func getExpandedURLs(args []string, aliases map[string]string) (urls []string, err error) { for _, arg := range args { - u, err := getURL(arg, aliases) + u, err := getExpandedURL(arg, aliases) if err != nil { return nil, iodine.New(err, nil) } From 29562bc88703ce432a7c6de6e580abc3e82d671d Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Tue, 28 Apr 2015 12:56:39 -0700 Subject: [PATCH 2/2] Implement sync command for single source multiple targets --- cmd-config.go | 202 ++++++++----------------------------------------- cmd-cp.go | 2 +- cmd-sync.go | 81 +++++++++++++++++++- config.go | 159 ++++++++++++++++++++++++++++++++++++++ hash-binary.go | 16 ++++ hostconfig.go | 5 ++ 6 files changed, 291 insertions(+), 174 deletions(-) create mode 100644 config.go diff --git a/cmd-config.go b/cmd-config.go index 87182ad1..865472f5 100644 --- a/cmd-config.go +++ b/cmd-config.go @@ -17,13 +17,8 @@ package main import ( - "os" - "path" - "runtime" "strings" - "os/user" - "github.com/minio-io/cli" "github.com/minio-io/mc/pkg/console" "github.com/minio-io/mc/pkg/quick" @@ -31,173 +26,6 @@ import ( "github.com/minio-io/minio/pkg/utils/log" ) -type hostConfig struct { - AccessKeyID string - SecretAccessKey string -} - -type configV1 struct { - Version string - Aliases map[string]string - Hosts map[string]*hostConfig -} - -// getMcConfigDir - construct minio client config folder -func getMcConfigDir() (string, error) { - u, err := user.Current() - if err != nil { - return "", iodine.New(err, nil) - } - // For windows the path is slightly different - switch runtime.GOOS { - case "windows": - return path.Join(u.HomeDir, mcConfigWindowsDir), nil - default: - return path.Join(u.HomeDir, mcConfigDir), nil - } -} - -// createMcConfigDir - create minio client config folder -func createMcConfigDir() error { - p, err := getMcConfigDir() - if err != nil { - return iodine.New(err, nil) - } - err = os.MkdirAll(p, 0700) - if err != nil { - return iodine.New(err, nil) - } - return nil -} - -// getMcConfigPath - construct minio client configuration path -func getMcConfigPath() (string, error) { - dir, err := getMcConfigDir() - if err != nil { - return "", iodine.New(err, nil) - } - return path.Join(dir, mcConfigFile), nil -} - -// mustGetMcConfigPath - similar to getMcConfigPath, ignores errors -func mustGetMcConfigPath() string { - p, _ := getMcConfigPath() - return p -} - -// getMcConfig - reads configuration file and returns config -func getMcConfig() (config *configV1, err error) { - if !isMcConfigExist() { - return nil, iodine.New(errInvalidArgument{}, nil) - } - configFile, err := getMcConfigPath() - if err != nil { - return nil, iodine.New(err, nil) - } - conf := newConfigV1() - if config := quick.New(conf); config != nil { - if err := config.Load(configFile); err != nil { - return nil, iodine.New(err, nil) - } - return config.Data().(*configV1), nil - } - return nil, iodine.New(errInvalidArgument{}, nil) -} - -// isMcConfigExist returns true/false if config exists -func isMcConfigExist() bool { - configFile, err := getMcConfigPath() - if err != nil { - return false - } - _, err = os.Stat(configFile) - if err != nil { - return false - } - return true -} - -// writeConfig - write configuration file -func writeConfig(config quick.Config) error { - err := createMcConfigDir() - if err != nil { - return iodine.New(err, nil) - } - configPath, err := getMcConfigPath() - if err != nil { - return iodine.New(err, nil) - } - if err := config.Save(configPath); err != nil { - return iodine.New(err, nil) - } - return nil -} - -// newConfigV1() - get new config version 1.0 -func newConfigV1() *configV1 { - conf := new(configV1) - conf.Version = mcCurrentConfigVersion - // make sure to allocate map's otherwise Golang - // exists silently without providing any errors - conf.Hosts = make(map[string]*hostConfig) - conf.Aliases = make(map[string]string) - return conf -} - -// newConfig - get new config interface -func newConfig() (config quick.Config) { - conf := newConfigV1() - s3HostConf := new(hostConfig) - s3HostConf.AccessKeyID = globalAccessKeyID - s3HostConf.SecretAccessKey = globalSecretAccessKey - - // Your example host config - exampleHostConf := new(hostConfig) - exampleHostConf.AccessKeyID = globalAccessKeyID - exampleHostConf.SecretAccessKey = globalSecretAccessKey - - conf.Hosts[exampleHostURL] = exampleHostConf - conf.Hosts["http*://s3*.amazonaws.com"] = s3HostConf - - aliases := make(map[string]string) - aliases["s3"] = "https://s3.amazonaws.com" - aliases["localhost"] = "http://localhost:9000" - conf.Aliases = aliases - config = quick.New(conf) - - return config -} - -// addAlias - add new aliases -func addAlias(alias []string) (quick.Config, error) { - if len(alias) < 2 { - return nil, iodine.New(errInvalidArgument{}, nil) - } - conf := newConfigV1() - config := quick.New(conf) - config.Load(mustGetMcConfigPath()) - - aliasName := alias[0] - url := strings.TrimSuffix(alias[1], "/") - if strings.HasPrefix(aliasName, "http") { - return nil, iodine.New(errInvalidAliasName{name: aliasName}, nil) - } - if !strings.HasPrefix(url, "http") { - return nil, iodine.New(errInvalidURL{url: url}, nil) - } - if !isValidAliasName(aliasName) { - return nil, iodine.New(errInvalidAliasName{name: aliasName}, nil) - } - // convert interface{} back to its original struct - newConf := config.Data().(*configV1) - if _, ok := newConf.Aliases[aliasName]; ok { - return nil, iodine.New(errAliasExists{name: aliasName}, nil) - } - newConf.Aliases[aliasName] = url - newConfig := quick.New(newConf) - return newConfig, nil -} - // runConfigCmd is the handle for "mc config" sub-command func runConfigCmd(ctx *cli.Context) { // show help if nothing is set @@ -260,3 +88,33 @@ func doConfig(arg string, alias []string) (string, error) { } return "Configuration written to [" + configPath + "]. Please update your access credentials.", nil } + +// addAlias - add new aliases +func addAlias(alias []string) (quick.Config, error) { + if len(alias) < 2 { + return nil, iodine.New(errInvalidArgument{}, nil) + } + conf := newConfigV1() + config := quick.New(conf) + config.Load(mustGetMcConfigPath()) + + aliasName := alias[0] + url := strings.TrimSuffix(alias[1], "/") + if strings.HasPrefix(aliasName, "http") { + return nil, iodine.New(errInvalidAliasName{name: aliasName}, nil) + } + if !strings.HasPrefix(url, "http") { + return nil, iodine.New(errInvalidURL{url: url}, nil) + } + if !isValidAliasName(aliasName) { + return nil, iodine.New(errInvalidAliasName{name: aliasName}, nil) + } + // convert interface{} back to its original struct + newConf := config.Data().(*configV1) + if _, ok := newConf.Aliases[aliasName]; ok { + return nil, iodine.New(errAliasExists{name: aliasName}, nil) + } + newConf.Aliases[aliasName] = url + newConfig := quick.New(newConf) + return newConfig, nil +} diff --git a/cmd-cp.go b/cmd-cp.go index 625ca846..6662b00b 100644 --- a/cmd-cp.go +++ b/cmd-cp.go @@ -97,7 +97,7 @@ func runCopyCmdMultipleSources(methods clientMethods, urls []string) { if err != nil { log.Debug.Println(iodine.New(err, nil)) console.Fatalf("Unable to read host configuration for source [%s] from config file [%s]. Reason: [%s].\n", - sourceURLs, mustGetMcConfigPath(), iodine.ToError(err)) + newRegularSourceURLs, mustGetMcConfigPath(), iodine.ToError(err)) } err = doCopyMultipleSources(methods, newRegularSourceURLConfigMap, targetURL, targetConfig) if err != nil { diff --git a/cmd-sync.go b/cmd-sync.go index 15c11ab0..eadaa3b0 100644 --- a/cmd-sync.go +++ b/cmd-sync.go @@ -1,6 +1,85 @@ +/* + * Minio Client, (C) 2015 Minio, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main -import "github.com/minio-io/cli" +import ( + "strings" + + "github.com/minio-io/cli" + "github.com/minio-io/mc/pkg/console" + "github.com/minio-io/minio/pkg/iodine" + "github.com/minio-io/minio/pkg/utils/log" +) func runSyncCmd(ctx *cli.Context) { + if len(ctx.Args()) < 2 || ctx.Args().First() == "help" { + cli.ShowCommandHelpAndExit(ctx, "cp", 1) // last argument is exit code + } + + config, err := getMcConfig() + if err != nil { + log.Debug.Println(iodine.New(err, nil)) + console.Fatalf("Unable to read config file [%s]. Reason: [%s].\n", mustGetMcConfigPath(), iodine.ToError(err)) + } + + // Convert arguments to URLs: expand alias, fix format... + urls, err := getExpandedURLs(ctx.Args(), config.Aliases) + if err != nil { + switch e := iodine.ToError(err).(type) { + case errUnsupportedScheme: + log.Debug.Println(iodine.New(err, nil)) + console.Fatalf("Unknown type of URL(s).\n") + default: + log.Debug.Println(iodine.New(err, nil)) + console.Fatalf("Unable to parse arguments. Reason: [%s].\n", e) + } + } + methods := mcClientMethods{} + runCopyCmdSingleSourceMultipleTargets(methods, urls) +} + +func runCopyCmdSingleSourceMultipleTargets(methods clientMethods, urls []string) { + sourceURL := urls[0] // first arg is source + targetURLs := urls[1:] // all other are targets + + recursive := isURLRecursive(sourceURL) + // if recursive strip off the "..." + if recursive { + sourceURL = strings.TrimSuffix(sourceURL, recursiveSeparator) + } + sourceConfig, err := getHostConfig(sourceURL) + if err != nil { + log.Debug.Println(iodine.New(err, nil)) + console.Fatalf("Unable to read host configuration for the following targets %s from config file [%s]. Reason: [%s].\n", + sourceURL, mustGetMcConfigPath(), iodine.ToError(err)) + } + targetURLConfigMap, err := getHostConfigs(targetURLs) + if err != nil { + log.Debug.Println(iodine.New(err, nil)) + console.Fatalf("Unable to read host configuration for source [%s] from config file [%s]. Reason: [%s].\n", + targetURLs, mustGetMcConfigPath(), iodine.ToError(err)) + } + + for targetURL, targetConfig := range targetURLConfigMap { + err = doCopySingleSourceRecursive(methods, sourceURL, targetURL, sourceConfig, targetConfig) + if err != nil { + log.Debug.Println(err) + console.Fatalf("Failed to copy from source [%s] to target %s. Reason: [%s].\n", + sourceURL, targetURL, iodine.ToError(err)) + } + } } diff --git a/config.go b/config.go new file mode 100644 index 00000000..582275fd --- /dev/null +++ b/config.go @@ -0,0 +1,159 @@ +/* + * Minio Client (C) 2015 Minio, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package main + +import ( + "os" + "os/user" + "path" + "runtime" + + "github.com/minio-io/mc/pkg/quick" + "github.com/minio-io/minio/pkg/iodine" +) + +type configV1 struct { + Version string + Aliases map[string]string + Hosts map[string]*hostConfig +} + +// getMcConfigDir - construct minio client config folder +func getMcConfigDir() (string, error) { + u, err := user.Current() + if err != nil { + return "", iodine.New(err, nil) + } + // For windows the path is slightly different + switch runtime.GOOS { + case "windows": + return path.Join(u.HomeDir, mcConfigWindowsDir), nil + default: + return path.Join(u.HomeDir, mcConfigDir), nil + } +} + +// createMcConfigDir - create minio client config folder +func createMcConfigDir() error { + p, err := getMcConfigDir() + if err != nil { + return iodine.New(err, nil) + } + err = os.MkdirAll(p, 0700) + if err != nil { + return iodine.New(err, nil) + } + return nil +} + +// getMcConfigPath - construct minio client configuration path +func getMcConfigPath() (string, error) { + dir, err := getMcConfigDir() + if err != nil { + return "", iodine.New(err, nil) + } + return path.Join(dir, mcConfigFile), nil +} + +// mustGetMcConfigPath - similar to getMcConfigPath, ignores errors +func mustGetMcConfigPath() string { + p, _ := getMcConfigPath() + return p +} + +// getMcConfig - reads configuration file and returns config +func getMcConfig() (config *configV1, err error) { + if !isMcConfigExist() { + return nil, iodine.New(errInvalidArgument{}, nil) + } + configFile, err := getMcConfigPath() + if err != nil { + return nil, iodine.New(err, nil) + } + conf := newConfigV1() + if config := quick.New(conf); config != nil { + if err := config.Load(configFile); err != nil { + return nil, iodine.New(err, nil) + } + return config.Data().(*configV1), nil + } + return nil, iodine.New(errInvalidArgument{}, nil) +} + +// isMcConfigExist returns true/false if config exists +func isMcConfigExist() bool { + configFile, err := getMcConfigPath() + if err != nil { + return false + } + _, err = os.Stat(configFile) + if err != nil { + return false + } + return true +} + +// writeConfig - write configuration file +func writeConfig(config quick.Config) error { + err := createMcConfigDir() + if err != nil { + return iodine.New(err, nil) + } + configPath, err := getMcConfigPath() + if err != nil { + return iodine.New(err, nil) + } + if err := config.Save(configPath); err != nil { + return iodine.New(err, nil) + } + return nil +} + +// newConfigV1() - get new config version 1.0 +func newConfigV1() *configV1 { + conf := new(configV1) + conf.Version = mcCurrentConfigVersion + // make sure to allocate map's otherwise Golang + // exists silently without providing any errors + conf.Hosts = make(map[string]*hostConfig) + conf.Aliases = make(map[string]string) + return conf +} + +// newConfig - get new config interface +func newConfig() (config quick.Config) { + conf := newConfigV1() + s3HostConf := new(hostConfig) + s3HostConf.AccessKeyID = globalAccessKeyID + s3HostConf.SecretAccessKey = globalSecretAccessKey + + // Your example host config + exampleHostConf := new(hostConfig) + exampleHostConf.AccessKeyID = globalAccessKeyID + exampleHostConf.SecretAccessKey = globalSecretAccessKey + + conf.Hosts[exampleHostURL] = exampleHostConf + conf.Hosts["http*://s3*.amazonaws.com"] = s3HostConf + + aliases := make(map[string]string) + aliases["s3"] = "https://s3.amazonaws.com" + aliases["localhost"] = "http://localhost:9000" + conf.Aliases = aliases + config = quick.New(conf) + + return config +} diff --git a/hash-binary.go b/hash-binary.go index 0b1dd99a..a10d3838 100644 --- a/hash-binary.go +++ b/hash-binary.go @@ -1,3 +1,19 @@ +/* + * Minio Client (C) 2015 Minio, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package main import ( diff --git a/hostconfig.go b/hostconfig.go index 7d0f24cd..49ceef97 100644 --- a/hostconfig.go +++ b/hostconfig.go @@ -25,6 +25,11 @@ import ( "github.com/minio-io/minio/pkg/iodine" ) +type hostConfig struct { + AccessKeyID string + SecretAccessKey string +} + // getHostURL - func getHostURL(u *url.URL) string { return u.Scheme + "://" + u.Host