Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Read the [blog post](https://blog.scaleway.com/2015/05/20/manage-baremetal-serve
* [`top [OPTIONS] SERVER`](#scw-top)
* [`version [OPTIONS]`](#scw-version)
* [`wait [OPTIONS] SERVER [SERVER...]`](#scw-wait)
* [`s3 [OPTIONS]`](#scw-s3)
* [Examples](#examples)
5. [Changelog](#changelog)
6. [Development](#development)
Expand Down Expand Up @@ -213,6 +214,7 @@ Commands:
top Lookup the running processes of a server
version Show the version information
wait Block until a server stops
s3 Access to s3 bucket

Run 'scw COMMAND --help' for more information on a command.
```
Expand Down Expand Up @@ -883,6 +885,19 @@ Options:
```


#### `scw s3`

```console
Usage: scw s3 [OPTIONS]

Access to s3 bucket.

Options:

-h, --help=false Print usage
```


---

### Examples
Expand Down Expand Up @@ -1643,6 +1658,7 @@ For previous Node.js versions, see [scaleway-cli-node](https://github.com/moul/s
* Support of `top` command
* Support of `version` command
* Support of `wait` command
* Support of `s3` command

[gopkg.in/scaleway/scaleway-cli.v1](http://gopkg.in/scaleway/scaleway-cli.v1)

Expand All @@ -1667,7 +1683,7 @@ Feel free to contribute :smiley::beers:
* `export PATH=$PATH:$GOPATH/bin`
3. Fetch the project: `go get -d github.com/scaleway/scaleway-cli/...`
4. Go to scaleway-cli directory: `cd $GOPATH/src/github.com/scaleway/scaleway-cli`
5. Hack: `emacs`
5. Hack: `vim`
6. Build: `make`
7. Run: `./scw`

Expand Down
4 changes: 3 additions & 1 deletion pkg/cli/cmd_rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

package cli

import "github.com/scaleway/scaleway-cli/pkg/commands"
import (
"github.com/scaleway/scaleway-cli/pkg/commands"
)

var cmdRm = &Command{
Exec: runRm,
Expand Down
33 changes: 33 additions & 0 deletions pkg/cli/cmd_s3.go
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)
}
1 change: 1 addition & 0 deletions pkg/cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ var Commands = []*Command{
cmdSecurityGroups,
cmdIPS,
cmdCS,
cmdS3,
}
2 changes: 2 additions & 0 deletions pkg/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ func Start(rawArgs []string, streams *commands.Streams) (int, error) {
}
flag.CommandLine.Parse(rawArgs)

config.MigrateConfig()

config, cfgErr := config.GetConfig()
if cfgErr != nil && !os.IsNotExist(cfgErr) {
return 1, fmt.Errorf("unable to open .scwrc config file: %v", cfgErr)
Expand Down
18 changes: 18 additions & 0 deletions pkg/commands/s3.go
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

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)

type S3Args struct{}

// Version is the handler for 'scw version'

Choose a reason for hiding this comment

The 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
}
44 changes: 43 additions & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"runtime"

"github.com/scaleway/scaleway-cli/pkg/scwversion"
"github.com/sirupsen/logrus"
)

// Config is a Scaleway CLI configuration file
Expand All @@ -29,6 +30,47 @@ type Config struct {
Version string `json:"version"`
}

// migrate config from home to ~/.scw/

Choose a reason for hiding this comment

The 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()
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions vendor/github.com/minio/mc/CONFLICT.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions vendor/github.com/minio/mc/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions vendor/github.com/minio/mc/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions vendor/github.com/minio/mc/Dockerfile.release

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading