mirror of
https://github.com/minio/mc.git
synced 2025-11-13 12:22:45 +03:00
Probe moves closer to mc, also brings in changes by avoiding it behave like an error interface{}
This commit is contained in:
5
Godeps/Godeps.json
generated
5
Godeps/Godeps.json
generated
@@ -32,11 +32,6 @@
|
|||||||
"Comment": "v0.2.0-21-gd9184e5",
|
"Comment": "v0.2.0-21-gd9184e5",
|
||||||
"Rev": "d9184e5834efb7cd4a24df4d6ebab9b51dad4d9c"
|
"Rev": "d9184e5834efb7cd4a24df4d6ebab9b51dad4d9c"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"ImportPath": "github.com/minio/minio/pkg/probe",
|
|
||||||
"Comment": "release-1434511043-300-g28d9565",
|
|
||||||
"Rev": "28d9565400d68ae1cd79b81075823f10775e6230"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/minio/pb",
|
"ImportPath": "github.com/minio/pb",
|
||||||
"Rev": "e3e099c334cd89a6fe993f0683eaafd85604290f"
|
"Rev": "e3e099c334cd89a6fe993f0683eaafd85604290f"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/client"
|
"github.com/minio/mc/pkg/client"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Help message.
|
// Help message.
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/minio/mc/pkg/client"
|
"github.com/minio/mc/pkg/client"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// validAliasURL: use net/url.Parse to validate
|
// validAliasURL: use net/url.Parse to validate
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Help message.
|
// Help message.
|
||||||
|
|||||||
11
cat_test.go
11
cat_test.go
@@ -23,6 +23,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
|
"github.com/minio/mc/pkg/probe"
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -36,10 +37,12 @@ func (s *CmdTestSuite) TestCatCmd(c *C) {
|
|||||||
objectPathServer := server.URL + "/bucket/object1"
|
objectPathServer := server.URL + "/bucket/object1"
|
||||||
data := "hello"
|
data := "hello"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
err = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
|
||||||
c.Assert(err, IsNil)
|
var perr *probe.Error
|
||||||
err = putTarget(objectPathServer, int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
perr = putTarget(objectPathServer, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
var sourceURLs []string
|
var sourceURLs []string
|
||||||
sourceURLs = append(sourceURLs, objectPath)
|
sourceURLs = append(sourceURLs, objectPath)
|
||||||
|
|||||||
52
cmd_test.go
52
cmd_test.go
@@ -58,32 +58,32 @@ func (s *CmdTestSuite) SetUpSuite(c *C) {
|
|||||||
}
|
}
|
||||||
setMcConfigDir(customConfigDir)
|
setMcConfigDir(customConfigDir)
|
||||||
|
|
||||||
err = createMcConfigDir()
|
perr := createMcConfigDir()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
config, err := newConfig()
|
config, perr := newConfig()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
err = writeConfig(config)
|
perr = writeConfig(config)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
err = createSessionDir()
|
perr = createSessionDir()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
_, err = doConfig("invalid", nil)
|
_, perr = doConfig("invalid", nil)
|
||||||
c.Assert(err, Not(IsNil))
|
c.Assert(perr, Not(IsNil))
|
||||||
|
|
||||||
_, err = doConfig("alias", []string{"test", "https://test.io"})
|
_, perr = doConfig("alias", []string{"test", "https://test.io"})
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
_, err = doConfig("alias", []string{"test", "https://test.io"})
|
_, perr = doConfig("alias", []string{"test", "https://test.io"})
|
||||||
c.Assert(err, Not(IsNil))
|
c.Assert(perr, Not(IsNil))
|
||||||
|
|
||||||
_, err = doConfig("alias", []string{"test", "htt://test.io"})
|
_, perr = doConfig("alias", []string{"test", "htt://test.io"})
|
||||||
c.Assert(err, Not(IsNil))
|
c.Assert(perr, Not(IsNil))
|
||||||
|
|
||||||
_, err = doConfig("alias", []string{"readonly", "https://new.test.io"})
|
_, perr = doConfig("alias", []string{"readonly", "https://new.test.io"})
|
||||||
c.Assert(err, Not(IsNil))
|
c.Assert(perr, Not(IsNil))
|
||||||
|
|
||||||
app = registerApp()
|
app = registerApp()
|
||||||
objectAPI := objectAPIHandler(objectAPIHandler{lock: &sync.Mutex{}, bucket: "bucket", object: make(map[string][]byte)})
|
objectAPI := objectAPIHandler(objectAPIHandler{lock: &sync.Mutex{}, bucket: "bucket", object: make(map[string][]byte)})
|
||||||
@@ -116,17 +116,17 @@ func (s *CmdTestSuite) TestNewConfigV1(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
conf, err := newConfig()
|
conf, perr := newConfig()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
configFile := filepath.Join(root, "config.json")
|
configFile := filepath.Join(root, "config.json")
|
||||||
err = conf.Save(configFile)
|
perr = conf.Save(configFile)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
confNew := newConfigV101()
|
confNew := newConfigV101()
|
||||||
config, err := quick.New(confNew)
|
config, perr := quick.New(confNew)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
err = config.Load(configFile)
|
perr = config.Load(configFile)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
data := config.Data().(*configV1)
|
data := config.Data().(*configV1)
|
||||||
|
|
||||||
type aliases struct {
|
type aliases struct {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
"github.com/minio/mc/pkg/client"
|
"github.com/minio/mc/pkg/client"
|
||||||
"github.com/minio/mc/pkg/client/fs"
|
"github.com/minio/mc/pkg/client/fs"
|
||||||
"github.com/minio/mc/pkg/client/s3"
|
"github.com/minio/mc/pkg/client/s3"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Check if the target URL represents folder. It may or may not exist yet.
|
// Check if the target URL represents folder. It may or may not exist yet.
|
||||||
|
|||||||
@@ -40,42 +40,42 @@ func (s *CmdTestSuite) TestCommonMethods(c *C) {
|
|||||||
objectPathServer := server.URL + "/bucket/object1"
|
objectPathServer := server.URL + "/bucket/object1"
|
||||||
data := "hello"
|
data := "hello"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
err = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
perr := putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
err = putTarget(objectPathServer, int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = putTarget(objectPathServer, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
c.Assert(isTargetURLDir(objectPathServer), Equals, false)
|
c.Assert(isTargetURLDir(objectPathServer), Equals, false)
|
||||||
c.Assert(isTargetURLDir(server.URL+"/bucket"), Equals, true)
|
c.Assert(isTargetURLDir(server.URL+"/bucket"), Equals, true)
|
||||||
|
|
||||||
reader, size, err := getSource(objectPathServer)
|
reader, size, perr := getSource(objectPathServer)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
c.Assert(size, Not(Equals), 0)
|
c.Assert(size, Not(Equals), 0)
|
||||||
var results bytes.Buffer
|
var results bytes.Buffer
|
||||||
_, err = io.CopyN(&results, reader, int64(size))
|
_, err = io.CopyN(&results, reader, int64(size))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Assert([]byte(data), DeepEquals, results.Bytes())
|
c.Assert([]byte(data), DeepEquals, results.Bytes())
|
||||||
|
|
||||||
_, content, err := url2Stat(objectPathServer)
|
_, content, perr := url2Stat(objectPathServer)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
c.Assert(content.Name, Equals, "object1")
|
c.Assert(content.Name, Equals, "object1")
|
||||||
c.Assert(content.Type.IsRegular(), Equals, true)
|
c.Assert(content.Type.IsRegular(), Equals, true)
|
||||||
|
|
||||||
_, _, err = getSource(objectPathServer + "invalid")
|
_, _, perr = getSource(objectPathServer + "invalid")
|
||||||
c.Assert(err, Not(IsNil))
|
c.Assert(perr, Not(IsNil))
|
||||||
|
|
||||||
_, _, err = url2Stat(objectPath + "invalid")
|
_, _, perr = url2Stat(objectPath + "invalid")
|
||||||
c.Assert(err, Not(IsNil))
|
c.Assert(perr, Not(IsNil))
|
||||||
|
|
||||||
_, err = source2Client(objectPathServer)
|
_, perr = source2Client(objectPathServer)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
_, err = target2Client(objectPathServer)
|
_, perr = target2Client(objectPathServer)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
_, err = source2Client("http://test.minio.io" + "/bucket/fail")
|
_, perr = source2Client("http://test.minio.io" + "/bucket/fail")
|
||||||
c.Assert(err, Not(IsNil))
|
c.Assert(perr, Not(IsNil))
|
||||||
|
|
||||||
_, err = target2Client("http://test.minio.io" + "/bucket/fail")
|
_, perr = target2Client("http://test.minio.io" + "/bucket/fail")
|
||||||
c.Assert(err, Not(IsNil))
|
c.Assert(perr, Not(IsNil))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import (
|
|||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/minio/mc/pkg/quick"
|
"github.com/minio/mc/pkg/quick"
|
||||||
"github.com/minio/minio/pkg/probe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Configure minio client
|
// Configure minio client
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/minio/mc/pkg/quick"
|
"github.com/minio/mc/pkg/quick"
|
||||||
"github.com/minio/minio/pkg/probe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type configV1 struct {
|
type configV1 struct {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Help message.
|
// Help message.
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/client"
|
"github.com/minio/mc/pkg/client"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type copyURLs struct {
|
type copyURLs struct {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Help message.
|
// Help message.
|
||||||
|
|||||||
4
diff.go
4
diff.go
@@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
"github.com/minio/mc/pkg/client"
|
"github.com/minio/mc/pkg/client"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/tchap/go-patricia/patricia"
|
"github.com/tchap/go-patricia/patricia"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ type diffV1 struct {
|
|||||||
|
|
||||||
type diff struct {
|
type diff struct {
|
||||||
message string
|
message string
|
||||||
err error
|
err *probe.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
func mustURLJoinPath(url1, url2 string) string {
|
func mustURLJoinPath(url1, url2 string) string {
|
||||||
|
|||||||
18
diff_test.go
18
diff_test.go
@@ -24,6 +24,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
|
"github.com/minio/mc/pkg/probe"
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -40,14 +41,14 @@ func (s *CmdTestSuite) TestDiffObjects(c *C) {
|
|||||||
objectPath1 := filepath.Join(root1, "object1")
|
objectPath1 := filepath.Join(root1, "object1")
|
||||||
data := "hello"
|
data := "hello"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
err = putTarget(objectPath1, int64(dataLen), bytes.NewReader([]byte(data)))
|
perr := putTarget(objectPath1, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
objectPath2 := filepath.Join(root2, "object1")
|
objectPath2 := filepath.Join(root2, "object1")
|
||||||
data = "hello"
|
data = "hello"
|
||||||
dataLen = len(data)
|
dataLen = len(data)
|
||||||
err = putTarget(objectPath2, int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = putTarget(objectPath2, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
for diff := range doDiffCmd(objectPath1, objectPath2, false) {
|
for diff := range doDiffCmd(objectPath1, objectPath2, false) {
|
||||||
c.Assert(diff.err, IsNil)
|
c.Assert(diff.err, IsNil)
|
||||||
@@ -65,20 +66,21 @@ func (s *CmdTestSuite) TestDiffDirs(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
defer os.RemoveAll(root2)
|
defer os.RemoveAll(root2)
|
||||||
|
|
||||||
|
var perr *probe.Error
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
objectPath := filepath.Join(root1, "object"+strconv.Itoa(i))
|
objectPath := filepath.Join(root1, "object"+strconv.Itoa(i))
|
||||||
data := "hello"
|
data := "hello"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
err = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
objectPath := filepath.Join(root2, "object"+strconv.Itoa(i))
|
objectPath := filepath.Join(root2, "object"+strconv.Itoa(i))
|
||||||
data := "hello"
|
data := "hello"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
err = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
for diff := range doDiffCmd(root1, root2, false) {
|
for diff := range doDiffCmd(root1, root2, false) {
|
||||||
|
|||||||
36
error.go
36
error.go
@@ -18,44 +18,28 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Fatal wrapper function which takes error and selectively prints stack frames if available on debug
|
// Fatal wrapper function which takes error and selectively prints stack frames if available on debug
|
||||||
func Fatal(err error) {
|
func Fatal(err *probe.Error) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch e := err.(type) {
|
if !globalDebugFlag {
|
||||||
case *probe.Error:
|
console.Fatalln(err.ToError())
|
||||||
if e == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !globalDebugFlag {
|
|
||||||
console.Fatalln(e.ToError())
|
|
||||||
}
|
|
||||||
console.Fatalln(err)
|
|
||||||
default:
|
|
||||||
console.Fatalln(err)
|
|
||||||
}
|
}
|
||||||
|
console.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error synonymous with Fatal but doesn't exit on error != nil
|
// Error synonymous with Fatal but doesn't exit on error != nil
|
||||||
func Error(err error) {
|
func Error(err *probe.Error) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch e := err.(type) {
|
if !globalDebugFlag {
|
||||||
case *probe.Error:
|
console.Errorln(err.ToError())
|
||||||
if e == nil {
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
if !globalDebugFlag {
|
|
||||||
console.Errorln(e.ToError())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
console.Errorln(err)
|
|
||||||
default:
|
|
||||||
console.Errorln(err)
|
|
||||||
}
|
}
|
||||||
|
console.Errorln(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/minio/mc/pkg/client"
|
"github.com/minio/mc/pkg/client"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type hostConfig struct {
|
type hostConfig struct {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Help message.
|
// Help message.
|
||||||
|
|||||||
2
ls.go
2
ls.go
@@ -25,7 +25,7 @@ import (
|
|||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/minio/mc/pkg/client"
|
"github.com/minio/mc/pkg/client"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
/// ls - related internal functions
|
/// ls - related internal functions
|
||||||
|
|||||||
27
ls_test.go
27
ls_test.go
@@ -24,6 +24,7 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
|
"github.com/minio/mc/pkg/probe"
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -33,32 +34,34 @@ func (s *CmdTestSuite) TestLSCmd(c *C) {
|
|||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
|
var perr *probe.Error
|
||||||
|
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
objectPath := filepath.Join(root, "object"+strconv.Itoa(i))
|
objectPath := filepath.Join(root, "object"+strconv.Itoa(i))
|
||||||
data := "hello"
|
data := "hello"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
err = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = doListCmd(root, false)
|
perr = doListCmd(root, false)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
err = doListCmd(root, true)
|
perr = doListCmd(root, true)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
objectPath := server.URL + "/bucket/object" + strconv.Itoa(i)
|
objectPath := server.URL + "/bucket/object" + strconv.Itoa(i)
|
||||||
data := "hello"
|
data := "hello"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
err := putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
perr := putTarget(objectPath, int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
}
|
}
|
||||||
err = doListCmd(server.URL+"/bucket", false)
|
perr = doListCmd(server.URL+"/bucket", false)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
err = doListCmd(server.URL+"/bucket", true)
|
perr = doListCmd(server.URL+"/bucket", true)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CmdTestSuite) TestLSContext(c *C) {
|
func (s *CmdTestSuite) TestLSContext(c *C) {
|
||||||
|
|||||||
13
main.go
13
main.go
@@ -84,16 +84,13 @@ func registerBefore(ctx *cli.Context) error {
|
|||||||
if globalDebugFlag {
|
if globalDebugFlag {
|
||||||
console.NoDebugPrint = false
|
console.NoDebugPrint = false
|
||||||
}
|
}
|
||||||
switch {
|
if console.IsValidTheme(themeName) != true {
|
||||||
case console.IsValidTheme(themeName) != true:
|
|
||||||
console.Errorf("Invalid theme, please choose from the following list: %s.\n", console.GetThemeNames())
|
console.Errorf("Invalid theme, please choose from the following list: %s.\n", console.GetThemeNames())
|
||||||
return errInvalidTheme{Theme: themeName}
|
return errInvalidTheme{Theme: themeName}
|
||||||
default:
|
}
|
||||||
err := console.SetTheme(themeName)
|
if err := console.SetTheme(themeName); err != nil {
|
||||||
if err != nil {
|
console.Errorf("Failed to set theme ‘%s’.", themeName)
|
||||||
console.Errorf("Failed to set theme ‘%s’.", themeName)
|
Error(err)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Migrate any old version of config / state files to newer format.
|
// Migrate any old version of config / state files to newer format.
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Help message.
|
// Help message.
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Help message.
|
// Help message.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/client"
|
"github.com/minio/mc/pkg/client"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/tchap/go-patricia/patricia"
|
"github.com/tchap/go-patricia/patricia"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client - client interface
|
// Client - client interface
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"github.com/minio/mc/pkg/client"
|
"github.com/minio/mc/pkg/client"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type fsClient struct {
|
type fsClient struct {
|
||||||
|
|||||||
@@ -40,30 +40,34 @@ func (s *MySuite) TestList(c *C) {
|
|||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
objectPath := filepath.Join(root, "object1")
|
objectPath := filepath.Join(root, "object1")
|
||||||
fsc, err := New(objectPath)
|
fsc, perr := New(objectPath)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
data := "hello"
|
data := "hello"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
|
|
||||||
err = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
objectPath = filepath.Join(root, "object2")
|
objectPath = filepath.Join(root, "object2")
|
||||||
fsc, err = New(objectPath)
|
fsc, perr = New(objectPath)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
err = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
fsc, err = New(root)
|
fsc, perr = New(root)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
var contents []*client.Content
|
var contents []*client.Content
|
||||||
for contentCh := range fsc.List(false) {
|
for contentCh := range fsc.List(false) {
|
||||||
|
if contentCh.Err != nil {
|
||||||
|
perr = contentCh.Err
|
||||||
|
break
|
||||||
|
}
|
||||||
contents = append(contents, contentCh.Content)
|
contents = append(contents, contentCh.Content)
|
||||||
}
|
}
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
c.Assert(len(contents), Equals, 2)
|
c.Assert(len(contents), Equals, 2)
|
||||||
|
|
||||||
for _, content := range contents {
|
for _, content := range contents {
|
||||||
@@ -71,20 +75,24 @@ func (s *MySuite) TestList(c *C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
objectPath = filepath.Join(root, "test1/newObject1")
|
objectPath = filepath.Join(root, "test1/newObject1")
|
||||||
fsc, err = New(objectPath)
|
fsc, perr = New(objectPath)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
err = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
fsc, err = New(root)
|
fsc, perr = New(root)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
contents = nil
|
contents = nil
|
||||||
for contentCh := range fsc.List(false) {
|
for contentCh := range fsc.List(false) {
|
||||||
|
if contentCh.Err != nil {
|
||||||
|
perr = contentCh.Err
|
||||||
|
break
|
||||||
|
}
|
||||||
contents = append(contents, contentCh.Content)
|
contents = append(contents, contentCh.Content)
|
||||||
}
|
}
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
c.Assert(len(contents), Equals, 3)
|
c.Assert(len(contents), Equals, 3)
|
||||||
|
|
||||||
for _, content := range contents {
|
for _, content := range contents {
|
||||||
@@ -95,11 +103,15 @@ func (s *MySuite) TestList(c *C) {
|
|||||||
c.Assert(content.Type.IsDir(), Equals, true)
|
c.Assert(content.Type.IsDir(), Equals, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
fsc, err = New(root)
|
fsc, perr = New(root)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
contents = nil
|
contents = nil
|
||||||
for contentCh := range fsc.List(true) {
|
for contentCh := range fsc.List(true) {
|
||||||
|
if contentCh.Err != nil {
|
||||||
|
perr = contentCh.Err
|
||||||
|
break
|
||||||
|
}
|
||||||
contents = append(contents, contentCh.Content)
|
contents = append(contents, contentCh.Content)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,10 +139,10 @@ func (s *MySuite) TestPutBucket(c *C) {
|
|||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
bucketPath := filepath.Join(root, "bucket")
|
bucketPath := filepath.Join(root, "bucket")
|
||||||
fsc, err := New(bucketPath)
|
fsc, perr := New(bucketPath)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
err = fsc.MakeBucket()
|
perr = fsc.MakeBucket()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestStatBucket(c *C) {
|
func (s *MySuite) TestStatBucket(c *C) {
|
||||||
@@ -140,12 +152,12 @@ func (s *MySuite) TestStatBucket(c *C) {
|
|||||||
|
|
||||||
bucketPath := filepath.Join(root, "bucket")
|
bucketPath := filepath.Join(root, "bucket")
|
||||||
|
|
||||||
fsc, err := New(bucketPath)
|
fsc, perr := New(bucketPath)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
err = fsc.MakeBucket()
|
perr = fsc.MakeBucket()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
_, err = fsc.Stat()
|
_, perr = fsc.Stat()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestPutBucketACL(c *C) {
|
func (s *MySuite) TestPutBucketACL(c *C) {
|
||||||
@@ -154,13 +166,13 @@ func (s *MySuite) TestPutBucketACL(c *C) {
|
|||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
bucketPath := filepath.Join(root, "bucket")
|
bucketPath := filepath.Join(root, "bucket")
|
||||||
fsc, err := New(bucketPath)
|
fsc, perr := New(bucketPath)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
err = fsc.MakeBucket()
|
perr = fsc.MakeBucket()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
err = fsc.SetBucketACL("private")
|
perr = fsc.SetBucketACL("private")
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestPutObject(c *C) {
|
func (s *MySuite) TestPutObject(c *C) {
|
||||||
@@ -169,14 +181,14 @@ func (s *MySuite) TestPutObject(c *C) {
|
|||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
objectPath := filepath.Join(root, "object")
|
objectPath := filepath.Join(root, "object")
|
||||||
fsc, err := New(objectPath)
|
fsc, perr := New(objectPath)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
data := "hello"
|
data := "hello"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
|
|
||||||
err = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *MySuite) TestGetObject(c *C) {
|
func (s *MySuite) TestGetObject(c *C) {
|
||||||
@@ -185,17 +197,17 @@ func (s *MySuite) TestGetObject(c *C) {
|
|||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
objectPath := filepath.Join(root, "object")
|
objectPath := filepath.Join(root, "object")
|
||||||
fsc, err := New(objectPath)
|
fsc, perr := New(objectPath)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
data := "hello"
|
data := "hello"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
|
|
||||||
err = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
reader, size, err := fsc.GetObject(0, 0)
|
reader, size, perr := fsc.GetObject(0, 0)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
var results bytes.Buffer
|
var results bytes.Buffer
|
||||||
_, err = io.CopyN(&results, reader, int64(size))
|
_, err = io.CopyN(&results, reader, int64(size))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
@@ -209,17 +221,17 @@ func (s *MySuite) TestGetObjectRange(c *C) {
|
|||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
objectPath := filepath.Join(root, "object")
|
objectPath := filepath.Join(root, "object")
|
||||||
fsc, err := New(objectPath)
|
fsc, perr := New(objectPath)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
data := "hello world"
|
data := "hello world"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
|
|
||||||
err = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
reader, size, err := fsc.GetObject(0, 5)
|
reader, size, perr := fsc.GetObject(0, 5)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
var results bytes.Buffer
|
var results bytes.Buffer
|
||||||
_, err = io.CopyN(&results, reader, int64(size))
|
_, err = io.CopyN(&results, reader, int64(size))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
@@ -232,17 +244,17 @@ func (s *MySuite) TestStatObject(c *C) {
|
|||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
objectPath := filepath.Join(root, "object")
|
objectPath := filepath.Join(root, "object")
|
||||||
fsc, err := New(objectPath)
|
fsc, perr := New(objectPath)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
data := "hello"
|
data := "hello"
|
||||||
dataLen := len(data)
|
dataLen := len(data)
|
||||||
|
|
||||||
err = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
content, err := fsc.Stat()
|
content, perr := fsc.Stat()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
c.Assert(content.Name, Equals, objectPath)
|
c.Assert(content.Name, Equals, objectPath)
|
||||||
c.Assert(content.Size, Equals, int64(dataLen))
|
c.Assert(content.Size, Equals, int64(dataLen))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/mc/pkg/client"
|
"github.com/minio/mc/pkg/client"
|
||||||
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/minio/minio-go"
|
"github.com/minio/minio-go"
|
||||||
"github.com/minio/minio/pkg/probe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config - see http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html
|
// Config - see http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?RESTAuthentication.html
|
||||||
@@ -178,7 +178,7 @@ func (c *s3Client) Stat() (*client.Content, *probe.Error) {
|
|||||||
if errResponse.Code == "NoSuchKey" {
|
if errResponse.Code == "NoSuchKey" {
|
||||||
for content := range c.List(false) {
|
for content := range c.List(false) {
|
||||||
if content.Err != nil {
|
if content.Err != nil {
|
||||||
return nil, probe.New(content.Err)
|
return nil, content.Err.Trace()
|
||||||
}
|
}
|
||||||
content.Content.Type = os.ModeDir
|
content.Content.Type = os.ModeDir
|
||||||
content.Content.Name = object
|
content.Content.Name = object
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import (
|
|||||||
|
|
||||||
"github.com/fatih/color"
|
"github.com/fatih/color"
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/shiena/ansicolor"
|
"github.com/shiena/ansicolor"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -352,7 +352,7 @@ func Unlock() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetTheme sets a color theme
|
// SetTheme sets a color theme
|
||||||
func SetTheme(themeName string) error {
|
func SetTheme(themeName string) *probe.Error {
|
||||||
if !IsValidTheme(themeName) {
|
if !IsValidTheme(themeName) {
|
||||||
return probe.New(fmt.Errorf("Unsupported theme name [%s]", themeName))
|
return probe.New(fmt.Errorf("Unsupported theme name [%s]", themeName))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,17 +124,9 @@ func (e *Error) Untrace() {
|
|||||||
e.tracePoints = e.tracePoints[:l-1]
|
e.tracePoints = e.tracePoints[:l-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error returns error string.
|
|
||||||
func (e *Error) Error() string {
|
|
||||||
if e == nil {
|
|
||||||
return "<nil>"
|
|
||||||
}
|
|
||||||
return e.String()
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns error message.
|
// String returns error message.
|
||||||
func (e *Error) String() string {
|
func (e *Error) String() string {
|
||||||
if e == nil {
|
if e == nil || e.e == nil {
|
||||||
return "<nil>"
|
return "<nil>"
|
||||||
}
|
}
|
||||||
e.lock.RLock()
|
e.lock.RLock()
|
||||||
@@ -164,7 +156,7 @@ func (e *Error) String() string {
|
|||||||
|
|
||||||
// JSON returns JSON formated error trace.
|
// JSON returns JSON formated error trace.
|
||||||
func (e *Error) JSON() string {
|
func (e *Error) JSON() string {
|
||||||
if e == nil {
|
if e == nil || e.e == nil {
|
||||||
return "<nil>"
|
return "<nil>"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/fatih/structs"
|
"github.com/fatih/structs"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config - generic config interface functions
|
// Config - generic config interface functions
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Help message.
|
// Help message.
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/minio/mc/pkg/quick"
|
"github.com/minio/mc/pkg/quick"
|
||||||
"github.com/minio/minio/pkg/probe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type sessionV1 struct {
|
type sessionV1 struct {
|
||||||
@@ -48,7 +48,7 @@ func (s sessionV1) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// loadSession - reads session file if exists and re-initiates internal variables
|
// loadSession - reads session file if exists and re-initiates internal variables
|
||||||
func loadSessionV1(sid string) (*sessionV1, error) {
|
func loadSessionV1(sid string) (*sessionV1, *probe.Error) {
|
||||||
if !isSessionDirExists() {
|
if !isSessionDirExists() {
|
||||||
return nil, probe.New(errInvalidArgument{})
|
return nil, probe.New(errInvalidArgument{})
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ func getSessionIDsV1() (sids []string) {
|
|||||||
if sidReg.Match([]byte(sid)) {
|
if sidReg.Match([]byte(sid)) {
|
||||||
sessionV1, err := loadSessionV1(sid)
|
sessionV1, err := loadSessionV1(sid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
console.Fatalf("Unable to load session ‘%s’, %s", sid, probe.New(err))
|
console.Fatalf("Unable to load session ‘%s’, %s", sid, err.Trace())
|
||||||
}
|
}
|
||||||
if sessionV1.Version != "1.0.0" {
|
if sessionV1.Version != "1.0.0" {
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
|
"github.com/minio/mc/pkg/probe"
|
||||||
"github.com/minio/mc/pkg/quick"
|
"github.com/minio/mc/pkg/quick"
|
||||||
"github.com/minio/minio/pkg/probe"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// migrateSessionV1ToV2 migrates all session files from v1 to v2.
|
// migrateSessionV1ToV2 migrates all session files from v1 to v2.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
func migrateSession() {
|
func migrateSession() {
|
||||||
|
|||||||
@@ -32,26 +32,26 @@ func (s *CmdTestSuite) TestValidSessionID(c *C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *CmdTestSuite) TestSession(c *C) {
|
func (s *CmdTestSuite) TestSession(c *C) {
|
||||||
err := createSessionDir()
|
perr := createSessionDir()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
c.Assert(isSessionDirExists(), Equals, true)
|
c.Assert(isSessionDirExists(), Equals, true)
|
||||||
|
|
||||||
session := newSessionV2()
|
session := newSessionV2()
|
||||||
c.Assert(session.Header.CommandArgs, IsNil)
|
c.Assert(session.Header.CommandArgs, IsNil)
|
||||||
c.Assert(len(session.SessionID), Equals, 8)
|
c.Assert(len(session.SessionID), Equals, 8)
|
||||||
|
|
||||||
err = session.Close()
|
perr = session.Close()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
savedSession, err := loadSessionV2(session.SessionID)
|
savedSession, perr := loadSessionV2(session.SessionID)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
c.Assert(session.SessionID, Equals, savedSession.SessionID)
|
c.Assert(session.SessionID, Equals, savedSession.SessionID)
|
||||||
|
|
||||||
err = savedSession.Close()
|
perr = savedSession.Close()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
err = savedSession.Delete()
|
perr = savedSession.Delete()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *CmdTestSuite) TestSessionContext(c *C) {
|
func (s *CmdTestSuite) TestSessionContext(c *C) {
|
||||||
@@ -72,16 +72,16 @@ func (s *CmdTestSuite) TestSessionContext(c *C) {
|
|||||||
c.Assert(console.IsExited, Equals, true)
|
c.Assert(console.IsExited, Equals, true)
|
||||||
console.IsExited = false
|
console.IsExited = false
|
||||||
|
|
||||||
err = createSessionDir()
|
perr := createSessionDir()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
c.Assert(isSessionDirExists(), Equals, true)
|
c.Assert(isSessionDirExists(), Equals, true)
|
||||||
|
|
||||||
session := newSessionV2()
|
session := newSessionV2()
|
||||||
c.Assert(session.Header.CommandArgs, IsNil)
|
c.Assert(session.Header.CommandArgs, IsNil)
|
||||||
c.Assert(len(session.SessionID), Equals, 8)
|
c.Assert(len(session.SessionID), Equals, 8)
|
||||||
|
|
||||||
err = session.Save()
|
perr = session.Save()
|
||||||
c.Assert(err, IsNil)
|
c.Assert(perr, IsNil)
|
||||||
|
|
||||||
err = app.Run([]string{os.Args[0], "session", "clear", session.SessionID})
|
err = app.Run([]string{os.Args[0], "session", "clear", session.SessionID})
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import (
|
|||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/client"
|
"github.com/minio/mc/pkg/client"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Help message.
|
// Help message.
|
||||||
@@ -70,7 +70,7 @@ func runShareCmd(ctx *cli.Context) {
|
|||||||
if len(args) == 2 {
|
if len(args) == 2 {
|
||||||
var err error
|
var err error
|
||||||
expires, err = time.ParseDuration(args.Last())
|
expires, err = time.ParseDuration(args.Last())
|
||||||
Fatal(err)
|
Fatal(probe.New(err))
|
||||||
}
|
}
|
||||||
targetURL, err := getExpandedURL(url, config.Aliases)
|
targetURL, err := getExpandedURL(url, config.Aliases)
|
||||||
Fatal(err)
|
Fatal(err)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import (
|
|||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
"github.com/minio/mc/pkg/console"
|
"github.com/minio/mc/pkg/console"
|
||||||
"github.com/minio/minio/pkg/probe"
|
"github.com/minio/mc/pkg/probe"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Updates container to hold updates json
|
// Updates container to hold updates json
|
||||||
|
|||||||
Reference in New Issue
Block a user