[Bugfix] duplicating flag registration (#7853)

This commit is contained in:
mizuno-keyence 2019-07-04 06:31:19 +09:00 committed by kannappanr
parent c43f745449
commit 09103991ea
3 changed files with 34 additions and 3 deletions

View file

@ -48,7 +48,7 @@ var (
// RegisterGatewayCommand registers a new command for gateway.
func RegisterGatewayCommand(cmd cli.Command) error {
cmd.Flags = append(append(cmd.Flags, append(cmd.Flags, ServerFlags...)...), GlobalFlags...)
cmd.Flags = append(append(cmd.Flags, ServerFlags...), GlobalFlags...)
gatewayCmd.Subcommands = append(gatewayCmd.Subcommands, cmd)
return nil
}

View file

@ -17,6 +17,7 @@
package cmd
import (
"fmt"
"strings"
"testing"
@ -34,6 +35,36 @@ func TestRegisterGatewayCommand(t *testing.T) {
}
}
// Test running a registered gateway command with a flag
func TestRunRegisteredGatewayCommand(t *testing.T) {
var err error
flagName := "test-flag"
flagValue := "foo"
cmd := cli.Command{
Name: "test-run-with-flag",
Flags: []cli.Flag{
cli.StringFlag{Name: flagName},
},
Action: func(ctx *cli.Context) {
if actual := ctx.String(flagName); actual != flagValue {
t.Errorf("value of %s expects %s, but got %s", flagName, flagValue, actual)
}
},
}
err = RegisterGatewayCommand(cmd)
if err != nil {
t.Errorf("RegisterGatewayCommand got unexpected error: %s", err)
}
if err = newApp("minio").Run(
[]string{"minio", "gateway", cmd.Name, fmt.Sprintf("--%s", flagName), flagValue}); err != nil {
t.Errorf("running registered gateway command got unexpected error: %s", err)
}
}
// Test parseGatewayEndpoint
func TestParseGatewayEndpoint(t *testing.T) {
testCases := []struct {

View file

@ -19,7 +19,7 @@ MinIO GCS Gateway allows you to access Google Cloud Storage (GCS) with Amazon S3
**Note:** For alternate ways to set up *Application Default Credentials*, see [Setting Up Authentication for Server to Server Production Applications](https://developers.google.com/identity/protocols/application-default-credentials).
### 1.1 Run MinIO GCS Gateway Using Docker
### 1.2 Run MinIO GCS Gateway Using Docker
```sh
docker run -p 9000:9000 --name gcs-s3 \
-v /path/to/credentials.json:/credentials.json \
@ -29,7 +29,7 @@ docker run -p 9000:9000 --name gcs-s3 \
minio/minio gateway gcs yourprojectid
```
### 1.2 Run MinIO GCS Gateway Using the MinIO Binary
### 1.3 Run MinIO GCS Gateway Using the MinIO Binary
```sh
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json