add gofumpt support, automated cleanup (#3911)
This commit is contained in:
@@ -61,7 +61,7 @@ jobs:
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: fmt
|
||||
run: diff -au <(gofmt -s -d .) <(printf "")
|
||||
run: diff -au <(gofumpt -d .) <(printf "")
|
||||
|
||||
- name: Test 386
|
||||
run: GOOS=linux GOARCH=386 go test -short ./...
|
||||
|
||||
@@ -19,7 +19,8 @@ checks:
|
||||
getdeps:
|
||||
@mkdir -p ${GOPATH}/bin
|
||||
@echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.40.1
|
||||
@which stringer 1>/dev/null || (echo "Installing stringer" && go install -v golang.org/x/tools/cmd/stringer@v0.1.5)
|
||||
@echo "Installing gofumpt" && go install mvdan.cc/gofumpt@latest
|
||||
@echo "Installing stringer" && go install -v golang.org/x/tools/cmd/stringer@latest
|
||||
|
||||
crosscompile:
|
||||
@(env bash $(PWD)/buildscripts/cross-compile.sh)
|
||||
|
||||
@@ -65,6 +65,7 @@ var adminBucketRemoteAddFlags = []cli.Flag{
|
||||
Usage: "disable proxying in active-active replication. If unset, default behavior is to proxy",
|
||||
},
|
||||
}
|
||||
|
||||
var adminBucketRemoteAddCmd = cli.Command{
|
||||
Name: "add",
|
||||
Usage: "add a new remote target",
|
||||
|
||||
@@ -132,6 +132,7 @@ func printTable(report madmin.Report, bits bool, iec bool) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func checkAdminBwInfoSyntax(ctx *cli.Context) {
|
||||
u := ctx.String("unit")
|
||||
if u != "bi" &&
|
||||
|
||||
@@ -59,6 +59,7 @@ var adminBucketRemoteEditFlags = []cli.Flag{
|
||||
Usage: "bucket path lookup supported by the server. Valid options are '[on,off,auto]'",
|
||||
},
|
||||
}
|
||||
|
||||
var adminBucketRemoteEditCmd = cli.Command{
|
||||
Name: "edit",
|
||||
Usage: "edit remote target",
|
||||
|
||||
@@ -100,7 +100,6 @@ func mainAdminBucketRemoteList(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
func printRemotes(ctx *cli.Context, urlStr string, targets []madmin.BucketTarget) {
|
||||
|
||||
maxURLLen := 10
|
||||
maxTgtLen := 6
|
||||
maxSrcLen := 6
|
||||
|
||||
@@ -30,6 +30,7 @@ var adminBucketRemoteRmFlags = []cli.Flag{
|
||||
Usage: "ARN to be removed",
|
||||
},
|
||||
}
|
||||
|
||||
var adminBucketRemoteRmCmd = cli.Command{
|
||||
Name: "rm",
|
||||
Usage: "remove configured remote target",
|
||||
@@ -55,7 +56,6 @@ EXAMPLES:
|
||||
|
||||
// checkAdminBucketRemoteRemoveSyntax - validate all the passed arguments
|
||||
func checkAdminBucketRemoteRemoveSyntax(ctx *cli.Context) {
|
||||
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
|
||||
}
|
||||
|
||||
@@ -73,7 +73,6 @@ func checkAdminConfigExportSyntax(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
func mainAdminConfigExport(ctx *cli.Context) error {
|
||||
|
||||
checkAdminConfigExportSyntax(ctx)
|
||||
|
||||
// Export the alias parameter from cli
|
||||
|
||||
@@ -86,7 +86,6 @@ func checkAdminConfigGetSyntax(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
func mainAdminConfigGet(ctx *cli.Context) error {
|
||||
|
||||
checkAdminConfigGetSyntax(ctx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
|
||||
@@ -114,7 +114,6 @@ func checkAdminConfigHistorySyntax(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
func mainAdminConfigHistory(ctx *cli.Context) error {
|
||||
|
||||
checkAdminConfigHistorySyntax(ctx)
|
||||
|
||||
console.SetColor("ConfigHistoryMessageRestoreID", color.New(color.Bold))
|
||||
|
||||
@@ -83,7 +83,6 @@ func checkAdminConfigImportSyntax(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
func mainAdminConfigImport(ctx *cli.Context) error {
|
||||
|
||||
checkAdminConfigImportSyntax(ctx)
|
||||
|
||||
// Set color preference of command outputs
|
||||
|
||||
@@ -72,7 +72,6 @@ func (u configResetMessage) String() (msg string) {
|
||||
if u.restart {
|
||||
msg += console.Colorize("ResetConfigSuccess",
|
||||
fmt.Sprintf("Please restart your server with `%s`.\n", suggestion))
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -95,7 +94,6 @@ func checkAdminConfigResetSyntax(ctx *cli.Context) {
|
||||
|
||||
// main config set function
|
||||
func mainAdminConfigReset(ctx *cli.Context) error {
|
||||
|
||||
// Check command arguments
|
||||
checkAdminConfigResetSyntax(ctx)
|
||||
|
||||
|
||||
@@ -82,7 +82,6 @@ func checkAdminConfigRestoreSyntax(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
func mainAdminConfigRestore(ctx *cli.Context) error {
|
||||
|
||||
checkAdminConfigRestoreSyntax(ctx)
|
||||
|
||||
console.SetColor("ConfigRestoreMessage", color.New(color.FgGreen))
|
||||
|
||||
@@ -94,7 +94,6 @@ func checkAdminConfigSetSyntax(ctx *cli.Context) {
|
||||
|
||||
// main config set function
|
||||
func mainAdminConfigSet(ctx *cli.Context) error {
|
||||
|
||||
// Check command arguments
|
||||
checkAdminConfigSetSyntax(ctx)
|
||||
|
||||
|
||||
@@ -94,8 +94,8 @@ func (l logMessage) JSON() string {
|
||||
fatalIf(probe.NewError(err), "Unable to marshal into JSON.")
|
||||
|
||||
return string(logJSON)
|
||||
|
||||
}
|
||||
|
||||
func getLogTime(lt string) string {
|
||||
tm, err := time.Parse(time.RFC3339Nano, lt)
|
||||
if err != nil {
|
||||
@@ -107,7 +107,7 @@ func getLogTime(lt string) string {
|
||||
// String - return colorized loginfo as string.
|
||||
func (l logMessage) String() string {
|
||||
var hostStr string
|
||||
var b = &strings.Builder{}
|
||||
b := &strings.Builder{}
|
||||
if l.NodeName != "" {
|
||||
hostStr = fmt.Sprintf("%s ", colorizedNodeName(l.NodeName))
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ func (h hri) getObjectHCCChange() (b, a col, err error) {
|
||||
err, surplusShardsAfterHeal, parityShards)
|
||||
}
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
// getReplicatedFileHCCChange - fetches health color code for metadata
|
||||
|
||||
+3
-4
@@ -356,7 +356,7 @@ func (s verboseBackgroundHealStatusMessage) String() string {
|
||||
setsStatus := generateSetsStatus(allDisks)
|
||||
serversStatus := generateServersStatus(allDisks)
|
||||
|
||||
var poolsInfo = make(map[int]poolInfo)
|
||||
poolsInfo := make(map[int]poolInfo)
|
||||
for _, pool := range pools {
|
||||
tolerance := computePoolTolerance(pool, parity, setsStatus, serversStatus)
|
||||
endpoints := computePoolEndpoints(pool, serversStatus)
|
||||
@@ -365,7 +365,7 @@ func (s verboseBackgroundHealStatusMessage) String() string {
|
||||
|
||||
distributed := len(serversStatus) > 1
|
||||
|
||||
var plural = ""
|
||||
plural := ""
|
||||
if distributed {
|
||||
plural = "s"
|
||||
}
|
||||
@@ -376,7 +376,7 @@ func (s verboseBackgroundHealStatusMessage) String() string {
|
||||
fmt.Fprintf(&msg, "Pool %s:\n", humanize.Ordinal(pool+1))
|
||||
|
||||
// Sort servers in this pool by name
|
||||
var orderedEndpoints = make([]string, len(poolsInfo[pool].endpoints))
|
||||
orderedEndpoints := make([]string, len(poolsInfo[pool].endpoints))
|
||||
copy(orderedEndpoints, poolsInfo[pool].endpoints)
|
||||
sort.Strings(orderedEndpoints)
|
||||
|
||||
@@ -586,7 +586,6 @@ func transformScanArg(scanArg string) madmin.HealScanMode {
|
||||
|
||||
// mainAdminHeal - the entry function of heal command
|
||||
func mainAdminHeal(ctx *cli.Context) error {
|
||||
|
||||
// Check for command syntax
|
||||
checkAdminHealSyntax(ctx)
|
||||
|
||||
|
||||
+1
-3
@@ -19,9 +19,7 @@ package cmd
|
||||
|
||||
import "github.com/minio/cli"
|
||||
|
||||
var (
|
||||
adminFlags = []cli.Flag{}
|
||||
)
|
||||
var adminFlags = []cli.Flag{}
|
||||
|
||||
const (
|
||||
// dot represents a list item, for eg. server status - online (green) or offline (red)
|
||||
|
||||
@@ -55,9 +55,7 @@ EXAMPLES:
|
||||
`,
|
||||
}
|
||||
|
||||
var (
|
||||
errBadUserGroupArg = errors.New("Last argument must be of the form user=xx or group=xx")
|
||||
)
|
||||
var errBadUserGroupArg = errors.New("Last argument must be of the form user=xx or group=xx")
|
||||
|
||||
func checkAdminPolicySetSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 3 {
|
||||
|
||||
@@ -189,7 +189,6 @@ func generatePrometheusConfig(ctx *cli.Context) error {
|
||||
|
||||
// mainAdminPrometheus is the handle for "mc admin prometheus generate" sub-command.
|
||||
func mainAdminPrometheusGenerate(ctx *cli.Context) error {
|
||||
|
||||
console.SetColor("yaml", color.New(color.FgGreen))
|
||||
|
||||
checkAdminPrometheusSyntax(ctx)
|
||||
|
||||
@@ -101,7 +101,6 @@ func checkAdminServiceRestartSyntax(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
func mainAdminServiceRestart(ctx *cli.Context) error {
|
||||
|
||||
// Validate serivce restart syntax.
|
||||
checkAdminServiceRestartSyntax(ctx)
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ func checkAdminServiceStopSyntax(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
func mainAdminServiceStop(ctx *cli.Context) error {
|
||||
|
||||
// Validate serivce stop syntax.
|
||||
checkAdminServiceStopSyntax(ctx)
|
||||
|
||||
|
||||
@@ -114,9 +114,9 @@ func checkAdminHealthSyntax(ctx *cli.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
//compress and tar MinIO health output
|
||||
// compress and tar MinIO health output
|
||||
func tarGZ(healthInfo interface{}, version string, filename string, showMessages bool) error {
|
||||
f, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR, 0666)
|
||||
f, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR, 0o666)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -665,5 +665,7 @@ func (f HealthDataTypeFlag) ApplyWithError(set *flag.FlagSet) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var liteOptions = HealthDataTypeSlice(madmin.HealthDataTypesLite)
|
||||
var fullOptions = HealthDataTypeSlice(madmin.HealthDataTypesList)
|
||||
var (
|
||||
liteOptions = HealthDataTypeSlice(madmin.HealthDataTypesLite)
|
||||
fullOptions = HealthDataTypeSlice(madmin.HealthDataTypesList)
|
||||
)
|
||||
|
||||
@@ -103,6 +103,7 @@ func (t tierInfos) NumRows() int {
|
||||
func (t tierInfos) NumCols() int {
|
||||
return len(tierInfoRowNames)
|
||||
}
|
||||
|
||||
func (t tierInfos) EmptyMessage() string {
|
||||
return "No remote tiers configured."
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@ func (t tierLS) NumRows() int {
|
||||
func (t tierLS) NumCols() int {
|
||||
return len(tierLSRowNames)
|
||||
}
|
||||
|
||||
func (t tierLS) EmptyMessage() string {
|
||||
return "No remote tier has been configured"
|
||||
}
|
||||
|
||||
@@ -117,7 +117,6 @@ func checkAdminTopLocksSyntax(ctx *cli.Context) {
|
||||
}
|
||||
|
||||
func mainAdminTopLocks(ctx *cli.Context) error {
|
||||
|
||||
checkAdminTopLocksSyntax(ctx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
|
||||
+3
-6
@@ -113,9 +113,7 @@ EXAMPLES:
|
||||
|
||||
const timeFormat = "2006-01-02T15:04:05:000"
|
||||
|
||||
var (
|
||||
colors = []color.Attribute{color.FgCyan, color.FgWhite, color.FgYellow, color.FgGreen}
|
||||
)
|
||||
var colors = []color.Attribute{color.FgCyan, color.FgWhite, color.FgYellow, color.FgGreen}
|
||||
|
||||
func checkAdminTraceSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
@@ -205,7 +203,6 @@ func matchTrace(ctx *cli.Context, traceInfo madmin.ServiceTraceInfo) bool {
|
||||
|
||||
// Calculate tracing options for command line flags
|
||||
func tracingOpts(ctx *cli.Context) (opts madmin.ServiceTraceOpts, e error) {
|
||||
|
||||
if t := ctx.String("response-threshold"); t != "" {
|
||||
d, e := time.ParseDuration(t)
|
||||
if e != nil {
|
||||
@@ -423,7 +420,7 @@ func (s shortTraceMsg) JSON() string {
|
||||
|
||||
func (s shortTraceMsg) String() string {
|
||||
var hostStr string
|
||||
var b = &strings.Builder{}
|
||||
b := &strings.Builder{}
|
||||
|
||||
if s.Host != "" {
|
||||
hostStr = colorizedNodeName(s.Host)
|
||||
@@ -542,7 +539,7 @@ func (t traceMessage) JSON() string {
|
||||
|
||||
func (t traceMessage) String() string {
|
||||
var nodeNameStr string
|
||||
var b = &strings.Builder{}
|
||||
b := &strings.Builder{}
|
||||
|
||||
trc := t.Trace
|
||||
if trc.NodeName != "" {
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ func mainAliasList(ctx *cli.Context, deprecated bool) error {
|
||||
|
||||
// Prints all the aliases
|
||||
func printAliases(aliases ...aliasMessage) {
|
||||
var maxAlias = 0
|
||||
maxAlias := 0
|
||||
for _, alias := range aliases {
|
||||
if len(alias.Alias) > maxAlias {
|
||||
maxAlias = len(alias.Alias)
|
||||
|
||||
+1
-3
@@ -35,9 +35,7 @@ import (
|
||||
// ----
|
||||
//
|
||||
|
||||
var (
|
||||
aliasFlags = []cli.Flag{}
|
||||
)
|
||||
var aliasFlags = []cli.Flag{}
|
||||
|
||||
var aliasSubcommands = []cli.Command{
|
||||
aliasSetCmd,
|
||||
|
||||
@@ -32,14 +32,12 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
anonymousFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "list recursively",
|
||||
},
|
||||
}
|
||||
)
|
||||
var anonymousFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "list recursively",
|
||||
},
|
||||
}
|
||||
|
||||
// Manage anonymous access to buckets and objects.
|
||||
var anonymousCmd = cli.Command{
|
||||
|
||||
@@ -84,7 +84,6 @@ func completeAdminConfigKeys(aliasPath string, keyPrefix string) (prediction []s
|
||||
// then recursively scans it. This is needed to satisfy posener/complete
|
||||
// (look at posener/complete.PredictFiles)
|
||||
func completeS3Path(s3Path string) (prediction []string) {
|
||||
|
||||
// Convert alias/bucket/incompl to alias/bucket/ to list its contents
|
||||
parentDirPath := filepath.Dir(s3Path) + "/"
|
||||
clnt, err := newClient(parentDirPath)
|
||||
@@ -220,10 +219,12 @@ func (al aliasComplete) Predict(a complete.Args) (prediction []string) {
|
||||
return
|
||||
}
|
||||
|
||||
var adminConfigCompleter = adminConfigComplete{}
|
||||
var s3Completer = s3Complete{}
|
||||
var aliasCompleter = aliasComplete{}
|
||||
var fsCompleter = fsComplete{}
|
||||
var (
|
||||
adminConfigCompleter = adminConfigComplete{}
|
||||
s3Completer = s3Complete{}
|
||||
aliasCompleter = aliasComplete{}
|
||||
fsCompleter = fsComplete{}
|
||||
)
|
||||
|
||||
// The list of all commands supported by mc with their mapping
|
||||
// with their bash completer function
|
||||
@@ -391,7 +392,7 @@ var completeCmds = map[string]complete.Predictor{
|
||||
// flagsToCompleteFlags transforms a cli.Flag to complete.Flags
|
||||
// understood by posener/complete library.
|
||||
func flagsToCompleteFlags(flags []cli.Flag) complete.Flags {
|
||||
var complFlags = make(complete.Flags)
|
||||
complFlags := make(complete.Flags)
|
||||
for _, f := range flags {
|
||||
for _, s := range strings.Split(f.GetName(), ",") {
|
||||
var flagName string
|
||||
@@ -429,7 +430,7 @@ func cmdToCompleteCmd(cmd cli.Command, parentPath string) complete.Command {
|
||||
func mainComplete() error {
|
||||
// Recursively register all commands and subcommands
|
||||
// along with global and local flags
|
||||
var complCmds = make(complete.Commands)
|
||||
complCmds := make(complete.Commands)
|
||||
for _, cmd := range appCmds {
|
||||
if cmd.Hidden {
|
||||
continue
|
||||
|
||||
@@ -25,7 +25,6 @@ import (
|
||||
)
|
||||
|
||||
func TestAutoCompletionCompletness(t *testing.T) {
|
||||
|
||||
var checkCompletion func(cmd cli.Command, cmdPath string) error
|
||||
|
||||
checkCompletion = func(cmd cli.Command, cmdPath string) error {
|
||||
|
||||
+11
-13
@@ -34,18 +34,16 @@ import (
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
var (
|
||||
catFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "display an earlier object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "display a specific version of an object",
|
||||
},
|
||||
}
|
||||
)
|
||||
var catFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "display an earlier object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "display a specific version of an object",
|
||||
},
|
||||
}
|
||||
|
||||
// Display contents of a file.
|
||||
var catCmd = cli.Command{
|
||||
@@ -174,7 +172,7 @@ func catURL(ctx context.Context, sourceURL, sourceVersion string, timeRef time.T
|
||||
case "-":
|
||||
reader = os.Stdin
|
||||
default:
|
||||
var versionID = sourceVersion
|
||||
versionID := sourceVersion
|
||||
var err *probe.Error
|
||||
// Try to stat the object, the purpose is to:
|
||||
// 1. extract the size of S3 object so we can check if the size of the
|
||||
|
||||
+2
-2
@@ -50,7 +50,7 @@ func createCertsDir() *probe.Error {
|
||||
if err != nil {
|
||||
return err.Trace()
|
||||
}
|
||||
if e := os.MkdirAll(p, 0700); e != nil {
|
||||
if e := os.MkdirAll(p, 0o700); e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
return nil
|
||||
@@ -90,7 +90,7 @@ func createCAsDir() *probe.Error {
|
||||
if err != nil {
|
||||
return err.Trace()
|
||||
}
|
||||
if e := os.MkdirAll(p, 0700); e != nil {
|
||||
if e := os.MkdirAll(p, 0o700); e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -170,8 +170,7 @@ func (e ObjectMissing) Error() string {
|
||||
}
|
||||
|
||||
// ObjectIsDeleteMarker - object is a delete marker as latest
|
||||
type ObjectIsDeleteMarker struct {
|
||||
}
|
||||
type ObjectIsDeleteMarker struct{}
|
||||
|
||||
func (e ObjectIsDeleteMarker) Error() string {
|
||||
return "Object is marked as deleted"
|
||||
|
||||
+15
-17
@@ -59,12 +59,11 @@ const (
|
||||
metadataKeyS3Cmd = "X-Amz-Meta-S3cmd-Attrs"
|
||||
)
|
||||
|
||||
var ( // GOOS specific ignore list.
|
||||
ignoreFiles = map[string][]string{
|
||||
"darwin": {"*.DS_Store"},
|
||||
"default": {"lost+found"},
|
||||
}
|
||||
)
|
||||
// GOOS specific ignore list.
|
||||
var ignoreFiles = map[string][]string{
|
||||
"darwin": {"*.DS_Store"},
|
||||
"default": {"lost+found"},
|
||||
}
|
||||
|
||||
// fsNew - instantiate a new fs
|
||||
func fsNew(path string) (Client, *probe.Error) {
|
||||
@@ -274,7 +273,7 @@ func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, progre
|
||||
|
||||
if objectDir != "" {
|
||||
// Create any missing top level directories.
|
||||
if e := os.MkdirAll(objectDir, 0777); e != nil {
|
||||
if e := os.MkdirAll(objectDir, 0o777); e != nil {
|
||||
err := f.toClientError(e, f.PathURL.Path)
|
||||
return 0, err.Trace(f.PathURL.Path)
|
||||
}
|
||||
@@ -294,7 +293,7 @@ func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, progre
|
||||
// should remove any partial download if any.
|
||||
defer os.Remove(objectPartPath)
|
||||
|
||||
tmpFile, e := os.OpenFile(objectPartPath, os.O_CREATE|os.O_WRONLY, 0666)
|
||||
tmpFile, e := os.OpenFile(objectPartPath, os.O_CREATE|os.O_WRONLY, 0o666)
|
||||
if e != nil {
|
||||
err := f.toClientError(e, f.PathURL.Path)
|
||||
return 0, err.Trace(f.PathURL.Path)
|
||||
@@ -921,7 +920,7 @@ func (f *fsClient) MakeBucket(ctx context.Context, region string, ignoreExisting
|
||||
// to call os.Mkdir() when ignoredExisting is disabled and os.MkdirAll()
|
||||
// otherwise.
|
||||
// NOTE: withLock=true has no meaning here.
|
||||
e := os.MkdirAll(f.PathURL.Path, 0777)
|
||||
e := os.MkdirAll(f.PathURL.Path, 0o777)
|
||||
if e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
@@ -1009,11 +1008,11 @@ func (f *fsClient) GetAccess(ctx context.Context) (access string, policyJSON str
|
||||
}
|
||||
// Mask with os.ModePerm to get only inode permissions
|
||||
switch st.Mode() & os.ModePerm {
|
||||
case os.FileMode(0777):
|
||||
case os.FileMode(0o777):
|
||||
return "readwrite", "", nil
|
||||
case os.FileMode(0555):
|
||||
case os.FileMode(0o555):
|
||||
return "readonly", "", nil
|
||||
case os.FileMode(0333):
|
||||
case os.FileMode(0o333):
|
||||
return "writeonly", "", nil
|
||||
}
|
||||
return "none", "", nil
|
||||
@@ -1036,13 +1035,13 @@ func (f *fsClient) SetAccess(ctx context.Context, access string, isJSON bool) *p
|
||||
var mode os.FileMode
|
||||
switch access {
|
||||
case "readonly":
|
||||
mode = os.FileMode(0555)
|
||||
mode = os.FileMode(0o555)
|
||||
case "writeonly":
|
||||
mode = os.FileMode(0333)
|
||||
mode = os.FileMode(0o333)
|
||||
case "readwrite":
|
||||
mode = os.FileMode(0777)
|
||||
mode = os.FileMode(0o777)
|
||||
case "none":
|
||||
mode = os.FileMode(0755)
|
||||
mode = os.FileMode(0o755)
|
||||
}
|
||||
e := os.Chmod(f.PathURL.Path, mode)
|
||||
if e != nil {
|
||||
@@ -1205,7 +1204,6 @@ func (f *fsClient) RemoveReplication(ctx context.Context) *probe.Error {
|
||||
API: "RemoveReplication",
|
||||
APIType: "filesystem",
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
// GetReplicationMetrics - Get replication metrics for a given bucket, not implemented.
|
||||
|
||||
@@ -23,11 +23,10 @@ package cmd
|
||||
import (
|
||||
"encoding/hex"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/pkg/xattr"
|
||||
"github.com/rjeczalik/notify"
|
||||
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -286,7 +286,8 @@ func (s *TestSuite) TestGet(c *C) {
|
||||
n, err := fsClient.Put(context.Background(), reader, int64(len(data)), nil, PutOptions{
|
||||
metadata: map[string]string{
|
||||
"Content-Type": "application/octet-stream",
|
||||
}})
|
||||
},
|
||||
})
|
||||
c.Assert(err, IsNil)
|
||||
c.Assert(n, Equals, int64(len(data)))
|
||||
|
||||
@@ -296,7 +297,6 @@ func (s *TestSuite) TestGet(c *C) {
|
||||
_, e = io.Copy(&results, reader)
|
||||
c.Assert(e, IsNil)
|
||||
c.Assert([]byte(data), DeepEquals, results.Bytes())
|
||||
|
||||
}
|
||||
|
||||
// Test get range in a file.
|
||||
|
||||
+20
-13
@@ -440,11 +440,13 @@ func (c *S3Client) ListNotificationConfigs(ctx context.Context, arn string) ([]N
|
||||
continue
|
||||
}
|
||||
prefix, suffix := getFilters(config.Config)
|
||||
configs = append(configs, NotificationConfig{ID: config.ID,
|
||||
configs = append(configs, NotificationConfig{
|
||||
ID: config.ID,
|
||||
Arn: config.Topic,
|
||||
Events: prettyEventNames(config.Events),
|
||||
Prefix: prefix,
|
||||
Suffix: suffix})
|
||||
Suffix: suffix,
|
||||
})
|
||||
}
|
||||
|
||||
for _, config := range mb.QueueConfigs {
|
||||
@@ -452,11 +454,13 @@ func (c *S3Client) ListNotificationConfigs(ctx context.Context, arn string) ([]N
|
||||
continue
|
||||
}
|
||||
prefix, suffix := getFilters(config.Config)
|
||||
configs = append(configs, NotificationConfig{ID: config.ID,
|
||||
configs = append(configs, NotificationConfig{
|
||||
ID: config.ID,
|
||||
Arn: config.Queue,
|
||||
Events: prettyEventNames(config.Events),
|
||||
Prefix: prefix,
|
||||
Suffix: suffix})
|
||||
Suffix: suffix,
|
||||
})
|
||||
}
|
||||
|
||||
for _, config := range mb.LambdaConfigs {
|
||||
@@ -464,11 +468,13 @@ func (c *S3Client) ListNotificationConfigs(ctx context.Context, arn string) ([]N
|
||||
continue
|
||||
}
|
||||
prefix, suffix := getFilters(config.Config)
|
||||
configs = append(configs, NotificationConfig{ID: config.ID,
|
||||
configs = append(configs, NotificationConfig{
|
||||
ID: config.ID,
|
||||
Arn: config.Lambda,
|
||||
Events: prettyEventNames(config.Events),
|
||||
Prefix: prefix,
|
||||
Suffix: suffix})
|
||||
Suffix: suffix,
|
||||
})
|
||||
}
|
||||
|
||||
return configs, nil
|
||||
@@ -646,7 +652,7 @@ func (c *S3Client) Select(ctx context.Context, expression string, sse encrypt.Se
|
||||
}
|
||||
|
||||
func (c *S3Client) notificationToEventsInfo(ninfo notification.Info) []EventInfo {
|
||||
var eventsInfo = make([]EventInfo, len(ninfo.Records))
|
||||
eventsInfo := make([]EventInfo, len(ninfo.Records))
|
||||
for i, record := range ninfo.Records {
|
||||
bucketName := record.S3.Bucket.Name
|
||||
var key string
|
||||
@@ -1115,7 +1121,8 @@ func (c *S3Client) Remove(ctx context.Context, isIncomplete, isRemoveBucket, isB
|
||||
Err: probe.NewError(errors.New(
|
||||
"use `mc rm` command to delete prefixes, or point your" +
|
||||
" bucket directly, `mc rb <alias>/<bucket-name>/`"),
|
||||
)}
|
||||
),
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -1405,7 +1412,7 @@ func (c *S3Client) SetAccess(ctx context.Context, bucketPolicy string, isJSON bo
|
||||
if e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
var p = policy.BucketAccessPolicy{Version: "2012-10-17"}
|
||||
p := policy.BucketAccessPolicy{Version: "2012-10-17"}
|
||||
if policyStr != "" {
|
||||
if e = json.Unmarshal([]byte(policyStr), &p); e != nil {
|
||||
return probe.NewError(e)
|
||||
@@ -1458,7 +1465,7 @@ func (c *S3Client) statIncompleteUpload(ctx context.Context, bucket, object stri
|
||||
objectMetadata.URL = c.targetURL.Clone()
|
||||
objectMetadata.Time = objectMultipartInfo.Initiated
|
||||
objectMetadata.Size = objectMultipartInfo.Size
|
||||
objectMetadata.Type = os.FileMode(0664)
|
||||
objectMetadata.Type = os.FileMode(0o664)
|
||||
objectMetadata.Metadata = map[string]string{}
|
||||
return objectMetadata, nil
|
||||
}
|
||||
@@ -1816,7 +1823,6 @@ func (c *S3Client) versionedList(ctx context.Context, contentCh chan *ClientCont
|
||||
|
||||
noVersioning:
|
||||
c.unversionedList(ctx, contentCh, opts)
|
||||
|
||||
}
|
||||
|
||||
// unversionedList is the non versioned S3 listing
|
||||
@@ -2042,7 +2048,7 @@ func (c *S3Client) objectInfo2ClientContent(bucket string, entry minio.ObjectInf
|
||||
content.Time = time.Now()
|
||||
}
|
||||
} else {
|
||||
content.Type = os.FileMode(0664)
|
||||
content.Type = os.FileMode(0o664)
|
||||
}
|
||||
|
||||
return content
|
||||
@@ -2058,7 +2064,8 @@ func (c *S3Client) bucketStat(ctx context.Context, bucket string) (*ClientConten
|
||||
return nil, probe.NewError(BucketDoesNotExist{Bucket: bucket})
|
||||
}
|
||||
return &ClientContent{
|
||||
URL: c.targetURL.Clone(), BucketName: bucket, Time: time.Unix(0, 0), Type: os.ModeDir}, nil
|
||||
URL: c.targetURL.Clone(), BucketName: bucket, Time: time.Unix(0, 0), Type: os.ModeDir,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (c *S3Client) listInRoutine(ctx context.Context, contentCh chan *ClientContent, opts ListOptions) {
|
||||
|
||||
@@ -96,7 +96,6 @@ type CopyOptions struct {
|
||||
type Client interface {
|
||||
// Common operations
|
||||
Stat(ctx context.Context, opts StatOptions) (content *ClientContent, err *probe.Error)
|
||||
|
||||
List(ctx context.Context, opts ListOptions) <-chan *ClientContent
|
||||
|
||||
// Bucket operations
|
||||
@@ -120,7 +119,6 @@ type Client interface {
|
||||
|
||||
// I/O operations with metadata.
|
||||
Get(ctx context.Context, opts GetOptions) (reader io.ReadCloser, err *probe.Error)
|
||||
|
||||
Put(ctx context.Context, reader io.Reader, size int64, progress io.Reader, opts PutOptions) (n int64, err *probe.Error)
|
||||
|
||||
// Object Locking related API
|
||||
@@ -140,7 +138,6 @@ type Client interface {
|
||||
Remove(ctx context.Context, isIncomplete, isRemoveBucket, isBypass bool, contentCh <-chan *ClientContent) (errorCh <-chan RemoveResult)
|
||||
// GetURL returns back internal url
|
||||
GetURL() ClientURL
|
||||
|
||||
AddUserAgent(app, version string)
|
||||
|
||||
// Tagging operations
|
||||
|
||||
@@ -245,7 +245,7 @@ func getSourceStream(ctx context.Context, alias, urlStr, versionID string, fetch
|
||||
st.Size = oinfo.Size
|
||||
st.ETag = oinfo.ETag
|
||||
st.Expires = oinfo.Expires
|
||||
st.Type = os.FileMode(0664)
|
||||
st.Type = os.FileMode(0o664)
|
||||
st.Metadata = map[string]string{}
|
||||
for k := range oinfo.Metadata {
|
||||
st.Metadata[k] = oinfo.Metadata.Get(k)
|
||||
@@ -347,7 +347,6 @@ func putTargetStreamWithURL(urlStr string, reader io.Reader, size int64, opts Pu
|
||||
|
||||
// copySourceToTargetURL copies to targetURL from source.
|
||||
func copySourceToTargetURL(ctx context.Context, alias, urlStr, source, sourceVersionID, mode, until, legalHold string, size int64, progress io.Reader, opts CopyOptions) *probe.Error {
|
||||
|
||||
targetClnt, err := newClientFromAlias(alias, urlStr)
|
||||
if err != nil {
|
||||
return err.Trace(alias, urlStr)
|
||||
@@ -423,7 +422,7 @@ func uploadSourceToTargetURL(ctx context.Context, urls URLs, progress io.Reader,
|
||||
tgtSSE := getSSE(targetPath, encKeyDB[targetAlias])
|
||||
|
||||
var err *probe.Error
|
||||
var metadata = map[string]string{}
|
||||
metadata := map[string]string{}
|
||||
var mode, until, legalHold string
|
||||
|
||||
// add object retention fields in metadata for target, if target wants
|
||||
|
||||
@@ -30,9 +30,9 @@ func TestGetDecodedKey(t *testing.T) {
|
||||
err error
|
||||
status bool
|
||||
}{
|
||||
//success scenario the key contains non printable (tab) character as key
|
||||
// success scenario the key contains non printable (tab) character as key
|
||||
{"s3/documents/=MzJieXRlc2xvbmdzZWNyZWFiY2RlZmcJZ2l2ZW5uMjE=", "s3/documents/=32byteslongsecreabcdefg givenn21", nil, true},
|
||||
//success scenario the key contains non printable (tab character) as key
|
||||
// success scenario the key contains non printable (tab character) as key
|
||||
{"s3/documents/=MzJieXRlc2xvbmdzZWNyZWFiY2RlZmcJZ2l2ZW5uMjE=,play/documents/=MzJieXRlc2xvbmdzZWNyZXRrZQltdXN0YmVnaXZlbjE=", "s3/documents/=32byteslongsecreabcdefg givenn21,play/documents/=32byteslongsecretke mustbegiven1", nil, true},
|
||||
// success scenario using a normal string
|
||||
{"s3/documents/=32byteslongsecretkeymustbegiven1", "s3/documents/=32byteslongsecretkeymustbegiven1", nil, true},
|
||||
|
||||
@@ -234,7 +234,6 @@ func migrateConfigV3ToV4() {
|
||||
fatalIf(probe.NewError(e), "Unable to save config version `4`.")
|
||||
|
||||
console.Infof("Successfully migrated %s from version `3` to version `4`.\n", mustGetMcConfigPath())
|
||||
|
||||
}
|
||||
|
||||
// Migrate config version `4` to `5`. Rename hostConfigV4.Signature -> hostConfigV5.API.
|
||||
|
||||
@@ -250,6 +250,7 @@ type hostConfigV8 struct {
|
||||
SecretKey string `json:"secretKey"`
|
||||
API string `json:"api"`
|
||||
}
|
||||
|
||||
type configV8 struct {
|
||||
Version string `json:"version"`
|
||||
Hosts map[string]hostConfigV8 `json:"hosts"`
|
||||
|
||||
@@ -34,7 +34,7 @@ func validateConfigVersion(config *configV10) (bool, string) {
|
||||
// Verifies the config file of the MinIO Client
|
||||
func validateConfigFile(config *configV10) (bool, []string) {
|
||||
ok, err := validateConfigVersion(config)
|
||||
var validationSuccessful = true
|
||||
validationSuccessful := true
|
||||
var errors []string
|
||||
if !ok {
|
||||
validationSuccessful = false
|
||||
@@ -52,7 +52,7 @@ func validateConfigFile(config *configV10) (bool, []string) {
|
||||
}
|
||||
|
||||
func validateConfigHost(host aliasConfigV10) (bool, []string) {
|
||||
var validationSuccessful = true
|
||||
validationSuccessful := true
|
||||
var hostErrors []string
|
||||
if !isValidAPI(strings.ToLower(host.API)) {
|
||||
validationSuccessful = false
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ func createMcConfigDir() *probe.Error {
|
||||
if err != nil {
|
||||
return err.Trace()
|
||||
}
|
||||
if e := os.MkdirAll(p, 0700); e != nil {
|
||||
if e := os.MkdirAll(p, 0o700); e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
return nil
|
||||
|
||||
+10
-8
@@ -105,9 +105,11 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
var rmFlag = "retention-mode"
|
||||
var rdFlag = "retention-duration"
|
||||
var lhFlag = "legal-hold"
|
||||
var (
|
||||
rmFlag = "retention-mode"
|
||||
rdFlag = "retention-duration"
|
||||
lhFlag = "legal-hold"
|
||||
)
|
||||
|
||||
// ErrInvalidMetadata reflects invalid metadata format
|
||||
var ErrInvalidMetadata = errors.New("specified metadata should be of form key1=value1;key2=value2;... and so on")
|
||||
@@ -328,7 +330,7 @@ func doPrepareCopyURLs(ctx context.Context, session *sessionV8, cancelCopy conte
|
||||
break
|
||||
}
|
||||
|
||||
var jsoniter = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
jsoniter := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
jsonData, e := jsoniter.Marshal(cpURLs)
|
||||
if e != nil {
|
||||
session.Delete()
|
||||
@@ -363,7 +365,7 @@ func doCopySession(ctx context.Context, cancelCopy context.CancelFunc, cli *cli.
|
||||
var isCopied func(string) bool
|
||||
var totalObjects, totalBytes int64
|
||||
|
||||
var cpURLsCh = make(chan URLs, 10000)
|
||||
cpURLsCh := make(chan URLs, 10000)
|
||||
|
||||
// Store a progress bar or an accounter
|
||||
var pg ProgressReader
|
||||
@@ -401,7 +403,7 @@ func doCopySession(ctx context.Context, cancelCopy context.CancelFunc, cli *cli.
|
||||
pg.SetTotal(totalBytes)
|
||||
|
||||
go func() {
|
||||
var jsoniter = jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
jsoniter := jsoniter.ConfigCompatibleWithStandardLibrary
|
||||
// Prepare URL scanner from session data file.
|
||||
urlScanner := bufio.NewScanner(session.NewDataReader())
|
||||
for {
|
||||
@@ -457,8 +459,8 @@ func doCopySession(ctx context.Context, cancelCopy context.CancelFunc, cli *cli.
|
||||
}()
|
||||
}
|
||||
|
||||
var quitCh = make(chan struct{})
|
||||
var statusCh = make(chan URLs)
|
||||
quitCh := make(chan struct{})
|
||||
statusCh := make(chan URLs)
|
||||
|
||||
parallel := newParallelManager(statusCh)
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ func getMetaDataEntry(metadataString string) (map[string]string, *probe.Error) {
|
||||
for ; ; p++ {
|
||||
ch, _, err := r.ReadRune()
|
||||
if err != nil {
|
||||
//eof
|
||||
// eof
|
||||
if ps == QSTRING || ps == DQSTRING || pt == KEY {
|
||||
return nil, probe.NewError(ErrInvalidMetadata)
|
||||
}
|
||||
|
||||
+6
-6
@@ -39,17 +39,17 @@ func TestParseMetaData(t *testing.T) {
|
||||
{"key1:value1;key2:value2", nil, ErrInvalidMetadata, false},
|
||||
// using no delimiter
|
||||
{"key1:value1:key2:value2", nil, ErrInvalidMetadata, false},
|
||||
//success: use value in quotes
|
||||
// success: use value in quotes
|
||||
{"Content-Disposition='form-data; name=\"description\"'", map[string]string{"Content-Disposition": "form-data; name=\"description\""}, nil, true},
|
||||
//success: use value in double quotes
|
||||
// success: use value in double quotes
|
||||
{"Content-Disposition=\"form-data; name='description'\"", map[string]string{"Content-Disposition": "form-data; name='description'"}, nil, true},
|
||||
//fail: unterminated quote
|
||||
// fail: unterminated quote
|
||||
{"Content-Disposition='form-data; name=\"description\"", nil, ErrInvalidMetadata, false},
|
||||
//fail: unterminated double quote
|
||||
// fail: unterminated double quote
|
||||
{"Content-Disposition=\"form-data; name='description'", nil, ErrInvalidMetadata, false},
|
||||
//success: use value and key in quotes
|
||||
// success: use value and key in quotes
|
||||
{"\"Content-Disposition\"='form-data; name=\"description\"'", map[string]string{"Content-Disposition": "form-data; name=\"description\""}, nil, true},
|
||||
//success: use value and key in quotes
|
||||
// success: use value and key in quotes
|
||||
{"\"Content=Disposition;Other key part=this is also key data\"='form-data; name=\"description\"'", map[string]string{"Content=Disposition;Other key part=this is also key data": "form-data; name=\"description\""}, nil, true},
|
||||
}
|
||||
|
||||
|
||||
@@ -197,7 +197,6 @@ func checkCopySyntaxTypeC(ctx context.Context, srcURLs []string, tgtURL string,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// checkCopySyntaxTypeD verifies if the source is a valid list of files and target is a valid folder.
|
||||
|
||||
@@ -103,7 +103,6 @@ func (d diffMessage) String() string {
|
||||
"Unhandled difference between `"+d.FirstURL+"` and `"+d.SecondURL+"`.")
|
||||
}
|
||||
return msg
|
||||
|
||||
}
|
||||
|
||||
// JSON jsonified diff message
|
||||
|
||||
+1
-3
@@ -176,9 +176,7 @@ func differenceInternal(ctx context.Context, sourceClnt, targetClnt Client, sour
|
||||
srcCtnt, srcOk := <-srcCh
|
||||
tgtCtnt, tgtOk := <-tgtCh
|
||||
|
||||
var (
|
||||
srcEOF, tgtEOF bool
|
||||
)
|
||||
var srcEOF, tgtEOF bool
|
||||
|
||||
for {
|
||||
srcEOF = !srcOk
|
||||
|
||||
+19
-21
@@ -28,27 +28,25 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
eventAddFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "event",
|
||||
Value: "put,delete,get",
|
||||
Usage: "filter specific type of event. Defaults to all event",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "prefix",
|
||||
Usage: "filter event associated to the specified prefix",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "suffix",
|
||||
Usage: "filter event associated to the specified suffix",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "ignore-existing, p",
|
||||
Usage: "ignore if event already exists",
|
||||
},
|
||||
}
|
||||
)
|
||||
var eventAddFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "event",
|
||||
Value: "put,delete,get",
|
||||
Usage: "filter specific type of event. Defaults to all event",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "prefix",
|
||||
Usage: "filter event associated to the specified prefix",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "suffix",
|
||||
Usage: "filter event associated to the specified suffix",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "ignore-existing, p",
|
||||
Usage: "ignore if event already exists",
|
||||
},
|
||||
}
|
||||
|
||||
var eventAddCmd = cli.Command{
|
||||
Name: "add",
|
||||
|
||||
+3
-4
@@ -28,9 +28,7 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
eventListFlags = []cli.Flag{}
|
||||
)
|
||||
var eventListFlags = []cli.Flag{}
|
||||
|
||||
var eventListCmd = cli.Command{
|
||||
Name: "list",
|
||||
@@ -135,7 +133,8 @@ func mainEventList(cliCtx *cli.Context) error {
|
||||
Prefix: config.Prefix,
|
||||
Suffix: config.Suffix,
|
||||
Arn: config.Arn,
|
||||
ID: config.ID})
|
||||
ID: config.ID,
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
+1
-3
@@ -19,9 +19,7 @@ package cmd
|
||||
|
||||
import "github.com/minio/cli"
|
||||
|
||||
var (
|
||||
eventFlags = []cli.Flag{}
|
||||
)
|
||||
var eventFlags = []cli.Flag{}
|
||||
|
||||
var eventSubcommands = []cli.Command{
|
||||
eventAddCmd,
|
||||
|
||||
+19
-21
@@ -28,27 +28,25 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
eventRemoveFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "force",
|
||||
Usage: "force removing all bucket notifications",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "event",
|
||||
Value: "put,delete,get",
|
||||
Usage: "filter specific type of event. Defaults to all event",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "prefix",
|
||||
Usage: "filter event associated to the specified prefix",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "suffix",
|
||||
Usage: "filter event associated to the specified suffix",
|
||||
},
|
||||
}
|
||||
)
|
||||
var eventRemoveFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "force",
|
||||
Usage: "force removing all bucket notifications",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "event",
|
||||
Value: "put,delete,get",
|
||||
Usage: "filter specific type of event. Defaults to all event",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "prefix",
|
||||
Usage: "filter event associated to the specified prefix",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "suffix",
|
||||
Usage: "filter event associated to the specified suffix",
|
||||
},
|
||||
}
|
||||
|
||||
var eventRemoveCmd = cli.Command{
|
||||
Name: "remove",
|
||||
|
||||
+8
-6
@@ -31,7 +31,7 @@ import (
|
||||
func TestMatchFind(t *testing.T) {
|
||||
// List of various contexts used in each tests,
|
||||
// tests are run in the same order as this list.
|
||||
var listFindContexts = []*findContext{
|
||||
listFindContexts := []*findContext{
|
||||
{
|
||||
clnt: &S3Client{
|
||||
targetURL: &ClientURL{},
|
||||
@@ -93,7 +93,7 @@ func TestMatchFind(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
var testCases = []struct {
|
||||
testCases := []struct {
|
||||
content contentMessage
|
||||
expectedMatch bool
|
||||
}{
|
||||
@@ -178,7 +178,7 @@ func TestMatchFind(t *testing.T) {
|
||||
|
||||
// Tests suffix strings trimmed off correctly at maxdepth.
|
||||
func TestSuffixTrimmingAtMaxDepth(t *testing.T) {
|
||||
var testCases = []struct {
|
||||
testCases := []struct {
|
||||
startPrefix string
|
||||
path string
|
||||
separator string
|
||||
@@ -268,7 +268,7 @@ func TestFindMatch(t *testing.T) {
|
||||
match bool
|
||||
}
|
||||
|
||||
var basicTests = []testFind{
|
||||
basicTests := []testFind{
|
||||
// Name match tests - success cases.
|
||||
{"*.jpg", "carter.jpg", "name", true},
|
||||
{"console", "pkg/console/console.go", "name", true},
|
||||
@@ -285,8 +285,10 @@ func TestFindMatch(t *testing.T) {
|
||||
{"*test/*", "bob/likes/test/cake", "name", false},
|
||||
{"*/test/*", "bob/likes/cake/test", "name", false},
|
||||
{"*.jpg", ".jpg/elves/are/evil", "name", false},
|
||||
{"wq3YgNiB2ILYg9iE2IXYnNud3I/hoI7igIvigIzigI3igI7igI/igKrigKvigKzigK3igK7igaDi",
|
||||
"An/Even/Bigger/String/wq3YgNiB2ILYg9iE2IXYnNud3I/hoI7igIvigIzigI3igI7igI/igKrigKvigKzigK3igK7igaDi", "name", false},
|
||||
{
|
||||
"wq3YgNiB2ILYg9iE2IXYnNud3I/hoI7igIvigIzigI3igI7igI/igKrigKvigKzigK3igK7igaDi",
|
||||
"An/Even/Bigger/String/wq3YgNiB2ILYg9iE2IXYnNud3I/hoI7igIvigIzigI3igI7igI/igKrigKvigKzigK3igK7igaDi", "name", false,
|
||||
},
|
||||
{"𝕿𝖍𝖊", "well/this/isAN/odd/font/THE", "name", false},
|
||||
{"𝕿𝖍𝖊", "well/this/isAN/odd/font/The", "name", false},
|
||||
{"𝕿𝖍𝖊", "well/this/isAN/odd/font/𝓣𝓱𝓮", "name", false},
|
||||
|
||||
+15
-17
@@ -33,23 +33,21 @@ import (
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
var (
|
||||
headFlags = []cli.Flag{
|
||||
cli.Int64Flag{
|
||||
Name: "n,lines",
|
||||
Usage: "print the first 'n' lines",
|
||||
Value: 10,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "select an object version at specified time",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "select an object version to display",
|
||||
},
|
||||
}
|
||||
)
|
||||
var headFlags = []cli.Flag{
|
||||
cli.Int64Flag{
|
||||
Name: "n,lines",
|
||||
Usage: "print the first 'n' lines",
|
||||
Value: 10,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "select an object version at specified time",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "select an object version to display",
|
||||
},
|
||||
}
|
||||
|
||||
// Display contents of a file.
|
||||
var headCmd = cli.Command{
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ func (i ilmImportMessage) JSON() string {
|
||||
// readILMConfig read from stdin, returns XML.
|
||||
func readILMConfig() (*lifecycle.Configuration, *probe.Error) {
|
||||
// User is expected to enter the lifecycleConfiguration instance contents in JSON format
|
||||
var cfg = lifecycle.NewConfiguration()
|
||||
cfg := lifecycle.NewConfiguration()
|
||||
|
||||
// Consume json from STDIN
|
||||
dec := json.NewDecoder(os.Stdin)
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ func (i ilmListMessage) JSON() string {
|
||||
|
||||
// validateILMListFlagSet - Only one of these flags needs to be set for display: --json, --expiry, --transition
|
||||
func validateILMListFlagSet(ctx *cli.Context) bool {
|
||||
var flags = [...]bool{ctx.Bool("expiry"), ctx.Bool("transition"), ctx.Bool("json")}
|
||||
flags := [...]bool{ctx.Bool("expiry"), ctx.Bool("transition"), ctx.Bool("json")}
|
||||
found := false
|
||||
for _, flag := range flags {
|
||||
if found && flag {
|
||||
|
||||
+3
-3
@@ -311,10 +311,10 @@ func mainILMRestore(cliCtx *cli.Context) (cErr error) {
|
||||
fatalIf(errDummy().Trace(), "Unable to restore the given URL")
|
||||
}
|
||||
|
||||
var restoreReqStatus = make(chan *probe.Error)
|
||||
var restoreStatus = make(chan *probe.Error)
|
||||
restoreReqStatus := make(chan *probe.Error)
|
||||
restoreStatus := make(chan *probe.Error)
|
||||
|
||||
var done = make(chan struct{})
|
||||
done := make(chan struct{})
|
||||
|
||||
go func() {
|
||||
showRestoreStatus(restoreReqStatus, restoreStatus, done)
|
||||
|
||||
@@ -104,8 +104,8 @@ type showDetails struct {
|
||||
// table with information. Table is constructed row-by-row. Headers are first, then the rest of the rows.
|
||||
func PopulateILMDataForDisplay(ilmCfg *lifecycle.Configuration, rowCheck *map[string]int, alignedHdrLabels *[]string,
|
||||
cellDataNoTags *[][]string, cellDataWithTags *[][]string, tagRows *map[string][]string,
|
||||
showAll, showExpiry, showTransition bool) {
|
||||
|
||||
showAll, showExpiry, showTransition bool,
|
||||
) {
|
||||
// We need the different column headers and their respective column index
|
||||
// where they appear in a map data-structure format.
|
||||
// [Column Label] -> [Column Number]
|
||||
@@ -412,7 +412,6 @@ func showExpiryDetails(rule lifecycle.Rule, showOpts showDetails) bool {
|
||||
expirySet := !rule.Expiration.IsNull()
|
||||
|
||||
return (expirySet && (showOpts.allAvailable || showOpts.expiry))
|
||||
|
||||
}
|
||||
|
||||
func showExpTick(showOpts showDetails) bool {
|
||||
|
||||
+18
-20
@@ -27,26 +27,24 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
lhClearFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "clear legal hold recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "clear legal hold of a specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "clear legal hold on an object version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "clear legal hold on multiple versions of object(s)",
|
||||
},
|
||||
}
|
||||
)
|
||||
var lhClearFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "clear legal hold recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "clear legal hold of a specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "clear legal hold on an object version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "clear legal hold on multiple versions of object(s)",
|
||||
},
|
||||
}
|
||||
|
||||
var legalHoldClearCmd = cli.Command{
|
||||
Name: "clear",
|
||||
|
||||
+19
-20
@@ -32,26 +32,25 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
lhInfoFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "show legal hold status recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "show legal hold status of a specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "show legal hold status of an object version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "show legal hold status of multiple versions of object(s)",
|
||||
},
|
||||
}
|
||||
)
|
||||
var lhInfoFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "show legal hold status recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "show legal hold status of a specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "show legal hold status of an object version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "show legal hold status of multiple versions of object(s)",
|
||||
},
|
||||
}
|
||||
|
||||
var legalHoldInfoCmd = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "show legal hold info for object(s)",
|
||||
|
||||
@@ -80,8 +80,10 @@ func (l legalHoldCmdMessage) JSON() string {
|
||||
return string(msgBytes)
|
||||
}
|
||||
|
||||
var errBucketLockConfigNotFound = errors.New("bucket lock config not found")
|
||||
var errBucketLockNotSupported = errors.New("bucket lock not supported")
|
||||
var (
|
||||
errBucketLockConfigNotFound = errors.New("bucket lock config not found")
|
||||
errBucketLockNotSupported = errors.New("bucket lock not supported")
|
||||
)
|
||||
|
||||
func isBucketLockEnabled(ctx context.Context, aliasedURL string) (bool, *probe.Error) {
|
||||
st, err := getBucketLockStatus(ctx, aliasedURL)
|
||||
|
||||
+19
-21
@@ -30,26 +30,25 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
lhSetFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "apply legal hold recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "apply legal hold to a specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "apply legal hold on an object version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "apply legal hold on multiple versions of an object",
|
||||
},
|
||||
}
|
||||
)
|
||||
var lhSetFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "apply legal hold recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "apply legal hold to a specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "apply legal hold on an object version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "apply legal hold on multiple versions of an object",
|
||||
},
|
||||
}
|
||||
|
||||
var legalHoldSetCmd = cli.Command{
|
||||
Name: "set",
|
||||
Usage: "set legal hold for object(s)",
|
||||
@@ -84,7 +83,6 @@ EXAMPLES:
|
||||
|
||||
// setLegalHold - Set legalhold for all objects within a given prefix.
|
||||
func setLegalHold(ctx context.Context, urlStr, versionID string, timeRef time.Time, withOlderVersions, recursive bool, lhold minio.LegalHoldStatus) error {
|
||||
|
||||
clnt, err := newClient(urlStr)
|
||||
if err != nil {
|
||||
fatalIf(err.Trace(), "Unable to parse the provided url.")
|
||||
|
||||
@@ -196,7 +196,6 @@ func printObjectVersions(clntURL ClientURL, ctntVersions []*ClientContent, print
|
||||
|
||||
// doList - list all entities inside a folder.
|
||||
func doList(ctx context.Context, clnt Client, isRecursive, isIncomplete, isSummary bool, timeRef time.Time, withOlderVersions bool) error {
|
||||
|
||||
var (
|
||||
lastPath string
|
||||
perObjectVersions []*ClientContent
|
||||
|
||||
+9
-13
@@ -45,15 +45,13 @@ import (
|
||||
completeinstall "github.com/posener/complete/cmd/install"
|
||||
)
|
||||
|
||||
var (
|
||||
// global flags for mc.
|
||||
mcFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "autocompletion",
|
||||
Usage: "install auto-completion for your shell",
|
||||
},
|
||||
}
|
||||
)
|
||||
// global flags for mc.
|
||||
var mcFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "autocompletion",
|
||||
Usage: "install auto-completion for your shell",
|
||||
},
|
||||
}
|
||||
|
||||
// Help template for mc
|
||||
var mcHelpTemplate = `NAME:
|
||||
@@ -96,7 +94,6 @@ func init() {
|
||||
|
||||
// Main starts mc application
|
||||
func Main(args []string) {
|
||||
|
||||
if len(args) > 1 {
|
||||
switch args[1] {
|
||||
case "mc", filepath.Base(args[0]):
|
||||
@@ -153,7 +150,7 @@ func onUsageError(ctx *cli.Context, err error, subcommand bool) error {
|
||||
|
||||
// Calculate the maximum width of the flag name field
|
||||
// for a good looking printing
|
||||
var help = make([]subCommandHelp, len(ctx.Command.Flags))
|
||||
help := make([]subCommandHelp, len(ctx.Command.Flags))
|
||||
maxWidth := 0
|
||||
for i, f := range ctx.Command.Flags {
|
||||
s := strings.Split(f.String(), "\t")
|
||||
@@ -187,7 +184,7 @@ func commandNotFound(ctx *cli.Context, cmds []cli.Command) {
|
||||
return
|
||||
}
|
||||
msg := fmt.Sprintf("`%s` is not a recognized command. Get help using `--help` flag.", command)
|
||||
var commandsTree = trie.NewTrie()
|
||||
commandsTree := trie.NewTrie()
|
||||
for _, cmd := range cmds {
|
||||
commandsTree.Insert(cmd.Name)
|
||||
}
|
||||
@@ -300,7 +297,6 @@ func initMC() {
|
||||
|
||||
// Load all authority certificates present in CAs dir
|
||||
loadRootCAs()
|
||||
|
||||
}
|
||||
|
||||
func installAutoCompletion() {
|
||||
|
||||
+15
-18
@@ -27,23 +27,21 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
mbFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "region",
|
||||
Value: "us-east-1",
|
||||
Usage: "specify bucket region; defaults to 'us-east-1'",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "ignore-existing, p",
|
||||
Usage: "ignore if bucket/directory already exists",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "with-lock, l",
|
||||
Usage: "enable object lock",
|
||||
},
|
||||
}
|
||||
)
|
||||
var mbFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "region",
|
||||
Value: "us-east-1",
|
||||
Usage: "specify bucket region; defaults to 'us-east-1'",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "ignore-existing, p",
|
||||
Usage: "ignore if bucket/directory already exists",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "with-lock, l",
|
||||
Usage: "enable object lock",
|
||||
},
|
||||
}
|
||||
|
||||
// make a bucket.
|
||||
var mbCmd = cli.Command{
|
||||
@@ -115,7 +113,6 @@ func checkMakeBucketSyntax(cliCtx *cli.Context) {
|
||||
|
||||
// mainMakeBucket is entry point for mb command.
|
||||
func mainMakeBucket(cli *cli.Context) error {
|
||||
|
||||
// check 'mb' cli arguments.
|
||||
checkMakeBucketSyntax(cli)
|
||||
|
||||
|
||||
+2
-5
@@ -313,7 +313,7 @@ func (mj *mirrorJob) doDeleteBucket(ctx context.Context, sURLs URLs) URLs {
|
||||
return sURLs.WithError(pErr)
|
||||
}
|
||||
|
||||
var contentCh = make(chan *ClientContent, 1)
|
||||
contentCh := make(chan *ClientContent, 1)
|
||||
contentCh <- &ClientContent{URL: clnt.GetURL()}
|
||||
close(contentCh)
|
||||
|
||||
@@ -407,7 +407,6 @@ func convertSizeToTag(size int64) string {
|
||||
|
||||
// doMirror - Mirror an object to multiple destination. URLs status contains a copy of sURLs and error if any.
|
||||
func (mj *mirrorJob) doMirror(ctx context.Context, sURLs URLs) URLs {
|
||||
|
||||
if sURLs.Error != nil { // Erroneous sURLs passed.
|
||||
return sURLs.WithError(sURLs.Error.Trace())
|
||||
}
|
||||
@@ -553,7 +552,7 @@ func (mj *mirrorJob) watchMirrorEvents(ctx context.Context, events []EventInfo)
|
||||
// build target path, it is the relative of the eventPath with the sourceUrl
|
||||
// joined to the targetURL.
|
||||
sourceSuffix := strings.TrimPrefix(eventPath, sourceURLFull)
|
||||
//Skip the object, if it matches the Exclude options provided
|
||||
// Skip the object, if it matches the Exclude options provided
|
||||
if matchExcludeOptions(mj.opts.excludeOptions, sourceSuffix) {
|
||||
continue
|
||||
}
|
||||
@@ -736,7 +735,6 @@ func (mj *mirrorJob) startMirror(ctx context.Context, cancelMirror context.Cance
|
||||
|
||||
// when using a struct for copying, we could save a lot of passing of variables
|
||||
func (mj *mirrorJob) mirror(ctx context.Context, cancelMirror context.CancelFunc) bool {
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
// Starts watcher loop for watching for new events.
|
||||
@@ -1010,7 +1008,6 @@ func mainMirror(cliCtx *cli.Context) error {
|
||||
if e := http.ListenAndServe(prometheusAddress, nil); e != nil {
|
||||
fatalIf(probe.NewError(e), "Unable to setup monitoring endpoint.")
|
||||
}
|
||||
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ func checkMirrorSyntax(ctx context.Context, cliCtx *cli.Context, encKeyDB map[st
|
||||
}
|
||||
|
||||
if srcClient.Type == fileSystem && !filepath.IsAbs(srcURL) {
|
||||
var origSrcURL = srcURL
|
||||
origSrcURL := srcURL
|
||||
var e error
|
||||
// Changing relative path to absolute path, if it is a local directory.
|
||||
// Save original in case of error
|
||||
|
||||
@@ -248,7 +248,6 @@ func availableMemory() (available uint64) {
|
||||
if available != 9223372036854771712 {
|
||||
// This means cgroup memory limit is configured.
|
||||
return
|
||||
|
||||
} // no-limit set proceed to set the limits based on virtual memory.
|
||||
|
||||
} // for all other platforms limits are based on virtual memory.
|
||||
|
||||
+19
-21
@@ -25,26 +25,24 @@ import (
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
var (
|
||||
pipeFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "encrypt",
|
||||
Usage: "encrypt objects (using server-side encryption with server managed keys)",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "storage-class, sc",
|
||||
Usage: "set storage class for new object(s) on target",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "attr",
|
||||
Usage: "add custom metadata for the object",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "tags",
|
||||
Usage: "apply one or more tags to the uploaded objects",
|
||||
},
|
||||
}
|
||||
)
|
||||
var pipeFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "encrypt",
|
||||
Usage: "encrypt objects (using server-side encryption with server managed keys)",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "storage-class, sc",
|
||||
Usage: "set storage class for new object(s) on target",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "attr",
|
||||
Usage: "add custom metadata for the object",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "tags",
|
||||
Usage: "apply one or more tags to the uploaded objects",
|
||||
},
|
||||
}
|
||||
|
||||
// Display contents of a file.
|
||||
var pipeCmd = cli.Command{
|
||||
@@ -135,7 +133,7 @@ func mainPipe(ctx *cli.Context) error {
|
||||
// validate pipe input arguments.
|
||||
checkPipeSyntax(ctx)
|
||||
|
||||
var meta = map[string]string{}
|
||||
meta := map[string]string{}
|
||||
if attr := ctx.String("attr"); attr != "" {
|
||||
meta, err = getMetaDataEntry(attr)
|
||||
fatalIf(err.Trace(attr), "Unable to parse --attr value")
|
||||
|
||||
@@ -36,7 +36,6 @@ import "github.com/rjeczalik/notify"
|
||||
|
||||
// PipeChan builds a new dynamically sized channel
|
||||
func PipeChan(capacity int) (inputCh chan notify.EventInfo, outputCh chan notify.EventInfo) {
|
||||
|
||||
// A set of channels which store all elements received from input
|
||||
channels := make(chan chan notify.EventInfo, 1000)
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import (
|
||||
)
|
||||
|
||||
func testPipeChan(inputCh, outputCh chan notify.EventInfo, totalMsgs int) error {
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
msgCtnt := notify.EventInfo(nil)
|
||||
|
||||
+6
-8
@@ -29,14 +29,12 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
policyFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "list recursively",
|
||||
},
|
||||
}
|
||||
)
|
||||
var policyFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "list recursively",
|
||||
},
|
||||
}
|
||||
|
||||
// Manage anonymous access to buckets and objects.
|
||||
var policyCmd = cli.Command{
|
||||
|
||||
@@ -55,7 +55,6 @@ func newPrettyRecord(indent int, rows ...Row) PrettyRecord {
|
||||
// buildRecord - creates a string which represents a record table given
|
||||
// some fields contents.
|
||||
func (t PrettyRecord) buildRecord(contents ...string) (line string) {
|
||||
|
||||
// totalRows is the minimum of the number of fields config
|
||||
// and the number of contents elements.
|
||||
totalRows := len(contents)
|
||||
|
||||
@@ -21,7 +21,6 @@ import "testing"
|
||||
|
||||
// TestPrettyTable - testing the behavior of the pretty table module
|
||||
func TestPrettyTable(t *testing.T) {
|
||||
|
||||
testCases := []struct {
|
||||
sep string
|
||||
tf []Field
|
||||
|
||||
+1
-1
@@ -173,7 +173,7 @@ func cursorAnimate() <-chan string {
|
||||
// cursors = "←↖↑↗→↘↓↙"
|
||||
// cursors = "◴◷◶◵"
|
||||
// cursors = "◰◳◲◱"
|
||||
//cursors = "⣾⣽⣻⢿⡿⣟⣯⣷"
|
||||
// cursors = "⣾⣽⣻⢿⡿⣟⣯⣷"
|
||||
case "darwin":
|
||||
cursors = "◐◓◑◒"
|
||||
default:
|
||||
|
||||
+11
-13
@@ -32,18 +32,16 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
rbFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "force",
|
||||
Usage: "force a recursive remove operation on all object versions",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "dangerous",
|
||||
Usage: "allow site-wide removal of objects",
|
||||
},
|
||||
}
|
||||
)
|
||||
var rbFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "force",
|
||||
Usage: "force a recursive remove operation on all object versions",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "dangerous",
|
||||
Usage: "allow site-wide removal of objects",
|
||||
},
|
||||
}
|
||||
|
||||
// remove a bucket.
|
||||
var rbCmd = cli.Command{
|
||||
@@ -219,7 +217,7 @@ func deleteBucket(ctx context.Context, url string, isForce bool) *probe.Error {
|
||||
// is not qualified by bucket
|
||||
func isS3NamespaceRemoval(ctx context.Context, url string) bool {
|
||||
// clean path for aliases like s3/.
|
||||
//Note: UNC path using / works properly in go 1.9.2 even though it breaks the UNC specification.
|
||||
// Note: UNC path using / works properly in go 1.9.2 even though it breaks the UNC specification.
|
||||
url = filepath.ToSlash(filepath.Clean(url))
|
||||
// namespace removal applies only for non FS. So filter out if passed url represents a directory
|
||||
_, path := url2Alias(url)
|
||||
|
||||
@@ -82,7 +82,7 @@ func (r replicateImportMessage) String() string {
|
||||
// readReplicationConfig read from stdin, returns XML.
|
||||
func readReplicationConfig() (*replication.Config, *probe.Error) {
|
||||
// User is expected to enter the replication configuration in JSON format
|
||||
var cfg = replication.Config{}
|
||||
cfg := replication.Config{}
|
||||
|
||||
// Consume json from STDIN
|
||||
dec := json.NewDecoder(os.Stdin)
|
||||
|
||||
@@ -66,6 +66,7 @@ func checkReplicateListSyntax(ctx *cli.Context) {
|
||||
cli.ShowCommandHelpAndExit(ctx, "ls", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func printReplicateListHeader() {
|
||||
if globalJSON {
|
||||
return
|
||||
|
||||
@@ -99,7 +99,6 @@ func (r replicateResetMessage) String() string {
|
||||
return console.Colorize("replicateResetMessage", fmt.Sprintf("Replication reset started for %s with ID %s", r.URL, r.ResyncTargetsInfo.Targets[0].ResetID))
|
||||
}
|
||||
return console.Colorize("replicateResetMessage", fmt.Sprintf("Replication reset started for %s", r.URL))
|
||||
|
||||
}
|
||||
|
||||
func mainReplicateReset(cliCtx *cli.Context) error {
|
||||
|
||||
@@ -79,8 +79,8 @@ func (s replicateStatusMessage) String() string {
|
||||
var contents [][]string
|
||||
|
||||
var rows string
|
||||
var arntheme = []string{"Headers"}
|
||||
var theme = []string{"Pending", "Failed", "Replicated", "Replica"}
|
||||
arntheme := []string{"Headers"}
|
||||
theme := []string{"Pending", "Failed", "Replicated", "Replica"}
|
||||
contents = append(contents, []string{"Pending", humanize.IBytes(s.ReplicationStatus.PendingSize), humanize.Comma(int64(s.ReplicationStatus.PendingCount))})
|
||||
contents = append(contents, []string{"Failed", humanize.IBytes(s.ReplicationStatus.FailedSize), humanize.Comma(int64(s.ReplicationStatus.FailedCount))})
|
||||
contents = append(contents, []string{"Replicated", humanize.IBytes(s.ReplicationStatus.ReplicatedSize), ""})
|
||||
|
||||
+22
-24
@@ -27,30 +27,28 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
retentionClearFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "clear retention recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "clear retention of a specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "roll back object(s) to current version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "clear retention of object(s) and all its versions",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "default",
|
||||
Usage: "set default bucket locking",
|
||||
},
|
||||
}
|
||||
)
|
||||
var retentionClearFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "clear retention recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "clear retention of a specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "roll back object(s) to current version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "clear retention of object(s) and all its versions",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "default",
|
||||
Usage: "set default bucket locking",
|
||||
},
|
||||
}
|
||||
|
||||
var retentionClearCmd = cli.Command{
|
||||
Name: "clear",
|
||||
|
||||
@@ -208,7 +208,6 @@ func applyRetention(ctx context.Context, op lockOpType, target, versionID string
|
||||
timeStr, err := getRetainUntilDate(validity, unit)
|
||||
if err != nil {
|
||||
return err.ToGoError()
|
||||
|
||||
}
|
||||
var e error
|
||||
until, e = time.Parse(time.RFC3339, timeStr)
|
||||
|
||||
+24
-25
@@ -31,30 +31,28 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
retentionInfoFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "show retention info recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "show retention info of specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "roll back object(s) to current version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "show retention info on object(s) and all its versions",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "default",
|
||||
Usage: "show bucket default retention mode",
|
||||
},
|
||||
}
|
||||
)
|
||||
var retentionInfoFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "show retention info recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "show retention info of specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "roll back object(s) to current version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "show retention info on object(s) and all its versions",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "default",
|
||||
Usage: "show bucket default retention mode",
|
||||
},
|
||||
}
|
||||
|
||||
var retentionInfoCmd = cli.Command{
|
||||
Name: "info",
|
||||
@@ -88,7 +86,8 @@ EXAMPLES:
|
||||
|
||||
5. Show default lock retention configuration for a bucket
|
||||
$ {{.HelpName}} myminio/mybucket/ --default
|
||||
`}
|
||||
`,
|
||||
}
|
||||
|
||||
func parseInfoRetentionArgs(cliCtx *cli.Context) (target, versionID string, recursive bool, timeRef time.Time, withVersions, defaultMode bool) {
|
||||
args := cliCtx.Args()
|
||||
|
||||
+28
-29
@@ -29,34 +29,32 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
retentionSetFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "apply retention recursively",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "bypass",
|
||||
Usage: "bypass governance",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "apply retention to a specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "roll back object(s) to current version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "apply retention object(s) and all its versions",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "default",
|
||||
Usage: "set bucket default retention mode",
|
||||
},
|
||||
}
|
||||
)
|
||||
var retentionSetFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "apply retention recursively",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "bypass",
|
||||
Usage: "bypass governance",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "apply retention to a specific object version",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "rewind",
|
||||
Usage: "roll back object(s) to current version at specified time",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "versions",
|
||||
Usage: "apply retention object(s) and all its versions",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "default",
|
||||
Usage: "set bucket default retention mode",
|
||||
},
|
||||
}
|
||||
|
||||
var retentionSetCmd = cli.Command{
|
||||
Name: "set",
|
||||
@@ -92,7 +90,8 @@ EXAMPLES:
|
||||
|
||||
5. Set default lock retention configuration for a bucket
|
||||
$ {{.HelpName}} --default governance 30d myminio/mybucket/
|
||||
`}
|
||||
`,
|
||||
}
|
||||
|
||||
func parseSetRetentionArgs(cliCtx *cli.Context) (target, versionID string, recursive bool, timeRef time.Time, withVersions bool, mode minio.RetentionMode, validity uint64, unit minio.ValidityUnit, bypass, bucketMode bool) {
|
||||
args := cliCtx.Args()
|
||||
|
||||
@@ -252,7 +252,6 @@ func checkRmSyntax(ctx context.Context, cliCtx *cli.Context, encKeyDB map[string
|
||||
fatalIf(errDummy().Trace(),
|
||||
"This operation results in site-wide removal of objects. If you are really sure, retry this command with ‘--dangerous’ and ‘--force’ flags.")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Remove a single object or a single version in a versioned bucket
|
||||
|
||||
+1
-1
@@ -262,7 +262,7 @@ func (s *sessionV8) isModified(sessionFile string) (bool, *probe.Error) {
|
||||
return false, probe.NewError(e).Trace(s.SessionID)
|
||||
}
|
||||
|
||||
var currentHeader = &sessionV8Header{}
|
||||
currentHeader := &sessionV8Header{}
|
||||
currentQS, e := quick.LoadConfig(sessionFile, nil, currentHeader)
|
||||
if e != nil {
|
||||
// If session does not exist for the first, return modified to
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ func createSessionDir() *probe.Error {
|
||||
return err.Trace()
|
||||
}
|
||||
|
||||
if e := os.MkdirAll(sessionDir, 0700); e != nil {
|
||||
if e := os.MkdirAll(sessionDir, 0o700); e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
return nil
|
||||
|
||||
+11
-13
@@ -26,19 +26,17 @@ import (
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
var (
|
||||
shareDownloadFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "share all objects recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "share a particular object version",
|
||||
},
|
||||
shareFlagExpire,
|
||||
}
|
||||
)
|
||||
var shareDownloadFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "share all objects recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "version-id, vid",
|
||||
Usage: "share a particular object version",
|
||||
},
|
||||
shareFlagExpire,
|
||||
}
|
||||
|
||||
// Share documents via URL.
|
||||
var shareDownload = cli.Command{
|
||||
|
||||
@@ -25,9 +25,7 @@ import (
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
var (
|
||||
shareListFlags = []cli.Flag{}
|
||||
)
|
||||
var shareListFlags = []cli.Flag{}
|
||||
|
||||
// Share documents via URL.
|
||||
var shareList = cli.Command{
|
||||
@@ -105,7 +103,6 @@ func doShareList(cmd string) *probe.Error {
|
||||
|
||||
// main entry point for share list.
|
||||
func mainShareList(ctx *cli.Context) error {
|
||||
|
||||
// validate command-line args.
|
||||
checkShareListSyntax(ctx)
|
||||
|
||||
|
||||
+1
-3
@@ -26,9 +26,7 @@ import (
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var (
|
||||
shareFlags = []cli.Flag{}
|
||||
)
|
||||
var shareFlags = []cli.Flag{}
|
||||
|
||||
var shareSubcommands = []cli.Command{
|
||||
shareDownload,
|
||||
|
||||
@@ -27,16 +27,14 @@ import (
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
var (
|
||||
shareUploadFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "recursively upload any object matching the prefix",
|
||||
},
|
||||
shareFlagExpire,
|
||||
shareFlagContentType,
|
||||
}
|
||||
)
|
||||
var shareUploadFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "recursively upload any object matching the prefix",
|
||||
},
|
||||
shareFlagExpire,
|
||||
shareFlagContentType,
|
||||
}
|
||||
|
||||
// Share documents via URL.
|
||||
var shareUpload = cli.Command{
|
||||
|
||||
+1
-1
@@ -131,7 +131,7 @@ func isShareDirExists() bool {
|
||||
|
||||
// Create config share dir.
|
||||
func createShareDir() *probe.Error {
|
||||
if e := os.MkdirAll(mustGetShareDir(), 0700); e != nil {
|
||||
if e := os.MkdirAll(mustGetShareDir(), 0o700); e != nil {
|
||||
return probe.NewError(e)
|
||||
}
|
||||
return nil
|
||||
|
||||
+36
-38
@@ -38,43 +38,41 @@ import (
|
||||
"github.com/minio/pkg/mimedb"
|
||||
)
|
||||
|
||||
var (
|
||||
sqlFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "query, e",
|
||||
Usage: "sql query expression",
|
||||
Value: "select * from s3object",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "sql query recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "csv-input",
|
||||
Usage: "csv input serialization option",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "json-input",
|
||||
Usage: "json input serialization option",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "compression",
|
||||
Usage: "input compression type",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "csv-output",
|
||||
Usage: "csv output serialization option",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "csv-output-header",
|
||||
Usage: "optional csv output header ",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "json-output",
|
||||
Usage: "json output serialization option",
|
||||
},
|
||||
}
|
||||
)
|
||||
var sqlFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "query, e",
|
||||
Usage: "sql query expression",
|
||||
Value: "select * from s3object",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "sql query recursively",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "csv-input",
|
||||
Usage: "csv input serialization option",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "json-input",
|
||||
Usage: "json input serialization option",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "compression",
|
||||
Usage: "input compression type",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "csv-output",
|
||||
Usage: "csv output serialization option",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "csv-output-header",
|
||||
Usage: "optional csv output header ",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "json-output",
|
||||
Usage: "json output serialization option",
|
||||
},
|
||||
}
|
||||
|
||||
// Display contents of a file.
|
||||
var sqlCmd = cli.Command{
|
||||
@@ -174,7 +172,7 @@ func parseKVArgs(is string) (map[string]string, *probe.Error) {
|
||||
e++
|
||||
}
|
||||
}
|
||||
var vEnd = len(is)
|
||||
vEnd := len(is)
|
||||
if e != -1 {
|
||||
vEnd = s + e
|
||||
}
|
||||
|
||||
+18
-10
@@ -61,55 +61,64 @@ var testParseSerializationCases = []struct {
|
||||
parsedOpts map[string]string
|
||||
errMsg string
|
||||
}{
|
||||
{"rd=\n,fd=;,qc=\"",
|
||||
{
|
||||
"rd=\n,fd=;,qc=\"",
|
||||
append(validCSVCommonKeys, validCSVInputKeys...),
|
||||
validCSVInputAbbrKeys,
|
||||
map[string]string{"recorddelimiter": "\n", "fielddelimiter": ";", "quotechar": "\""},
|
||||
"<nil>",
|
||||
},
|
||||
{"rd=\n,fd=;,qc=\"",
|
||||
{
|
||||
"rd=\n,fd=;,qc=\"",
|
||||
validCSVInputKeys,
|
||||
validCSVInputAbbrKeys,
|
||||
map[string]string{},
|
||||
"Options should be key-value pairs in the form key=value,... where valid key(s) are ",
|
||||
},
|
||||
{"nokey=\n,fd=;,qc=\"",
|
||||
{
|
||||
"nokey=\n,fd=;,qc=\"",
|
||||
validCSVInputKeys,
|
||||
validCSVInputAbbrKeys,
|
||||
map[string]string{},
|
||||
"Options should be key-value pairs in the form key=value,... where valid key(s) are ",
|
||||
},
|
||||
{"rd=\n\n,fd=|,qc=\",qc='",
|
||||
{
|
||||
"rd=\n\n,fd=|,qc=\",qc='",
|
||||
validCSVInputKeys,
|
||||
validCSVInputAbbrKeys,
|
||||
map[string]string{},
|
||||
"More than one key=value found for ",
|
||||
},
|
||||
{"recordDelimiter=\n\n,FieldDelimiter=|,QuoteChAR=\"",
|
||||
{
|
||||
"recordDelimiter=\n\n,FieldDelimiter=|,QuoteChAR=\"",
|
||||
append(validCSVCommonKeys, validCSVInputKeys...),
|
||||
validCSVInputAbbrKeys,
|
||||
map[string]string{"recorddelimiter": "\n\n", "fielddelimiter": "|", "quotechar": "\""},
|
||||
"<nil>",
|
||||
},
|
||||
{"recordDelimiter=\n\n,FieldDelimiter=|,QuoteChAR=\",fh=use,qrd=;",
|
||||
{
|
||||
"recordDelimiter=\n\n,FieldDelimiter=|,QuoteChAR=\",fh=use,qrd=;",
|
||||
append(validCSVCommonKeys, validCSVInputKeys...),
|
||||
validCSVInputAbbrKeys,
|
||||
map[string]string{"recorddelimiter": "\n\n", "fielddelimiter": "|", "quotechar": "\"", "quotedrecorddelimiter": ";", "fileheader": "use"},
|
||||
"<nil>",
|
||||
},
|
||||
{"recordDelimiter=\n\n,FieldDelimiter=|,QuoteChar=\",qf=;,qec='",
|
||||
{
|
||||
"recordDelimiter=\n\n,FieldDelimiter=|,QuoteChar=\",qf=;,qec='",
|
||||
append(validCSVCommonKeys, validCSVOutputKeys...),
|
||||
validCSVOutputAbbrKeys,
|
||||
map[string]string{},
|
||||
"Options should be key-value pairs in the form key=value,... where valid key(s) are ",
|
||||
},
|
||||
{"FieldDelimiter=|,QuoteChar=\",qf=;,qec='",
|
||||
{
|
||||
"FieldDelimiter=|,QuoteChar=\",qf=;,qec='",
|
||||
append(validCSVCommonKeys, validCSVOutputKeys...),
|
||||
validCSVOutputAbbrKeys,
|
||||
map[string]string{"fielddelimiter": "|", "quotechar": "\"", "quotefields": ";", "quoteescchar": "'"},
|
||||
"<nil>",
|
||||
},
|
||||
{"type=lines",
|
||||
{
|
||||
"type=lines",
|
||||
validJSONInputKeys,
|
||||
nil,
|
||||
map[string]string{"type": "lines"},
|
||||
@@ -118,7 +127,6 @@ var testParseSerializationCases = []struct {
|
||||
}
|
||||
|
||||
func TestParseSerializationOpts(t *testing.T) {
|
||||
|
||||
for i, test := range testParseSerializationCases {
|
||||
optsMap, err := parseSerializationOpts(test.inp, test.validKeys, test.validAbbrKeys)
|
||||
gerr := err.ToGoError()
|
||||
|
||||
@@ -183,5 +183,4 @@ func mainStat(cliCtx *cli.Context) error {
|
||||
|
||||
}
|
||||
return cErr
|
||||
|
||||
}
|
||||
|
||||
+2
-3
@@ -80,8 +80,8 @@ func (stat statMessage) String() (msg string) {
|
||||
msgBuilder.WriteString(fmt.Sprintf("%-10s: %s (lifecycle-rule-id: %s) ", "Expiration",
|
||||
stat.Expiration.Local().Format(printDate), stat.ExpirationRuleID) + "\n")
|
||||
}
|
||||
var maxKeyMetadata = 0
|
||||
var maxKeyEncrypted = 0
|
||||
maxKeyMetadata := 0
|
||||
maxKeyEncrypted := 0
|
||||
for k := range stat.Metadata {
|
||||
// Skip encryption headers, we print them later.
|
||||
if !strings.HasPrefix(strings.ToLower(k), serverEncryptionKeyPrefix) {
|
||||
@@ -330,7 +330,6 @@ func (v bucketInfoMessage) JSON() string {
|
||||
|
||||
fatalIf(probe.NewError(enc.Encode(v)), "Unable to marshal into JSON.")
|
||||
return buf.String()
|
||||
|
||||
}
|
||||
|
||||
func (v bucketInfoMessage) String() string {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user