split gateway from uplink

Change-Id: I7504a630cb85539750e32780c1c2347742a9c9c4
Reviewed-on: https://review.gerrithub.io/430644
Reviewed-by: Kaloyan Raev <kaloyan@storj.io>
Tested-by: Kaloyan Raev <kaloyan@storj.io>
This commit is contained in:
JT Olio 2018-10-24 17:14:38 -06:00
parent 99640225fd
commit cd51787827
13 changed files with 53 additions and 15 deletions

18
cmd/gateway/README.md Normal file
View File

@ -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
```

13
cmd/gateway/main.go Normal file
View File

@ -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)
}

View File

@ -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

View File

@ -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")
}

View File

@ -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")
}

View File

@ -18,7 +18,7 @@ func init() {
Use: "mb",
Short: "Create a new bucket",
RunE: makeBucket,
})
}, CLICmd)
}
func makeBucket(cmd *cobra.Command, args []string) error {

View File

@ -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

View File

@ -19,7 +19,7 @@ func init() {
Use: "rb",
Short: "Remove an empty bucket",
RunE: deleteBucket,
})
}, CLICmd)
}
func deleteBucket(cmd *cobra.Command, args []string) error {

View File

@ -17,7 +17,7 @@ func init() {
Use: "rm",
Short: "Delete an object",
RunE: delete,
})
}, CLICmd)
}
func delete(cmd *cobra.Command, args []string) error {

View File

@ -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

View File

@ -17,7 +17,7 @@ var (
Use: "run",
Short: "Run the S3 gateway",
RunE: cmdRun,
})
}, GWCmd)
)
func cmdRun(cmd *cobra.Command, args []string) (err error) {

View File

@ -36,7 +36,8 @@ var (
)
func init() {
RootCmd.AddCommand(setupCmd)
CLICmd.AddCommand(setupCmd)
GWCmd.AddCommand(setupCmd)
cfgstruct.Bind(setupCmd.Flags(), &setupCfg, cfgstruct.ConfDir(defaultConfDir))
}

View File

@ -9,5 +9,5 @@ import (
)
func main() {
process.Exec(cmd.RootCmd)
process.Exec(cmd.CLICmd)
}