-
Notifications
You must be signed in to change notification settings - Fork 156
WIP: S3 integration #520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: S3 integration #520
Changes from all commits
5be1b43
f01377c
2541508
0039860
bd4b121
2b3a953
4da7136
b3eec99
f7e0dc3
f128c3d
6eae32c
0acc2f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| // Copyright (C) 2015 Scaleway. All rights reserved. | ||
| // Use of this source code is governed by a MIT-style | ||
| // license that can be found in the LICENSE.md file. | ||
|
|
||
| package cli | ||
|
|
||
| import ( | ||
| "github.com/scaleway/scaleway-cli/pkg/commands" | ||
| ) | ||
|
|
||
| var cmdS3 = &Command{ | ||
| Exec: runS3, | ||
| UsageLine: "s3 [OPTIONS]", | ||
| Description: "Access to s3 bucket", | ||
| Help: "Access to s3 bucket.", | ||
| } | ||
|
|
||
| func init() { | ||
| cmdS3.Flag.BoolVar(&s3Help, []string{"h", "-help"}, false, "Print usage") | ||
| } | ||
|
|
||
| // Flags | ||
| var s3Help bool // -h, --help flag | ||
|
|
||
| func runS3(cmd *Command, rawArgs []string) error { | ||
| if s3Help { | ||
| return cmd.PrintUsage() | ||
| } | ||
|
|
||
| args := commands.S3Args{} | ||
| ctx := cmd.GetContext(rawArgs) | ||
| return commands.S3(ctx, args) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,4 +50,5 @@ var Commands = []*Command{ | |
| cmdSecurityGroups, | ||
| cmdIPS, | ||
| cmdCS, | ||
| cmdS3, | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // Copyright (C) 2015 Scaleway. All rights reserved. | ||
| // Use of this source code is governed by a MIT-style | ||
| // license that can be found in the LICENSE.md file. | ||
|
|
||
| package commands | ||
|
|
||
| import ( | ||
| minio "github.com/minio/mc/cmd" | ||
| ) | ||
|
|
||
| // VersionArgs are flags for the `RunVersion` function | ||
| type S3Args struct{} | ||
|
|
||
| // Version is the handler for 'scw version' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment on exported function S3 should be of the form "S3 ..." |
||
| func S3(ctx CommandContext, args S3Args) error { | ||
| minio.Main() | ||
| return nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ import ( | |
| "runtime" | ||
|
|
||
| "github.com/scaleway/scaleway-cli/pkg/scwversion" | ||
| "github.com/sirupsen/logrus" | ||
| ) | ||
|
|
||
| // Config is a Scaleway CLI configuration file | ||
|
|
@@ -29,6 +30,47 @@ type Config struct { | |
| Version string `json:"version"` | ||
| } | ||
|
|
||
| // migrate config from home to ~/.scw/ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment on exported function MigrateConfig should be of the form "MigrateConfig ..." |
||
| func MigrateConfig() { | ||
| // Get old config Path | ||
| oldConfigPath, err := GetHomeDir() | ||
| if err != nil { | ||
| fmt.Errorf("%s", err) | ||
| } | ||
| // Create scw folder | ||
| err = os.Mkdir(oldConfigPath+"/.scw", os.ModePerm) | ||
| if err != nil { | ||
| fmt.Errorf("Unable to make directory: %s", err) | ||
| } | ||
|
|
||
| oldConfigPath = filepath.Join(oldConfigPath, ".scwrc") | ||
|
|
||
| // Get new config Path | ||
| newConfigPath, err := GetConfigFilePath() | ||
| if err != nil { | ||
| fmt.Errorf("Unable to get scwrc config file path: %s", err) | ||
| } | ||
|
|
||
| // Check if file exist | ||
| _, err = os.Stat(oldConfigPath) | ||
| if err != nil { | ||
| if os.IsNotExist(err) { | ||
| return | ||
| } | ||
| fmt.Errorf("%s", err) | ||
| return | ||
| } | ||
|
|
||
| // mv file to new Path | ||
| err = os.Rename(oldConfigPath, newConfigPath) | ||
| if err != nil { | ||
| fmt.Errorf("%s", err) | ||
| } | ||
| logrus.Info(oldConfigPath, " moved to ", newConfigPath) | ||
|
|
||
| return | ||
| } | ||
|
|
||
| // Save write the config file | ||
| func (c *Config) Save() error { | ||
| scwrcPath, err := GetConfigFilePath() | ||
|
|
@@ -87,7 +129,7 @@ func GetConfigFilePath() (string, error) { | |
| if err != nil { | ||
| return "", err | ||
| } | ||
| return filepath.Join(path, ".scwrc"), nil | ||
| return filepath.Join(path, ".scw/scwrc"), nil | ||
| } | ||
|
|
||
| // GetHomeDir returns the path to your home | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment on exported type S3Args should be of the form "S3Args ..." (with optional leading article)