/
put.go
89 lines (79 loc) · 2.42 KB
/
put.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Warp (C) 2019-2020 MinIO, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package cli
import (
"github.com/minio/cli"
"github.com/minio/minio-go/v7"
"github.com/minio/pkg/v2/console"
"github.com/minio/warp/pkg/bench"
)
var putFlags = []cli.Flag{
cli.StringFlag{
Name: "obj.size",
Value: "10MiB",
Usage: "Size of each generated object. Can be a number or 10KiB/MiB/GiB. All sizes are base 2 binary.",
},
cli.StringFlag{
Name: "part.size",
Value: "",
Usage: "Multipart part size. Can be a number or 10KiB/MiB/GiB. All sizes are base 2 binary.",
Hidden: true,
},
}
// Put command.
var putCmd = cli.Command{
Name: "put",
Usage: "benchmark put objects",
Action: mainPut,
Before: setGlobalsFromContext,
Flags: combineFlags(globalFlags, ioFlags, putFlags, genFlags, benchFlags, analyzeFlags),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{.HelpName}} [FLAGS]
-> see https://github.com/minio/warp#put
FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}`,
}
// mainPut is the entry point for cp command.
func mainPut(ctx *cli.Context) error {
checkPutSyntax(ctx)
b := bench.Put{
Common: getCommon(ctx, newGenSource(ctx, "obj.size")),
}
return runBench(ctx, &b)
}
// putOpts retrieves put options from the context.
func putOpts(ctx *cli.Context) minio.PutObjectOptions {
pSize, _ := toSize(ctx.String("part.size"))
return minio.PutObjectOptions{
ServerSideEncryption: newSSE(ctx),
DisableMultipart: ctx.Bool("disable-multipart"),
DisableContentSha256: ctx.Bool("disable-sha256-payload"),
SendContentMd5: ctx.Bool("md5"),
StorageClass: ctx.String("storage-class"),
PartSize: pSize,
}
}
func checkPutSyntax(ctx *cli.Context) {
if ctx.NArg() > 0 {
console.Fatal("Command takes no arguments")
}
checkAnalyze(ctx)
checkBenchmark(ctx)
}