mirror of
https://github.com/minio/minio.git
synced 2025-05-23 02:21:51 -04:00
parent
ec2920e981
commit
3dfe254a11
@ -28,23 +28,22 @@ import (
|
|||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
var gatewayTemplate = `NAME:
|
const azureGatewayTemplate = `NAME:
|
||||||
{{.HelpName}} - {{.Usage}}
|
{{.HelpName}} - {{.Usage}}
|
||||||
|
|
||||||
USAGE:
|
USAGE:
|
||||||
{{.HelpName}} {{if .VisibleFlags}}[FLAGS]{{end}} BACKEND [ENDPOINT]
|
{{.HelpName}} {{if .VisibleFlags}}[FLAGS]{{end}} [ENDPOINT]
|
||||||
{{if .VisibleFlags}}
|
{{if .VisibleFlags}}
|
||||||
FLAGS:
|
FLAGS:
|
||||||
{{range .VisibleFlags}}{{.}}
|
{{range .VisibleFlags}}{{.}}
|
||||||
{{end}}{{end}}
|
{{end}}{{end}}
|
||||||
BACKEND:
|
ENDPOINT:
|
||||||
azure: Microsoft Azure Blob Storage. Default ENDPOINT is https://core.windows.net
|
Azure server endpoint. Default ENDPOINT is https://core.windows.net
|
||||||
s3: Amazon Simple Storage Service (S3). Default ENDPOINT is https://s3.amazonaws.com
|
|
||||||
|
|
||||||
ENVIRONMENT VARIABLES:
|
ENVIRONMENT VARIABLES:
|
||||||
ACCESS:
|
ACCESS:
|
||||||
MINIO_ACCESS_KEY: Username or access key of your storage backend.
|
MINIO_ACCESS_KEY: Username or access key of Azure storage.
|
||||||
MINIO_SECRET_KEY: Password or secret key of your storage backend.
|
MINIO_SECRET_KEY: Password or secret key of Azure storage.
|
||||||
|
|
||||||
BROWSER:
|
BROWSER:
|
||||||
MINIO_BROWSER: To disable web browser access, set this value to "off".
|
MINIO_BROWSER: To disable web browser access, set this value to "off".
|
||||||
@ -53,24 +52,18 @@ EXAMPLES:
|
|||||||
1. Start minio gateway server for Azure Blob Storage backend.
|
1. Start minio gateway server for Azure Blob Storage backend.
|
||||||
$ export MINIO_ACCESS_KEY=azureaccountname
|
$ export MINIO_ACCESS_KEY=azureaccountname
|
||||||
$ export MINIO_SECRET_KEY=azureaccountkey
|
$ export MINIO_SECRET_KEY=azureaccountkey
|
||||||
$ {{.HelpName}} azure
|
$ {{.HelpName}}
|
||||||
|
2. Start minio gateway server for Azure Blob Storage backend on custom endpoint.
|
||||||
2. Start minio gateway server for AWS S3 backend.
|
$ export MINIO_ACCESS_KEY=azureaccountname
|
||||||
$ export MINIO_ACCESS_KEY=accesskey
|
$ export MINIO_SECRET_KEY=azureaccountkey
|
||||||
$ export MINIO_SECRET_KEY=secretkey
|
$ {{.HelpName}} https://azure.example.com
|
||||||
$ {{.HelpName}} s3
|
|
||||||
|
|
||||||
3. Start minio gateway server for S3 backend on custom endpoint.
|
|
||||||
$ export MINIO_ACCESS_KEY=Q3AM3UQ867SPQQA43P2F
|
|
||||||
$ export MINIO_SECRET_KEY=zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG
|
|
||||||
$ {{.HelpName}} s3 https://play.minio.io:9000
|
|
||||||
`
|
`
|
||||||
|
|
||||||
var gatewayCmd = cli.Command{
|
var azureBackendCmd = cli.Command{
|
||||||
Name: "gateway",
|
Name: "azure",
|
||||||
Usage: "Start object storage gateway.",
|
Usage: "Microsoft Azure Blob Storage.",
|
||||||
Action: gatewayMain,
|
Action: azureGatewayMain,
|
||||||
CustomHelpTemplate: gatewayTemplate,
|
CustomHelpTemplate: azureGatewayTemplate,
|
||||||
Flags: append(serverFlags,
|
Flags: append(serverFlags,
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "quiet",
|
Name: "quiet",
|
||||||
@ -80,6 +73,59 @@ var gatewayCmd = cli.Command{
|
|||||||
HideHelpCommand: true,
|
HideHelpCommand: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const s3GatewayTemplate = `NAME:
|
||||||
|
{{.HelpName}} - {{.Usage}}
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
{{.HelpName}} {{if .VisibleFlags}}[FLAGS]{{end}} [ENDPOINT]
|
||||||
|
{{if .VisibleFlags}}
|
||||||
|
FLAGS:
|
||||||
|
{{range .VisibleFlags}}{{.}}
|
||||||
|
{{end}}{{end}}
|
||||||
|
ENDPOINT:
|
||||||
|
S3 server endpoint. Default ENDPOINT is https://s3.amazonaws.com
|
||||||
|
|
||||||
|
ENVIRONMENT VARIABLES:
|
||||||
|
ACCESS:
|
||||||
|
MINIO_ACCESS_KEY: Username or access key of S3 storage.
|
||||||
|
MINIO_SECRET_KEY: Password or secret key of S3 storage.
|
||||||
|
|
||||||
|
BROWSER:
|
||||||
|
MINIO_BROWSER: To disable web browser access, set this value to "off".
|
||||||
|
|
||||||
|
EXAMPLES:
|
||||||
|
1. Start minio gateway server for AWS S3 backend.
|
||||||
|
$ export MINIO_ACCESS_KEY=accesskey
|
||||||
|
$ export MINIO_SECRET_KEY=secretkey
|
||||||
|
$ {{.HelpName}}
|
||||||
|
|
||||||
|
2. Start minio gateway server for S3 backend on custom endpoint.
|
||||||
|
$ export MINIO_ACCESS_KEY=Q3AM3UQ867SPQQA43P2F
|
||||||
|
$ export MINIO_SECRET_KEY=zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG
|
||||||
|
$ {{.HelpName}} https://play.minio.io:9000
|
||||||
|
`
|
||||||
|
|
||||||
|
var s3BackendCmd = cli.Command{
|
||||||
|
Name: "s3",
|
||||||
|
Usage: "Amazon Simple Storage Service (S3).",
|
||||||
|
Action: s3GatewayMain,
|
||||||
|
CustomHelpTemplate: s3GatewayTemplate,
|
||||||
|
Flags: append(serverFlags,
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "quiet",
|
||||||
|
Usage: "Disable startup banner.",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
HideHelpCommand: true,
|
||||||
|
}
|
||||||
|
|
||||||
|
var gatewayCmd = cli.Command{
|
||||||
|
Name: "gateway",
|
||||||
|
Usage: "Start object storage gateway.",
|
||||||
|
HideHelpCommand: true,
|
||||||
|
Subcommands: []cli.Command{azureBackendCmd, s3BackendCmd},
|
||||||
|
}
|
||||||
|
|
||||||
// Represents the type of the gateway backend.
|
// Represents the type of the gateway backend.
|
||||||
type gatewayBackend string
|
type gatewayBackend string
|
||||||
|
|
||||||
@ -120,7 +166,7 @@ func mustSetBrowserSettingFromEnv() {
|
|||||||
//
|
//
|
||||||
// - Azure Blob Storage.
|
// - Azure Blob Storage.
|
||||||
// - Add your favorite backend here.
|
// - Add your favorite backend here.
|
||||||
func newGatewayLayer(backendType, endpoint, accessKey, secretKey string, secure bool) (GatewayLayer, error) {
|
func newGatewayLayer(backendType gatewayBackend, endpoint, accessKey, secretKey string, secure bool) (GatewayLayer, error) {
|
||||||
|
|
||||||
switch gatewayBackend(backendType) {
|
switch gatewayBackend(backendType) {
|
||||||
case azureBackend:
|
case azureBackend:
|
||||||
@ -212,12 +258,26 @@ func validateGatewayArguments(serverAddr, endpointAddr string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler for 'minio gateway'.
|
// Handler for 'minio gateway azure' command line.
|
||||||
func gatewayMain(ctx *cli.Context) {
|
func azureGatewayMain(ctx *cli.Context) {
|
||||||
if !ctx.Args().Present() || ctx.Args().First() == "help" {
|
if ctx.Args().Present() && ctx.Args().First() == "help" {
|
||||||
cli.ShowCommandHelpAndExit(ctx, "gateway", 1)
|
cli.ShowCommandHelpAndExit(ctx, "azure", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gatewayMain(ctx, azureBackend)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handler for 'minio gateway s3' command line.
|
||||||
|
func s3GatewayMain(ctx *cli.Context) {
|
||||||
|
if ctx.Args().Present() && ctx.Args().First() == "help" {
|
||||||
|
cli.ShowCommandHelpAndExit(ctx, "s3", 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
gatewayMain(ctx, s3Backend)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handler for 'minio gateway'.
|
||||||
|
func gatewayMain(ctx *cli.Context, backendType gatewayBackend) {
|
||||||
// Fetch access and secret key from env.
|
// Fetch access and secret key from env.
|
||||||
accessKey, secretKey := mustGetGatewayCredsFromEnv()
|
accessKey, secretKey := mustGetGatewayCredsFromEnv()
|
||||||
|
|
||||||
@ -234,13 +294,8 @@ func gatewayMain(ctx *cli.Context) {
|
|||||||
log.EnableQuiet()
|
log.EnableQuiet()
|
||||||
}
|
}
|
||||||
|
|
||||||
// First argument is selected backend type.
|
|
||||||
backendType := ctx.Args().Get(0)
|
|
||||||
// Second argument is the endpoint address (optional)
|
|
||||||
endpointAddr := ctx.Args().Get(1)
|
|
||||||
|
|
||||||
serverAddr := ctx.String("address")
|
serverAddr := ctx.String("address")
|
||||||
|
endpointAddr := ctx.Args().Get(0)
|
||||||
err := validateGatewayArguments(serverAddr, endpointAddr)
|
err := validateGatewayArguments(serverAddr, endpointAddr)
|
||||||
fatalIf(err, "Invalid argument")
|
fatalIf(err, "Invalid argument")
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Prints the formatted startup message.
|
// Prints the formatted startup message.
|
||||||
func printGatewayStartupMessage(apiEndPoints []string, accessKey, secretKey, backendType string) {
|
func printGatewayStartupMessage(apiEndPoints []string, accessKey, secretKey string, backendType gatewayBackend) {
|
||||||
// Prints credential.
|
// Prints credential.
|
||||||
printGatewayCommonMsg(apiEndPoints, accessKey, secretKey)
|
printGatewayCommonMsg(apiEndPoints, accessKey, secretKey)
|
||||||
|
|
||||||
|
@ -18,6 +18,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
@ -59,7 +60,7 @@ VERSION:
|
|||||||
` + Version +
|
` + Version +
|
||||||
`{{ "\n"}}`
|
`{{ "\n"}}`
|
||||||
|
|
||||||
func newApp() *cli.App {
|
func newApp(name string) *cli.App {
|
||||||
// Collection of minio commands currently supported are.
|
// Collection of minio commands currently supported are.
|
||||||
commands := []cli.Command{}
|
commands := []cli.Command{}
|
||||||
|
|
||||||
@ -108,7 +109,7 @@ func newApp() *cli.App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Name = "Minio"
|
app.Name = name
|
||||||
app.Author = "Minio.io"
|
app.Author = "Minio.io"
|
||||||
app.Version = Version
|
app.Version = Version
|
||||||
app.Usage = "Cloud Storage Server."
|
app.Usage = "Cloud Storage Server."
|
||||||
@ -137,7 +138,8 @@ func newApp() *cli.App {
|
|||||||
|
|
||||||
// Main main for minio server.
|
// Main main for minio server.
|
||||||
func Main(args []string) {
|
func Main(args []string) {
|
||||||
app := newApp()
|
name := filepath.Base(args[0])
|
||||||
|
app := newApp(name)
|
||||||
|
|
||||||
// Run the app - exit on error.
|
// Run the app - exit on error.
|
||||||
if err := app.Run(args); err != nil {
|
if err := app.Run(args); err != nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user