Skip to content

Commit

Permalink
FIx
Browse files Browse the repository at this point in the history
  • Loading branch information
remyleone committed Apr 21, 2020
1 parent d044ea8 commit 1a44c70
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Generate a S3 tool configuration file.

USAGE:
scw object config get [arg=value ...]

EXAMPLES:
Generate a s3cmd config file for Paris region
scw object config get region=fr-par type=s3cmd

Generate a rclone config file for default region
scw object config get type=rclone

Generate a mc (minio) config file for default region
scw object config get type=mc

ARGS:
type Type of S3 tool you want to generate a config for (rclone | s3cmd | mc)
[name=scaleway] Name of the s3 remote you want to generate
[region] Region to target. If none is passed will use default region from the config (fr-par | nl-ams)

FLAGS:
-h, --help help for get

GLOBAL FLAGS:
-D, --debug Enable debug mode
-o, --output string Output format: json or human
-p, --profile string The config profile to use

SEE ALSO:
# Install a S3 tool configuration file
scw object config install
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Install a S3 tool configuration file to its default location.

USAGE:
scw object config install [arg=value ...]

EXAMPLES:
Install a s3cmd config file for Paris region
scw object config install region=fr-par type=s3cmd

Install a rclone config file for default region
scw object config install type=rclone

Install a mc (minio) config file for default region
scw object config install type=mc

ARGS:
type Type of S3 tool you want to generate a config for (rclone | s3cmd | mc)
[name=scaleway] Name of the s3 remote you want to generate
[region] Region to target. If none is passed will use default region from the config (fr-par | nl-ams)

FLAGS:
-h, --help help for install

GLOBAL FLAGS:
-D, --debug Enable debug mode
-o, --output string Output format: json or human
-p, --profile string The config profile to use

SEE ALSO:
# Generate a S3 tool configuration file
scw object config get
18 changes: 18 additions & 0 deletions cmd/scw/testdata/test-all-usage-object-config-usage.stderr.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Configuration generation for S3 tools.

USAGE:
scw object config <command>

AVAILABLE COMMANDS:
get Generate a S3 tool configuration file
install Install a S3 tool configuration file to its default location

FLAGS:
-h, --help help for config

GLOBAL FLAGS:
-D, --debug Enable debug mode
-o, --output string Output format: json or human
-p, --profile string The config profile to use

Use "scw object config [command] --help" for more information about a command.
17 changes: 17 additions & 0 deletions cmd/scw/testdata/test-all-usage-object-usage.stderr.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Object-storage utils

USAGE:
scw object <command>

AVAILABLE COMMANDS:
config Manage configuration files for popular S3 tools

FLAGS:
-h, --help help for object

GLOBAL FLAGS:
-D, --debug Enable debug mode
-o, --output string Output format: json or human
-p, --profile string The config profile to use

Use "scw object [command] --help" for more information about a command.
8 changes: 4 additions & 4 deletions internal/namespaces/object/v1/custom_config_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ func configGetCommand() *core.Command {
Namespace: "object",
Resource: "config",
Verb: "get",
Short: "Generate a S3 related configuration file",
Long: "Generate a S3 related configuration file.",
Short: "Generate a S3 tool configuration file",
Long: "Generate a S3 tool configuration file.",
ArgsType: reflect.TypeOf(getArgs{}),
ArgSpecs: []*core.ArgSpec{
{
Name: "type",
Short: "Type of S3 tool you want to generate a config for",
Required: true,
EnumValues: supportedTools,
EnumValues: []string{rclone.String(), s3cmd.String(), mc.String()},
},
{
Name: "name",
Short: "Name of the s3 remote you want to generate",
Required: false,
Default: func() (value string, doc string) {
return "scaleway", "default value"
return "scaleway", "scaleway"
},
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
Expand Down
8 changes: 4 additions & 4 deletions internal/namespaces/object/v1/custom_config_install.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ func configInstallCommand() *core.Command {
Namespace: "object",
Resource: "config",
Verb: "install",
Short: "Install a S3 related configuration file to its default location",
Long: "Install a S3 related configuration file.",
Short: "Install a S3 tool configuration file to its default location",
Long: "Install a S3 tool configuration file to its default location.",
ArgsType: reflect.TypeOf(installArgs{}),
ArgSpecs: []*core.ArgSpec{
{
Name: "type",
Short: "Type of S3 tool you want to generate a config for",
Required: true,
EnumValues: supportedTools,
EnumValues: []string{rclone.String(), s3cmd.String(), mc.String()},
},
{
Name: "name",
Short: "Name of the s3 remote you want to generate",
Required: false,
Default: func() (value string, doc string) {
return "scaleway", "default value"
return "scaleway", "scaleway"
},
},
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms),
Expand Down
8 changes: 8 additions & 0 deletions internal/namespaces/object/v1/s3configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ import (

type s3tool string

func (c s3tool) String() string {
return string(c)
}

type s3config struct {
AccessKey string
SecretKey string
Expand Down Expand Up @@ -71,6 +75,10 @@ func newS3Config(ctx context.Context, region scw.Region, name string) (s3config,
if !secretExists {
return s3config{}, fmt.Errorf("no secret key found")
}
if region == "" {
defaultRegion, _ := client.GetDefaultRegion()
region = defaultRegion
}
config := s3config{
AccessKey: accessKey,
SecretKey: secretKey,
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"9","hosts":{"scaleway_fr-par":{"url":"https://s3.fr-par.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v2"}}}
{"version":"9","hosts":{"scaleway":{"url":"https://s3.fr-par.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v2"}}}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by scaleway-cli command
# Configuration file for rclone https://rclone.org/s3/#scaleway
# Default location: $HOME/.config/rclone/rclone.conf
[scaleway_fr-par]
[scaleway]
type = s3
env_auth = false
endpoint = s3.fr-par.scw.cloud
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"version":"9","hosts":{"scaleway_nl-ams":{"url":"https://s3.nl-ams.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v2"}}}
{"version":"9","hosts":{"scaleway":{"url":"https://s3.nl-ams.scw.cloud","accessKey":"SCWXXXXXXXXXXXXXXXXX","secretKey":"11111111-1111-1111-1111-111111111111","api":"S3v2"}}}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Generated by scaleway-cli command
# Configuration file for rclone https://rclone.org/s3/#scaleway
# Default location: $HOME/.config/rclone/rclone.conf
[scaleway_nl-ams]
[scaleway]
type = s3
env_auth = false
endpoint = s3.nl-ams.scw.cloud
Expand Down

0 comments on commit 1a44c70

Please sign in to comment.