This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"time" | |
"github.com/Xuanwo/storage" | |
"github.com/Xuanwo/storage/pkg/credential" | |
"github.com/Xuanwo/storage/pkg/endpoint" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestCatRun(t *testing.T) { | |
tmpErr := errors.New("temp err") | |
cases := []struct { | |
name string | |
input string | |
parseErr error | |
runErr error | |
}{ | |
{ | |
name: "normal", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (s *Storage) getAbsPath(path string) string { | |
return strings.TrimPrefix(strings.TrimSuffix(s.workDir, "/")+"/"+path, "/") | |
} | |
func (s *Storage) getRelPath(path string) string { | |
return strings.TrimPrefix(path, strings.TrimSuffix(s.workDir, "/")+"/") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package utils | |
import ( | |
"path/filepath" | |
"strings" | |
) | |
var separator = "/" | |
// ParseWd get a path as input, split the work dir and file by following rules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func HandleStorageBaseAndPath(t *taskutils.BetweenStorageTask) error { | |
// In operation cp, we set source storage to dir of the source path. | |
srcPath, err := filepath.Abs(t.GetSourcePath()) | |
if err != nil { | |
return err | |
} | |
if err = t.GetSourceStorage().Init(types.WithBase(filepath.Dir(srcPath))); err != nil { | |
return err | |
} | |
t.SetSourcePath(filepath.Base(srcPath)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ModifyStruct uses reflect to modify a struct. | |
// v is a pointer to a struct, | |
// m supports the map to modify the struct, | |
// myTag is used to determine which field to modify by its tag, | |
// if myTag == "", modify by its name. | |
func ModifyStruct(v interface{}, m StringMapper, myTag string) error { | |
if reflect.TypeOf(v).Kind() != reflect.Ptr || // v should be a pointer | |
reflect.TypeOf(v).Elem().Kind() != reflect.Struct { // to a struct | |
return InvalidStructErr | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"github.com/spf13/cobra" | |
"github.com/yunify/qsctl/v2/action" | |
"github.com/yunify/qsctl/v2/utils" | |
) | |
// CpCommand will handle copy command. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package action | |
import ( | |
"bufio" | |
"bytes" | |
"crypto/md5" | |
"io" | |
"os" | |
"runtime/pprof" | |
"sync" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package action | |
// FlagHandler contains all flags from cmd | |
type FlagHandler struct { | |
Bench bool `json:"bench"` | |
ExpectSize int64 `json:"expect_size"` | |
Format string `json:"format"` | |
HumanReadable bool `json:"human_readable"` | |
LongFormat bool `json:"long_format"` | |
MaximumMemoryContent int64 `json:"maximum_memory_content"` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package action | |
import ( | |
"io" | |
"io/ioutil" | |
"testing" | |
"github.com/google/uuid" | |
"github.com/stretchr/testify/assert" | |
"github.com/stretchr/testify/suite" |
NewerOlder