diff --git a/cmd/gateway/README.md b/cmd/gateway/README.md new file mode 100644 index 000000000..b50d6d42f --- /dev/null +++ b/cmd/gateway/README.md @@ -0,0 +1,18 @@ +# Gateway + +Documentation for developing and building the gateway service + +Usage: + +First make an identity: +``` +go install storj.io/storj/cmd/gateway +gateway setup +``` + +The gateway shares the uplink config file. +You can edit `~/.storj/uplink/config.yaml` to your liking. Then run it! + +``` +gateway run +``` diff --git a/cmd/gateway/main.go b/cmd/gateway/main.go new file mode 100644 index 000000000..a9ac9c287 --- /dev/null +++ b/cmd/gateway/main.go @@ -0,0 +1,13 @@ +// Copyright (C) 2018 Storj Labs, Inc. +// See LICENSE for copying information. + +package main + +import ( + "storj.io/storj/cmd/uplink/cmd" + "storj.io/storj/pkg/process" +) + +func main() { + process.Exec(cmd.GWCmd) +} diff --git a/cmd/uplink/cmd/cat.go b/cmd/uplink/cmd/cat.go index 1e94ce26a..c6704d7bd 100644 --- a/cmd/uplink/cmd/cat.go +++ b/cmd/uplink/cmd/cat.go @@ -17,7 +17,7 @@ func init() { Use: "cat", Short: "Copies a Storj object to standard out", RunE: catMain, - }) + }, CLICmd) } // catMain is the function executed when catCmd is called diff --git a/cmd/uplink/cmd/cp.go b/cmd/uplink/cmd/cp.go index a45e7f3d0..0fc3b1fae 100644 --- a/cmd/uplink/cmd/cp.go +++ b/cmd/uplink/cmd/cp.go @@ -31,7 +31,7 @@ func init() { Use: "cp", Short: "Copies a local file or Storj object to another location locally or in Storj", RunE: copyMain, - }) + }, CLICmd) progress = cpCmd.Flags().Bool("progress", true, "if true, show progress") } diff --git a/cmd/uplink/cmd/ls.go b/cmd/uplink/cmd/ls.go index 44e0874d1..9433360da 100644 --- a/cmd/uplink/cmd/ls.go +++ b/cmd/uplink/cmd/ls.go @@ -25,7 +25,7 @@ func init() { Use: "ls", Short: "List objects and prefixes or all buckets", RunE: list, - }) + }, CLICmd) recursiveFlag = lsCmd.Flags().Bool("recursive", false, "if true, list recursively") } diff --git a/cmd/uplink/cmd/mb.go b/cmd/uplink/cmd/mb.go index 4ce2bebd7..96bba33d6 100644 --- a/cmd/uplink/cmd/mb.go +++ b/cmd/uplink/cmd/mb.go @@ -18,7 +18,7 @@ func init() { Use: "mb", Short: "Create a new bucket", RunE: makeBucket, - }) + }, CLICmd) } func makeBucket(cmd *cobra.Command, args []string) error { diff --git a/cmd/uplink/cmd/put.go b/cmd/uplink/cmd/put.go index 211325b6a..5e9dfb5cc 100644 --- a/cmd/uplink/cmd/put.go +++ b/cmd/uplink/cmd/put.go @@ -17,7 +17,7 @@ func init() { Use: "put", Short: "Copies data from standard in to a Storj object", RunE: putMain, - }) + }, CLICmd) } // putMain is the function executed when putCmd is called diff --git a/cmd/uplink/cmd/rb.go b/cmd/uplink/cmd/rb.go index 638990ee8..971e3a762 100644 --- a/cmd/uplink/cmd/rb.go +++ b/cmd/uplink/cmd/rb.go @@ -19,7 +19,7 @@ func init() { Use: "rb", Short: "Remove an empty bucket", RunE: deleteBucket, - }) + }, CLICmd) } func deleteBucket(cmd *cobra.Command, args []string) error { diff --git a/cmd/uplink/cmd/rm.go b/cmd/uplink/cmd/rm.go index f0a499814..5c75f8c4c 100644 --- a/cmd/uplink/cmd/rm.go +++ b/cmd/uplink/cmd/rm.go @@ -17,7 +17,7 @@ func init() { Use: "rm", Short: "Delete an object", RunE: delete, - }) + }, CLICmd) } func delete(cmd *cobra.Command, args []string) error { diff --git a/cmd/uplink/cmd/root.go b/cmd/uplink/cmd/root.go index 40c2d4a39..79f6d67d7 100644 --- a/cmd/uplink/cmd/root.go +++ b/cmd/uplink/cmd/root.go @@ -23,14 +23,20 @@ type Config struct { var cfg Config -// RootCmd represents the base command when called without any subcommands -var RootCmd = &cobra.Command{ +// CLICmd represents the base CLI command when called without any subcommands +var CLICmd = &cobra.Command{ Use: "uplink", - Short: "The Storj client-side S3 gateway and CLI", + Short: "The Storj client-side CLI", } -func addCmd(cmd *cobra.Command) *cobra.Command { - RootCmd.AddCommand(cmd) +// GWCmd represents the base gateway command when called without any subcommands +var GWCmd = &cobra.Command{ + Use: "gateway", + Short: "The Storj client-side S3 gateway", +} + +func addCmd(cmd *cobra.Command, root *cobra.Command) *cobra.Command { + root.AddCommand(cmd) cfgstruct.Bind(cmd.Flags(), &cfg, cfgstruct.ConfDir(defaultConfDir)) cmd.Flags().String("config", filepath.Join(defaultConfDir, "config.yaml"), "path to configuration") return cmd diff --git a/cmd/uplink/cmd/run.go b/cmd/uplink/cmd/run.go index 1de26d619..da059a5de 100644 --- a/cmd/uplink/cmd/run.go +++ b/cmd/uplink/cmd/run.go @@ -17,7 +17,7 @@ var ( Use: "run", Short: "Run the S3 gateway", RunE: cmdRun, - }) + }, GWCmd) ) func cmdRun(cmd *cobra.Command, args []string) (err error) { diff --git a/cmd/uplink/cmd/setup.go b/cmd/uplink/cmd/setup.go index fa754ee73..99227ef66 100644 --- a/cmd/uplink/cmd/setup.go +++ b/cmd/uplink/cmd/setup.go @@ -36,7 +36,8 @@ var ( ) func init() { - RootCmd.AddCommand(setupCmd) + CLICmd.AddCommand(setupCmd) + GWCmd.AddCommand(setupCmd) cfgstruct.Bind(setupCmd.Flags(), &setupCfg, cfgstruct.ConfDir(defaultConfDir)) } diff --git a/cmd/uplink/main.go b/cmd/uplink/main.go index b5948d310..f43b48056 100644 --- a/cmd/uplink/main.go +++ b/cmd/uplink/main.go @@ -9,5 +9,5 @@ import ( ) func main() { - process.Exec(cmd.RootCmd) + process.Exec(cmd.CLICmd) }