diff --git a/options.go b/api-options.go similarity index 67% rename from options.go rename to api-options.go index 5b2ae20f..ae4120fe 100644 --- a/options.go +++ b/api-options.go @@ -19,30 +19,11 @@ package main import ( "log" "os" - "strings" "github.com/codegangsta/cli" "github.com/minio-io/mc/pkg/s3" ) -type MinioClient struct { - bucketName string - keyName string - body string - bucketAcls string - policy string - region string - query string // TODO -} - -var Options = []cli.Command{ - GetObject, - PutObject, - ListObjects, - ListBuckets, - Configure, -} - var GetObject = cli.Command{ Name: "get-object", Usage: "", @@ -78,33 +59,24 @@ var Configure = cli.Command{ Action: doConfigure, } -func parseInput(c *cli.Context) string { - var commandName string - switch len(c.Args()) { - case 1: - commandName = c.Args()[0] - default: - log.Fatal("command name must not be blank\n") - } - - var inputOptions []string - if c.String("bucket") != "" { - inputOptions = strings.Split(c.String("options"), ",") - } - - if inputOptions[0] == "" { - log.Fatal("options cannot be empty with a command name") - } - return commandName -} - func doGetObject(c *cli.Context) { var bucket, key string accessKey := os.Getenv("AWS_ACCESS_KEY_ID") - secretKey := os.Getenv("AWS_ACCESS_SECRET_KEY") - if accessKey == "" || secretKey == "" { - log.Fatal("no AWS_ACCESS_KEY_ID or AWS_ACCESS_KEY_SECRET set in environment") + secretKey := os.Getenv("AWS_SECRET_ACCESS_KEY") + if accessKey == "" && secretKey == "" { + errstr := `You can configure your credentials by running "mc configure"` + log.Fatal(errstr) } + if accessKey == "" { + errstr := `Partial credentials found in the env, missing : AWS_ACCESS_KEY_ID` + log.Fatal(errstr) + } + + if secretKey == "" { + errstr := `Partial credentials found in the env, missing : AWS_SECRET_ACCESS_KEY` + log.Fatal(errstr) + } + s3c := s3.NewS3Client(accessKey, secretKey) _, _, err := s3c.Get(bucket, key) if err != nil { diff --git a/common.go b/common.go new file mode 100644 index 00000000..442ead0b --- /dev/null +++ b/common.go @@ -0,0 +1,53 @@ +package main + +import ( + "log" + "strings" + + "github.com/codegangsta/cli" +) + +type MinioClient struct { + bucketName string + keyName string + body string + bucketAcls string + policy string + region string + query string // TODO +} + +var Options = []cli.Command{ + Cp, + Ls, + Mb, + Mv, + Rb, + Rm, + Sync, + GetObject, + PutObject, + ListObjects, + ListBuckets, + Configure, +} + +func parseInput(c *cli.Context) string { + var commandName string + switch len(c.Args()) { + case 1: + commandName = c.Args()[0] + default: + log.Fatal("command name must not be blank\n") + } + + var inputOptions []string + if c.String("bucket") != "" { + inputOptions = strings.Split(c.String("options"), ",") + } + + if inputOptions[0] == "" { + log.Fatal("options cannot be empty with a command name") + } + return commandName +} diff --git a/fs-options.go b/fs-options.go new file mode 100644 index 00000000..9a32c5c0 --- /dev/null +++ b/fs-options.go @@ -0,0 +1,92 @@ +/* + * Mini Object Storage, (C) 2014 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/codegangsta/cli" + // "github.com/minio-io/mc/pkg/s3" +) + +var Cp = cli.Command{ + Name: "cp", + Usage: "", + Description: "", + Action: doCopy, +} + +var Ls = cli.Command{ + Name: "ls", + Usage: "", + Description: "", + Action: doList, +} + +var Mb = cli.Command{ + Name: "mb", + Usage: "", + Description: "", + Action: doMakeBucket, +} + +var Mv = cli.Command{ + Name: "mv", + Usage: "", + Description: "", + Action: doMoveObject, +} + +var Rb = cli.Command{ + Name: "rb", + Usage: "", + Description: "", + Action: doRemoveBucket, +} + +var Rm = cli.Command{ + Name: "rm", + Usage: "", + Description: "", + Action: doRemoveObject, +} + +var Sync = cli.Command{ + Name: "sync", + Usage: "", + Description: "", + Action: doSync, +} + +func doCopy(c *cli.Context) { +} + +func doList(c *cli.Context) { +} + +func doMakeBucket(c *cli.Context) { +} + +func doMoveObject(c *cli.Context) { +} + +func doRemoveBucket(c *cli.Context) { +} + +func doRemoveObject(c *cli.Context) { +} + +func doSync(c *cli.Context) { +}