/
ilm-deprecated-cmds.go
224 lines (185 loc) · 7.51 KB
/
ilm-deprecated-cmds.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// Copyright (c) 2022 MinIO, Inc.
//
// This file is part of MinIO Object Storage stack
//
// 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 cmd
import "github.com/minio/cli"
var ilmDepCmds = []cli.Command{
ilmDepAddCmd,
ilmDepEditCmd,
ilmDepLsCmd,
ilmDepRmCmd,
ilmDepExportCmd,
ilmDepImportCmd,
}
var (
ilmDepAddCmd = cli.Command{
Name: "add",
Usage: "add a lifecycle configuration rule for a bucket",
Action: mainILMAdd,
Hidden: true, // to avoid being listed in `mc ilm`
OnUsageError: onUsageError,
Before: setGlobalsFromContext,
Flags: append(ilmAddFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{.HelpName}} [COMMAND FLAGS] TARGET
FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}
DESCRIPTION:
Add a lifecycle configuration rule.
EXAMPLES:
1. Add a lifecycle rule with an expiration action for all objects in mybucket.
{{.Prompt}} {{.HelpName}} --expire-days "200" myminio/mybucket
2. Add a lifecycle rule with a transition and a noncurrent version transition action for objects with prefix doc/ in mybucket.
Tiers must exist in MinIO. Use existing tiers or add new tiers.
{{.Prompt}} mc tier add minio myminio MINIOTIER-1 --endpoint https://warm-minio-1.com \
--access-key ACCESSKEY --secret-key SECRETKEY --bucket bucket1 --prefix prefix1
{{.Prompt}} mc tier add minio myminio MINIOTIER-2 --endpoint https://warm-minio-2.com \
--access-key ACCESSKEY --secret-key SECRETKEY --bucket bucket2 --prefix prefix2
{{.Prompt}} {{.HelpName}} --prefix "doc/" --transition-days "90" --transition-tier "MINIOTIER-1" \
--noncurrent-transition-days "45" --noncurrent-transition-tier "MINIOTIER-2" \
myminio/mybucket/
3. Add a lifecycle rule with an expiration and a noncurrent version expiration action for all objects with prefix doc/ in mybucket.
{{.Prompt}} {{.HelpName}} --prefix "doc/" --expire-days "300" --noncurrent-expire-days "100" \
myminio/mybucket/
`,
}
ilmDepRmCmd = cli.Command{
Name: "rm",
Usage: "remove (if any) existing lifecycle configuration rule",
Action: mainILMRemove,
Hidden: true, // to avoid being listed in `mc ilm`
OnUsageError: onUsageError,
Before: setGlobalsFromContext,
Flags: append(ilmRemoveFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{.HelpName}} [FLAGS] TARGET
FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}
DESCRIPTION:
Remove a lifecycle configuration rule for the bucket by ID, optionally you can remove
all the lifecycle rules on a bucket with '--all --force' option.
EXAMPLES:
1. Remove the lifecycle management configuration rule given by ID "bgrt1ghju" for mybucket on alias 'myminio'. ID is case sensitive.
{{.Prompt}} {{.HelpName}} --id "bgrt1ghju" myminio/mybucket
2. Remove ALL the lifecycle management configuration rules for mybucket on alias 'myminio'.
Because the result is complete removal, the use of --force flag is enforced.
{{.Prompt}} {{.HelpName}} --all --force myminio/mybucket
`,
}
ilmDepEditCmd = cli.Command{
Name: "edit",
Usage: "modify a lifecycle configuration rule with given id",
Action: mainILMEdit,
Hidden: true, // to avoid being listed in `mc ilm`
OnUsageError: onUsageError,
Before: setGlobalsFromContext,
Flags: append(ilmEditFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{.HelpName}} [COMMAND FLAGS] TARGET
FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}
DESCRIPTION:
Modify a lifecycle configuration rule with given id.
EXAMPLES:
1. Modify the expiration date for an existing rule with id "rHTY.a123".
{{.Prompt}} {{.HelpName}} --id "rHTY.a123" --expiry-date "2020-09-17" s3/mybucket
2. Modify the expiration and transition days for an existing rule with id "hGHKijqpo123".
{{.Prompt}} {{.HelpName}} --id "hGHKijqpo123" --expiry-days "300" \
--transition-days "200" --storage-class "GLACIER" s3/mybucket
3. Disable the rule with id "rHTY.a123".
{{.Prompt}} {{.HelpName}} --id "rHTY.a123" --disable s3/mybucket
`,
}
ilmDepLsCmd = cli.Command{
Name: "ls",
Usage: "lists lifecycle configuration rules set on a bucket",
Action: mainILMList,
Hidden: true, // to avoid being listed in `mc ilm`
OnUsageError: onUsageError,
Before: setGlobalsFromContext,
Flags: append(ilmListFlags, globalFlags...),
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{.HelpName}} [FLAGS] TARGET
FLAGS:
{{range .VisibleFlags}}{{.}}
{{end}}
DESCRIPTION:
List lifecycle configuration rules set on a bucket.
EXAMPLES:
1. List the lifecycle management rules (all fields) for mybucket on alias 'myminio'.
{{.Prompt}} {{.HelpName}} myminio/mybucket
2. List the lifecycle management rules (expration date/days fields) for mybucket on alias 'myminio'.
{{.Prompt}} {{.HelpName}} --expiry myminio/mybucket
3. List the lifecycle management rules (transition date/days, storage class fields) for mybucket on alias 'myminio'.
{{.Prompt}} {{.HelpName}} --transition myminio/mybucket
4. List the lifecycle management rules in JSON format for mybucket on alias 'myminio'.
{{.Prompt}} {{.HelpName}} --json myminio/mybucket
`,
}
ilmDepExportCmd = cli.Command{
Name: "export",
Usage: "export lifecycle configuration in JSON format",
Action: mainILMExport,
Hidden: true, // to avoid being listed in `mc ilm`
OnUsageError: onUsageError,
Before: setGlobalsFromContext,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{.HelpName}} TARGET
DESCRIPTION:
Exports lifecycle configuration in JSON format to STDOUT.
EXAMPLES:
1. Export lifecycle configuration for 'mybucket' to 'lifecycle.json' file.
{{.Prompt}} {{.HelpName}} myminio/mybucket > lifecycle.json
2. Print lifecycle configuration for 'mybucket' to STDOUT.
{{.Prompt}} {{.HelpName}} play/mybucket
`,
}
ilmDepImportCmd = cli.Command{
Name: "import",
Usage: "import lifecycle configuration in JSON format",
Action: mainILMImport,
Hidden: true, // to avoid being listed in `mc ilm`
OnUsageError: onUsageError,
Before: setGlobalsFromContext,
Flags: globalFlags,
CustomHelpTemplate: `NAME:
{{.HelpName}} - {{.Usage}}
USAGE:
{{.HelpName}} TARGET
DESCRIPTION:
Import entire lifecycle configuration from STDIN, input file is expected to be in JSON format.
EXAMPLES:
1. Set lifecycle configuration for the mybucket on alias 'myminio' to the rules imported from lifecycle.json
{{.Prompt}} {{.HelpName}} myminio/mybucket < lifecycle.json
2. Set lifecycle configuration for the mybucket on alias 'myminio'. User is expected to enter the JSON contents on STDIN
{{.Prompt}} {{.HelpName}} myminio/mybucket
`,
}
)