Compare commits
1482
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e44ad30db | ||
|
|
fc1d65b6e8 | ||
|
|
b0e8574969 | ||
|
|
a9a7b7a225 | ||
|
|
ce9e444740 | ||
|
|
80ae287b02 | ||
|
|
127d84854d | ||
|
|
a59de0d37e | ||
|
|
d2960d67ce | ||
|
|
36d5749991 | ||
|
|
fc64e84829 | ||
|
|
7a6a43046c | ||
|
|
50669cafa6 | ||
|
|
d42880acb1 | ||
|
|
250c0e4e59 | ||
|
|
e19fcb8daf | ||
|
|
abfc6709b0 | ||
|
|
e9d27aef5c | ||
|
|
591858cd1a | ||
|
|
6e2ed46cb4 | ||
|
|
30fd595df6 | ||
|
|
8f7accb135 | ||
|
|
1cff14a109 | ||
|
|
03e876aeaa | ||
|
|
6c0d5e4b65 | ||
|
|
83d81ea590 | ||
|
|
907555c849 | ||
|
|
1b1a5940ab | ||
|
|
aa60a8db1e | ||
|
|
8ca59cdebf | ||
|
|
b5a0640899 | ||
|
|
b5937c68bc | ||
|
|
0d9d42166a | ||
|
|
844139d52d | ||
|
|
d62c1e2418 | ||
|
|
4e8402e46f | ||
|
|
f126341342 | ||
|
|
5619a78ead | ||
|
|
04161f5e19 | ||
|
|
c586b4c06e | ||
|
|
19952de324 | ||
|
|
7c229abb05 | ||
|
|
276e1db70d | ||
|
|
162609d6d0 | ||
|
|
32dfeaaf6b | ||
|
|
cc4ff3a0cc | ||
|
|
0530f5a471 | ||
|
|
e964a37a3f | ||
|
|
606cdd3453 | ||
|
|
1187be0ad2 | ||
|
|
6a61b286b1 | ||
|
|
792c6c1475 | ||
|
|
1a504e6e64 | ||
|
|
8e6b9c8a49 | ||
|
|
8df32e87d6 | ||
|
|
45c6f376c4 | ||
|
|
2a5195f2d2 | ||
|
|
3f0953f9f4 | ||
|
|
dbc09a8bf0 | ||
|
|
42bb4df233 | ||
|
|
d9feb87286 | ||
|
|
661afae983 | ||
|
|
033969a0bf | ||
|
|
5a3ad93ab9 | ||
|
|
dc2a851b54 | ||
|
|
8eae2e3bbf | ||
|
|
4d7b58bac5 | ||
|
|
9c34f6c94b | ||
|
|
d6ffdbc8fb | ||
|
|
84a7b83eda | ||
|
|
de063f9252 | ||
|
|
b01f48836a | ||
|
|
3252573ed2 | ||
|
|
0f31ce23b9 | ||
|
|
869c875967 | ||
|
|
bd00af5a71 | ||
|
|
def1988b92 | ||
|
|
f13defa545 | ||
|
|
a7a9b65237 | ||
|
|
88b984a6e2 | ||
|
|
9aa7712c43 | ||
|
|
0d5acd8820 | ||
|
|
9de0045882 | ||
|
|
cce6451b63 | ||
|
|
a1d6c3d4af | ||
|
|
5488be0c8b | ||
|
|
9cf722a3aa | ||
|
|
096fbbf24a | ||
|
|
af342c3780 | ||
|
|
d7846dab9e | ||
|
|
b44a7642ed | ||
|
|
2cae86c783 | ||
|
|
620455a22c | ||
|
|
dec8d91dbc | ||
|
|
f4f5932d3f | ||
|
|
3902b3b03f | ||
|
|
c7a8815414 | ||
|
|
99bdf20c64 | ||
|
|
3b15bec803 | ||
|
|
c5e56141bd | ||
|
|
220f7c217a | ||
|
|
2f42260f98 | ||
|
|
a11a264933 | ||
|
|
c7537a171f | ||
|
|
65efe40a82 | ||
|
|
f65871e305 | ||
|
|
ab2bce93ea | ||
|
|
7b93343803 | ||
|
|
c579c0b403 | ||
|
|
c595efe440 | ||
|
|
cb1daf1567 | ||
|
|
2be75594d0 | ||
|
|
ed42cdc3a8 | ||
|
|
8e3b5ebc46 | ||
|
|
5d50c9beb9 | ||
|
|
9b6f6cdbb4 | ||
|
|
006c48c51c | ||
|
|
e71b1c80b4 | ||
|
|
548dc0fd99 | ||
|
|
3a7a724753 | ||
|
|
5960c628f3 | ||
|
|
dabc6c598e | ||
|
|
cb7674133a | ||
|
|
98bc432b53 | ||
|
|
e048c85d71 | ||
|
|
f5cd21bcf0 | ||
|
|
8ad226ca83 | ||
|
|
fd6d470242 | ||
|
|
a7147d221d | ||
|
|
af7c550f26 | ||
|
|
f5596de2fe | ||
|
|
8a0d1134bb | ||
|
|
3f23cdd921 | ||
|
|
829153f47c | ||
|
|
ccbc1ff725 | ||
|
|
3e28003f82 | ||
|
|
6d12396b47 | ||
|
|
9914c8187e | ||
|
|
43524f7978 | ||
|
|
f06a4b20a3 | ||
|
|
0c58d62a1f | ||
|
|
068e19a7e4 | ||
|
|
16249f3587 | ||
|
|
7656636373 | ||
|
|
fd70dd59c6 | ||
|
|
2f9bcdf344 | ||
|
|
dd01c71445 | ||
|
|
ac39184c35 | ||
|
|
d2b7c3c3ac | ||
|
|
91278da28d | ||
|
|
0ddf3e2691 | ||
|
|
1264168162 | ||
|
|
aed4d3062f | ||
|
|
61db086b10 | ||
|
|
a59f9e4d30 | ||
|
|
8b3935e24d | ||
|
|
0373840f42 | ||
|
|
8132c286e4 | ||
|
|
eef80d47cd | ||
|
|
37e0f8ba27 | ||
|
|
05c3ae8716 | ||
|
|
f06a0987a3 | ||
|
|
3391f39521 | ||
|
|
e08ded6d28 | ||
|
|
3144cb97ed | ||
|
|
12012eafad | ||
|
|
385bc1b23a | ||
|
|
0b2f0c9b48 | ||
|
|
409ccc7c07 | ||
|
|
7bd5c343f7 | ||
|
|
68a9e3f52e | ||
|
|
7031efb55a | ||
|
|
2d516d350a | ||
|
|
2a84f0f1f9 | ||
|
|
9bdd7660f6 | ||
|
|
b6c50a92a1 | ||
|
|
23a05f5a17 | ||
|
|
bd7a49f500 | ||
|
|
8a207df2ab | ||
|
|
cb73b76c81 | ||
|
|
e84871950a | ||
|
|
a064265d0c | ||
|
|
4793c40bf6 | ||
|
|
18a579da0b | ||
|
|
df75eed32e | ||
|
|
26e7e49cd7 | ||
|
|
d0c62eb584 | ||
|
|
3a4e469334 | ||
|
|
ae66e893c7 | ||
|
|
7fd441ec6c | ||
|
|
6460d2facf | ||
|
|
b2ff347c69 | ||
|
|
b882f3e484 | ||
|
|
1461b652d9 | ||
|
|
a776222b33 | ||
|
|
e7c79413d7 | ||
|
|
9b5d0ba1ef | ||
|
|
9f6b500142 | ||
|
|
9e8fea96ca | ||
|
|
6e1d044f91 | ||
|
|
c0cfc9c507 | ||
|
|
905502e311 | ||
|
|
14303ec6cf | ||
|
|
7866f97ef5 | ||
|
|
6339784743 | ||
|
|
b9bfcb50a3 | ||
|
|
b493f01699 | ||
|
|
e45d648ce9 | ||
|
|
3177a62819 | ||
|
|
ae271e7645 | ||
|
|
0eef0174a7 | ||
|
|
b880f09931 | ||
|
|
6047ef858a | ||
|
|
e4d4bf6641 | ||
|
|
198bca9cdf | ||
|
|
054cfa0103 | ||
|
|
6b329ce01f | ||
|
|
44a597a9f9 | ||
|
|
55c6a1fccc | ||
|
|
026cfa16c5 | ||
|
|
924df70b33 | ||
|
|
6c41669342 | ||
|
|
1aa0f47736 | ||
|
|
bc69976481 | ||
|
|
88544fee85 | ||
|
|
7e6f46fba6 | ||
|
|
1bcd5df300 | ||
|
|
368b4106d7 | ||
|
|
445414dc0c | ||
|
|
2d01434415 | ||
|
|
fa0aa1e45f | ||
|
|
5a8f677304 | ||
|
|
4e4c912b37 | ||
|
|
a8bf2a463b | ||
|
|
e576844f0f | ||
|
|
d7bc62efa6 | ||
|
|
77a4c9f9e5 | ||
|
|
1f997000a3 | ||
|
|
1f2429c336 | ||
|
|
6bf64d9704 | ||
|
|
24456eb990 | ||
|
|
56b22c37fc | ||
|
|
4e56329bae | ||
|
|
e7d3f4637a | ||
|
|
f661334f3d | ||
|
|
7f37854b02 | ||
|
|
ef90b8b3dd | ||
|
|
855333e4ab | ||
|
|
0667914d16 | ||
|
|
c19d58bb88 | ||
|
|
a88acb58d4 | ||
|
|
43b03a8532 | ||
|
|
b3ce21fb72 | ||
|
|
539a6b5654 | ||
|
|
bc5835e680 | ||
|
|
4af8b2d20b | ||
|
|
addaf66de8 | ||
|
|
c3ab68ed1e | ||
|
|
7dafdaf88e | ||
|
|
c319567430 | ||
|
|
bfafb96632 | ||
|
|
05ec684549 | ||
|
|
5e95eea60c | ||
|
|
db1b1bd811 | ||
|
|
a1ba511f16 | ||
|
|
cebf331854 | ||
|
|
2c52cdf27c | ||
|
|
776643ff2a | ||
|
|
b70da9cbcb | ||
|
|
9242dbdf69 | ||
|
|
7c0ab1b2d5 | ||
|
|
27d0ea67cb | ||
|
|
c8d9eee2b4 | ||
|
|
6a2b118473 | ||
|
|
a06096f8ee | ||
|
|
87092404e0 | ||
|
|
4b7e85d7e9 | ||
|
|
fbbae711bd | ||
|
|
5b972bb7b0 | ||
|
|
91efd0c066 | ||
|
|
9740a09584 | ||
|
|
8d65ee7130 | ||
|
|
6e251456d2 | ||
|
|
9714e1cf49 | ||
|
|
60d3646baf | ||
|
|
7d142be711 | ||
|
|
deb714784c | ||
|
|
757b9d6872 | ||
|
|
954f0a5fd1 | ||
|
|
ac08bf41a7 | ||
|
|
077fff35dd | ||
|
|
1402987ccb | ||
|
|
0c11cf9f28 | ||
|
|
e207f3bfa4 | ||
|
|
073c9c6308 | ||
|
|
8cf4031ef5 | ||
|
|
dfbedf9f3a | ||
|
|
6c3ac00e18 | ||
|
|
8c4a2698d9 | ||
|
|
a62d2b4659 | ||
|
|
c4890d949b | ||
|
|
af1676e6ec | ||
|
|
4eae7ec7ed | ||
|
|
36c17891d6 | ||
|
|
37f5eff195 | ||
|
|
20e5905de0 | ||
|
|
a17153cf9e | ||
|
|
c00c7e3a35 | ||
|
|
d8393a365e | ||
|
|
78e3c94f5a | ||
|
|
ef59238007 | ||
|
|
b537ee408b | ||
|
|
4380288249 | ||
|
|
1ac898c382 | ||
|
|
a093f822e2 | ||
|
|
9f9f7ec542 | ||
|
|
e513a4f68f | ||
|
|
6074aa43ff | ||
|
|
9914d28527 | ||
|
|
0ee9471197 | ||
|
|
c3cae160b3 | ||
|
|
1f71fdc03a | ||
|
|
49e85e9109 | ||
|
|
bac257a6e0 | ||
|
|
e10c82f9ad | ||
|
|
501b791408 | ||
|
|
ccb35f1672 | ||
|
|
faa895dd75 | ||
|
|
dde89f7604 | ||
|
|
28d8677578 | ||
|
|
1d9873c512 | ||
|
|
a8c6f751a7 | ||
|
|
13cf091af6 | ||
|
|
cb577322fd | ||
|
|
f9d36f9b52 | ||
|
|
56ea65a78e | ||
|
|
8bbd07802e | ||
|
|
e3b84c39df | ||
|
|
cb909f5ce5 | ||
|
|
18da584d5a | ||
|
|
b3c692d6eb | ||
|
|
0053d58648 | ||
|
|
97482653ac | ||
|
|
7672841f8c | ||
|
|
d759f195f2 | ||
|
|
006cb0c0cf | ||
|
|
4eb6f999a6 | ||
|
|
7c0fb6a99e | ||
|
|
f782b462c6 | ||
|
|
4942cffc2c | ||
|
|
c44387cb32 | ||
|
|
e93ec078dc | ||
|
|
650a4b8d66 | ||
|
|
ade302d969 | ||
|
|
169aa24ae0 | ||
|
|
24ebcf13cf | ||
|
|
130f4393bb | ||
|
|
7e19044d98 | ||
|
|
1fd739cc50 | ||
|
|
93d579a936 | ||
|
|
8760185bc3 | ||
|
|
f73987fc34 | ||
|
|
1c3e6516f0 | ||
|
|
419a6935db | ||
|
|
f1f3003e5e | ||
|
|
5fcb069e8a | ||
|
|
c1fe60f7ad | ||
|
|
e7df97d1e0 | ||
|
|
95ee8f0714 | ||
|
|
c041d86f03 | ||
|
|
e13737383f | ||
|
|
c00afbc516 | ||
|
|
766b69802c | ||
|
|
864e4589ac | ||
|
|
41c804b179 | ||
|
|
fca6cb2815 | ||
|
|
d0e1456be3 | ||
|
|
2b99236a22 | ||
|
|
5023905a3a | ||
|
|
5ed74df9ed | ||
|
|
4e8e67fb04 | ||
|
|
1967d38dd4 | ||
|
|
74fc02e5eb | ||
|
|
52fc5e8c15 | ||
|
|
7ef637884c | ||
|
|
24101f18aa | ||
|
|
b6969bc501 | ||
|
|
4dc0a44ebf | ||
|
|
c691cc5488 | ||
|
|
d4fbfb5975 | ||
|
|
00873e4b93 | ||
|
|
b1f5e78980 | ||
|
|
bd7442fbc6 | ||
|
|
c7989d06bc | ||
|
|
681cbb06de | ||
|
|
3dffa04f66 | ||
|
|
060b0762fb | ||
|
|
df5f03a109 | ||
|
|
465e6cf63c | ||
|
|
25fd302af6 | ||
|
|
bf2f7f0292 | ||
|
|
138587816a | ||
|
|
d4f9ea859d | ||
|
|
adafa0024f | ||
|
|
9ac1bf4a29 | ||
|
|
f3dd24f578 | ||
|
|
3792e9f906 | ||
|
|
f1c04ad4b8 | ||
|
|
e216394765 | ||
|
|
6ab70467cc | ||
|
|
b2ab462551 | ||
|
|
786a53672b | ||
|
|
63ce578c46 | ||
|
|
965747e45d | ||
|
|
0289d32164 | ||
|
|
40e328eac2 | ||
|
|
470ae1ee5f | ||
|
|
50bfa26724 | ||
|
|
ab396ae957 | ||
|
|
7838365102 | ||
|
|
6c2325129f | ||
|
|
fa4da03a4f | ||
|
|
d1232dc089 | ||
|
|
91c9364f3c | ||
|
|
440f6dccbc | ||
|
|
6bae0eb218 | ||
|
|
b47b2e19a8 | ||
|
|
00f655ac41 | ||
|
|
b7a3dff287 | ||
|
|
8a8611cf74 | ||
|
|
bb2bfdc918 | ||
|
|
0324fdcc6e | ||
|
|
2b36376bbc | ||
|
|
f11c3a9733 | ||
|
|
3b65e9cba6 | ||
|
|
f11ae85566 | ||
|
|
7f2df96e48 | ||
|
|
4b34df590a | ||
|
|
177f15db2e | ||
|
|
2568f9e7bf | ||
|
|
217f5fcbae | ||
|
|
1ca2182203 | ||
|
|
150d2494e9 | ||
|
|
db1b508d8b | ||
|
|
d24de97cde | ||
|
|
3776dff20f | ||
|
|
9ff6c146b4 | ||
|
|
ce0c109ae3 | ||
|
|
0449df8887 | ||
|
|
a5d03c51e2 | ||
|
|
0c1f1e29f1 | ||
|
|
1dde65d9c0 | ||
|
|
f7b1b4a139 | ||
|
|
fede0756d4 | ||
|
|
64fb8f0a8f | ||
|
|
93209e842c | ||
|
|
8f2ffbfa86 | ||
|
|
af6cff00a5 | ||
|
|
7f550f9482 | ||
|
|
19c49468b7 | ||
|
|
f992322606 | ||
|
|
b7e4a633d8 | ||
|
|
5649deee40 | ||
|
|
b55e3e2d29 | ||
|
|
05d63c9aba | ||
|
|
d5b4a04592 | ||
|
|
d584adda01 | ||
|
|
25a043b508 | ||
|
|
85cce08a85 | ||
|
|
8f1ce3c59f | ||
|
|
41d337e95c | ||
|
|
e10c597425 | ||
|
|
6fc39cdf8e | ||
|
|
35632bc1af | ||
|
|
a104aa1cb2 | ||
|
|
2a6bdd8164 | ||
|
|
c58148a421 | ||
|
|
b1ca6482d5 | ||
|
|
54fab0ad8f | ||
|
|
ebb05ce469 | ||
|
|
ce7ffc38df | ||
|
|
ff9731a0d2 | ||
|
|
b604a89a9c | ||
|
|
fe5e714593 | ||
|
|
cd41dbc0a2 | ||
|
|
24e58fce38 | ||
|
|
6f2dc37ad8 | ||
|
|
eafc9ee7b4 | ||
|
|
a80eca5af8 | ||
|
|
091a109e5a | ||
|
|
cdb458c987 | ||
|
|
f9dc22561c | ||
|
|
5ad2d36f5c | ||
|
|
6313ee7dab | ||
|
|
73d8b35425 | ||
|
|
4d70066990 | ||
|
|
7e52c104be | ||
|
|
588a8fcd17 | ||
|
|
0ba1633a04 | ||
|
|
069968c8aa | ||
|
|
0c4b649369 | ||
|
|
bd03dfbb15 | ||
|
|
9498227542 | ||
|
|
32c13f2977 | ||
|
|
6f8859262c | ||
|
|
cd1f28e20c | ||
|
|
b1aa159838 | ||
|
|
3c0bc7ec33 | ||
|
|
6a98216c53 | ||
|
|
7ffa755cd9 | ||
|
|
0631315535 | ||
|
|
2be7f6dd13 | ||
|
|
ceb216f8a3 | ||
|
|
d93b7f7638 | ||
|
|
ec734d0f71 | ||
|
|
90dc31f6ba | ||
|
|
9c09f78982 | ||
|
|
90d22b271f | ||
|
|
2750c4bfe6 | ||
|
|
c61a26269f | ||
|
|
65d564dd87 | ||
|
|
442facedd1 | ||
|
|
a2592cef84 | ||
|
|
023e56e0a1 | ||
|
|
c8a3b7bff0 | ||
|
|
12acca5abd | ||
|
|
67f2472d24 | ||
|
|
f19a10dce2 | ||
|
|
ea8c0db96e | ||
|
|
0b0acc611f | ||
|
|
7b5d5ea990 | ||
|
|
56c2c1a5c5 | ||
|
|
f3c9e9172a | ||
|
|
9193388568 | ||
|
|
a419bb4130 | ||
|
|
469665f886 | ||
|
|
5d98d19608 | ||
|
|
9d762f5aa6 | ||
|
|
51a3d287bb | ||
|
|
fbb7d75c1c | ||
|
|
53dc65c92a | ||
|
|
d811d416a5 | ||
|
|
ba37e08f1f | ||
|
|
5c713e5ecb | ||
|
|
712ff33319 | ||
|
|
90d6e7df24 | ||
|
|
b8570a9a0b | ||
|
|
360d094828 | ||
|
|
08685bae6a | ||
|
|
4989d51e2c | ||
|
|
a62a539399 | ||
|
|
d5b6931a1e | ||
|
|
397f41c71c | ||
|
|
707f46c32b | ||
|
|
133dd1f7da | ||
|
|
bdefdc0169 | ||
|
|
c51e3b3ec9 | ||
|
|
88223f96be | ||
|
|
fa520cbd1a | ||
|
|
166db95464 | ||
|
|
0e27dd4ed4 | ||
|
|
2403e7a744 | ||
|
|
ea03e61fac | ||
|
|
f55e9c1997 | ||
|
|
7664bb2c8d | ||
|
|
09f832f597 | ||
|
|
4cc297ba4e | ||
|
|
bf731558cd | ||
|
|
949dd282f9 | ||
|
|
61b74e90bf | ||
|
|
3b479cf92e | ||
|
|
09c31c4ab2 | ||
|
|
71196b1013 | ||
|
|
72c8e92459 | ||
|
|
a6d82862cd | ||
|
|
672390b86a | ||
|
|
2e586e6b9d | ||
|
|
ad0bc4c33d | ||
|
|
a75dca16bd | ||
|
|
4e3b501528 | ||
|
|
dc2ad27429 | ||
|
|
b99c313366 | ||
|
|
e13751f5d5 | ||
|
|
ca650e227a | ||
|
|
df8bb795ba | ||
|
|
2fe7d04043 | ||
|
|
138d7656ba | ||
|
|
2018319125 | ||
|
|
c8c5c15249 | ||
|
|
32d8ef24ef | ||
|
|
f82a7b13c1 | ||
|
|
49c2beec79 | ||
|
|
24a72e4a33 | ||
|
|
c7166eac3a | ||
|
|
20dd7011b9 | ||
|
|
f23f814764 | ||
|
|
e1617a504b | ||
|
|
89930fed29 | ||
|
|
8c262e1f3f | ||
|
|
e6a6cfcebf | ||
|
|
bb43b2adf1 | ||
|
|
2d6a960f94 | ||
|
|
4036009dc2 | ||
|
|
ab2500e2ef | ||
|
|
5c4add2000 | ||
|
|
59187f2ef7 | ||
|
|
37ee28a051 | ||
|
|
91ca683b03 | ||
|
|
68b638f2f9 | ||
|
|
42023a1298 | ||
|
|
150bc75a2c | ||
|
|
4388f6d69b | ||
|
|
9e4e435c56 | ||
|
|
dfa1e42b25 | ||
|
|
cb9e103714 | ||
|
|
dee04e3d73 | ||
|
|
18f81e5458 | ||
|
|
8cae137525 | ||
|
|
3b31837927 | ||
|
|
f0f56ac906 | ||
|
|
4d36c1f8b8 | ||
|
|
a9e875b503 | ||
|
|
51ef254a41 | ||
|
|
e05f02d9f4 | ||
|
|
0ea8d1d479 | ||
|
|
eeeca2332d | ||
|
|
080414009e | ||
|
|
25de1da81b | ||
|
|
1fb87a492e | ||
|
|
71eb7f6689 | ||
|
|
64a78e7811 | ||
|
|
b010699112 | ||
|
|
3230acae32 | ||
|
|
91da0da183 | ||
|
|
fc04dc6463 | ||
|
|
fd43df09a1 | ||
|
|
b621ae58f5 | ||
|
|
bcbbfa7352 | ||
|
|
5b5d65a142 | ||
|
|
1a27f7f51d | ||
|
|
1092f6932f | ||
|
|
128f81461c | ||
|
|
7a26f993a2 | ||
|
|
c170a2db6c | ||
|
|
d58cf3c8c6 | ||
|
|
a7dd97f140 | ||
|
|
093bf0d54a | ||
|
|
a0d9e26dc7 | ||
|
|
24e7caa146 | ||
|
|
b65d6797cd | ||
|
|
67e90b8fcb | ||
|
|
fd89251270 | ||
|
|
4152714126 | ||
|
|
3862184a8a | ||
|
|
7e1e91d9c9 | ||
|
|
5d9a04bac6 | ||
|
|
2f2aecb09d | ||
|
|
e03d8d99a3 | ||
|
|
f7c366ae3d | ||
|
|
0724774bd8 | ||
|
|
551a124804 | ||
|
|
609274326b | ||
|
|
ac9b942397 | ||
|
|
b70a79e39b | ||
|
|
0baee49a66 | ||
|
|
6a2da1a6ef | ||
|
|
28aae43c8c | ||
|
|
0596acea95 | ||
|
|
8694ddb3ee | ||
|
|
c27941bc2a | ||
|
|
79e183fd0f | ||
|
|
632f0949bd | ||
|
|
374100da7e | ||
|
|
3f87064138 | ||
|
|
63821bbe3f | ||
|
|
2a66f9ba2b | ||
|
|
27a033440e | ||
|
|
50766862c1 | ||
|
|
6d1a41458b | ||
|
|
9663319e9e | ||
|
|
8f0b923312 | ||
|
|
7c9ea88742 | ||
|
|
ee283811a3 | ||
|
|
d92d2f0d4f | ||
|
|
f2f8f858a6 | ||
|
|
64e0c36e3b | ||
|
|
85f814eb44 | ||
|
|
2616a1d051 | ||
|
|
7038207039 | ||
|
|
23aab5b458 | ||
|
|
e109a5370a | ||
|
|
871b8da9a6 | ||
|
|
34757e2ce2 | ||
|
|
dff0f0318c | ||
|
|
45df811a89 | ||
|
|
8a488ba0e4 | ||
|
|
ea0a4b2142 | ||
|
|
4482063fb9 | ||
|
|
2d8bd7aecc | ||
|
|
69bea2eb96 | ||
|
|
c5112d4a0f | ||
|
|
a8064ff644 | ||
|
|
fccdcfe803 | ||
|
|
543ea4bd90 | ||
|
|
da47ed8ac4 | ||
|
|
f3b2d5471f | ||
|
|
3f426ff7e0 | ||
|
|
1e1480f408 | ||
|
|
4e316c3a40 | ||
|
|
cb110f7403 | ||
|
|
21a79b4a44 | ||
|
|
cf6defe025 | ||
|
|
6eaf0dd05e | ||
|
|
c2a771f51c | ||
|
|
6cfbc809cf | ||
|
|
3dc37f1ecd | ||
|
|
5dda155f81 | ||
|
|
c51267871c | ||
|
|
9a9a6d853d | ||
|
|
9aebf1e818 | ||
|
|
3df8101903 | ||
|
|
94943334d4 | ||
|
|
27d1131825 | ||
|
|
e0c6fabda6 | ||
|
|
71f5a7568f | ||
|
|
2a33d28cb9 | ||
|
|
9927c0d5c7 | ||
|
|
42898064f2 | ||
|
|
810978720f | ||
|
|
90a60d3b6a | ||
|
|
f6240587db | ||
|
|
80aecfddff | ||
|
|
72403ecbd1 | ||
|
|
16965bc19a | ||
|
|
d7078ae153 | ||
|
|
bced96ee98 | ||
|
|
990a7b6d51 | ||
|
|
735aa139b1 | ||
|
|
aa4a4774da | ||
|
|
c389ee4aa0 | ||
|
|
f93fe1330a | ||
|
|
3710c443bb | ||
|
|
0f8345b207 | ||
|
|
6f478d0a6f | ||
|
|
d902705d90 | ||
|
|
f79aefa797 | ||
|
|
196723372c | ||
|
|
f687722587 | ||
|
|
26b9044a86 | ||
|
|
a9c606f119 | ||
|
|
26b71711e8 | ||
|
|
6438350130 | ||
|
|
508869e3f1 | ||
|
|
1db7a3bbed | ||
|
|
57a9c6fab2 | ||
|
|
93297260be | ||
|
|
dff077e34b | ||
|
|
a8380a00ef | ||
|
|
5afb0a3aa7 | ||
|
|
54ee3a2800 | ||
|
|
9f75caef55 | ||
|
|
bc1c6bde1d | ||
|
|
1dd2b4494d | ||
|
|
5fc35b6682 | ||
|
|
22ab93da0f | ||
|
|
1582b1cf35 | ||
|
|
bd7564a2d4 | ||
|
|
af7d551010 | ||
|
|
3acbeda9c2 | ||
|
|
89d30e9aa2 | ||
|
|
64d45ac35a | ||
|
|
f8661fd87e | ||
|
|
12add870fc | ||
|
|
00a2f81589 | ||
|
|
617b5e39f5 | ||
|
|
1555979f96 | ||
|
|
418c8e7182 | ||
|
|
3b94d4d3e0 | ||
|
|
e541715e42 | ||
|
|
37bdbd037e | ||
|
|
d399b1e70b | ||
|
|
fef437bdd6 | ||
|
|
809741e161 | ||
|
|
0f360131cb | ||
|
|
cb3ce8fb97 | ||
|
|
b56e297be0 | ||
|
|
81eb54d146 | ||
|
|
9fabc08520 | ||
|
|
b885d13060 | ||
|
|
67dbada736 | ||
|
|
c25461640b | ||
|
|
c727be5a48 | ||
|
|
ae098462c9 | ||
|
|
74a7c3dc9a | ||
|
|
c2fcfe6512 | ||
|
|
bdcb9dcb2f | ||
|
|
6200a34522 | ||
|
|
9a25e66e87 | ||
|
|
7c454d8f94 | ||
|
|
ab3e70ae9f | ||
|
|
1818191dca | ||
|
|
31e5ac02bd | ||
|
|
aa3c9f58df | ||
|
|
df9320134b | ||
|
|
6003da8daa | ||
|
|
41e3ea5664 | ||
|
|
8b33b2809c | ||
|
|
56309a4999 | ||
|
|
2d691508c2 | ||
|
|
98e88c2ff0 | ||
|
|
675618574a | ||
|
|
d97cfaa55d | ||
|
|
ec76f67668 | ||
|
|
a12c507bec | ||
|
|
ca26dac8e2 | ||
|
|
5d0a9c0803 | ||
|
|
b85dabd6b4 | ||
|
|
e978c71b7c | ||
|
|
eb9493458e | ||
|
|
f4bb0b8850 | ||
|
|
dd4e356c64 | ||
|
|
c1ed052638 | ||
|
|
88a3c2b1e1 | ||
|
|
f0f156aca8 | ||
|
|
b1aa2232ef | ||
|
|
4b4555b811 | ||
|
|
ecdeb3934d | ||
|
|
abceea8fa1 | ||
|
|
83a9d8b91d | ||
|
|
68a9eeae18 | ||
|
|
5729a01e69 | ||
|
|
ea469140d5 | ||
|
|
b5b7a56eca | ||
|
|
66677d7c21 | ||
|
|
7805774cf3 | ||
|
|
8ae04b41b0 | ||
|
|
b27cd5ada8 | ||
|
|
a1355e50e2 | ||
|
|
2ad65c0799 | ||
|
|
7f2770e68f | ||
|
|
c34dec5495 | ||
|
|
ba92305de0 | ||
|
|
0a790a1a2e | ||
|
|
3ea090fe18 | ||
|
|
0490231b34 | ||
|
|
030aa5aba5 | ||
|
|
09d04326dc | ||
|
|
cfb25fe81b | ||
|
|
ecfd4526a3 | ||
|
|
affc127af0 | ||
|
|
a498b9b3a2 | ||
|
|
e684b48cfe | ||
|
|
5b585c4759 | ||
|
|
2e612b23d6 | ||
|
|
4a130c60a8 | ||
|
|
b72d2d9cc5 | ||
|
|
b3229507a9 | ||
|
|
1761b338f9 | ||
|
|
c63c5732e9 | ||
|
|
dba70c0b92 | ||
|
|
c75abbb3f9 | ||
|
|
19e14db50a | ||
|
|
bd5372f165 | ||
|
|
a3203d4fe7 | ||
|
|
e538599e2f | ||
|
|
4b62f520e8 | ||
|
|
bc1a108e5c | ||
|
|
38965dd432 | ||
|
|
30491f369d | ||
|
|
1941a2532a | ||
|
|
3a22044471 | ||
|
|
da3e027145 | ||
|
|
7bc792e745 | ||
|
|
939e1006cc | ||
|
|
57faed2725 | ||
|
|
f9a6d70bc0 | ||
|
|
e3854b077a | ||
|
|
75a36b4831 | ||
|
|
30965763d6 | ||
|
|
e940856fee | ||
|
|
07169d421e | ||
|
|
a5ea937df2 | ||
|
|
539cd245d6 | ||
|
|
ede0911de2 | ||
|
|
733d3c5d54 | ||
|
|
0854af6e6d | ||
|
|
d8d3a3dec1 | ||
|
|
59ef9fe468 | ||
|
|
9ddc45162a | ||
|
|
bda754d07f | ||
|
|
124b9fa4d9 | ||
|
|
45578f0ed2 | ||
|
|
4e7eeb0725 | ||
|
|
f0309e33e1 | ||
|
|
8964876217 | ||
|
|
e3b84ac010 | ||
|
|
d541a7f6ef | ||
|
|
69f967b3f3 | ||
|
|
1bb64f0bf0 | ||
|
|
2073642656 | ||
|
|
f3eaa54a32 | ||
|
|
a91204ea6f | ||
|
|
5117f74fce | ||
|
|
57414cbb6e | ||
|
|
24d4c28aa9 | ||
|
|
cb4f46854b | ||
|
|
0992c3a50d | ||
|
|
c5eaa30253 | ||
|
|
6faac81eb0 | ||
|
|
2fc5413002 | ||
|
|
8137e79d0c | ||
|
|
b827fac635 | ||
|
|
4479667d4c | ||
|
|
9226796558 | ||
|
|
fd340638bb | ||
|
|
6ca902d13a | ||
|
|
73a61b4203 | ||
|
|
96378448c5 | ||
|
|
eab117c07c | ||
|
|
7b69f0064d | ||
|
|
0dd32c1b26 | ||
|
|
c707a17f30 | ||
|
|
502e28d2be | ||
|
|
b7e87b623d | ||
|
|
7bbc81ffa4 | ||
|
|
449cad0eb8 | ||
|
|
7260b0f9ea | ||
|
|
a83ffe321c | ||
|
|
a215fbb718 | ||
|
|
87f7e65c4c | ||
|
|
ab31cf97da | ||
|
|
b2d2e09105 | ||
|
|
c9f33698fc | ||
|
|
044a95b6cf | ||
|
|
c352cadd4b | ||
|
|
40971c0b93 | ||
|
|
0d0638b398 | ||
|
|
12627c35e4 | ||
|
|
1d5870b2a2 | ||
|
|
ae88af8b1b | ||
|
|
bc756e3dbd | ||
|
|
bc679788ac | ||
|
|
a1110bc022 | ||
|
|
073ed250fe | ||
|
|
3b78c115f6 | ||
|
|
f8aafcc774 | ||
|
|
22b8ab43bd | ||
|
|
5eab7c2698 | ||
|
|
26f5102eae | ||
|
|
9998e077df | ||
|
|
480bc8aa2a | ||
|
|
a8c97b467d | ||
|
|
7f01db2cda | ||
|
|
d83e73b85b | ||
|
|
7e49e2d519 | ||
|
|
5a962a7cf5 | ||
|
|
70dcf20d74 | ||
|
|
c57a2dc4c2 | ||
|
|
4ab7f30f99 | ||
|
|
29f2dbca6b | ||
|
|
4070902cda | ||
|
|
556bbc2de5 | ||
|
|
7e879edabc | ||
|
|
f48ac0de19 | ||
|
|
1a5aab3ff4 | ||
|
|
8cf797da5f | ||
|
|
023b38fe3f | ||
|
|
afcfe758f3 | ||
|
|
c0b89a7aec | ||
|
|
4f1f864f64 | ||
|
|
2d4346bfe1 | ||
|
|
d566905d7a | ||
|
|
743d72ea1a | ||
|
|
10059459f3 | ||
|
|
376b4ce2f8 | ||
|
|
961c4b5dae | ||
|
|
1711f0bb46 | ||
|
|
b41b98b04d | ||
|
|
1b794a4ae1 | ||
|
|
182ad295d8 | ||
|
|
75e9691616 | ||
|
|
1ccf40d1e5 | ||
|
|
2dc48e9dd3 | ||
|
|
757fff7764 | ||
|
|
0fe4319e17 | ||
|
|
18ddd3925b | ||
|
|
8aaf909a08 | ||
|
|
da5c19848d | ||
|
|
45b32d3985 | ||
|
|
ae3c123a5c | ||
|
|
fe82b0381c | ||
|
|
0ede95b65e | ||
|
|
4758556eec | ||
|
|
ea580b0b65 | ||
|
|
b1dd99c94d | ||
|
|
57bf0c0e79 | ||
|
|
7ebe7908ea | ||
|
|
750644ec4d | ||
|
|
efeaf2ee72 | ||
|
|
97c7984bca | ||
|
|
335a53ad29 | ||
|
|
d4981656d3 | ||
|
|
766e04d79d | ||
|
|
4e30ca1617 | ||
|
|
65e22bee24 | ||
|
|
3987f1405a | ||
|
|
e1056aa50d | ||
|
|
017dddef97 | ||
|
|
55f06077e5 | ||
|
|
99ee2a5042 | ||
|
|
793cda2ca0 | ||
|
|
83bb797389 | ||
|
|
8fbbd0ee83 | ||
|
|
b94b8e67e9 | ||
|
|
f93fb55606 | ||
|
|
3b4626ea15 | ||
|
|
d9663e5d96 | ||
|
|
5d703df69d | ||
|
|
5f2f82b5f7 | ||
|
|
5dee56d5d0 | ||
|
|
722ee94165 | ||
|
|
b64c8a3aa9 | ||
|
|
13259eea21 | ||
|
|
9da492975c | ||
|
|
96dc4f920d | ||
|
|
2d221ba8da | ||
|
|
87309ebaac | ||
|
|
eeb18ff75c | ||
|
|
4cb6e35342 | ||
|
|
5ddf9728f8 | ||
|
|
275db95170 | ||
|
|
399187c4fb | ||
|
|
1fd03fb81f | ||
|
|
0aa704ad5e | ||
|
|
1e7b4c9e4a | ||
|
|
65c582cd5b | ||
|
|
336e7f58bf | ||
|
|
dfffc1e7cc | ||
|
|
a63a1f7eca | ||
|
|
b3fe40e113 | ||
|
|
093ab6b034 | ||
|
|
ceb38130fc | ||
|
|
7498e97182 | ||
|
|
32a8f34f7d | ||
|
|
014d09412a | ||
|
|
ab6b2a83ac | ||
|
|
79a51e9afc | ||
|
|
c9448749d0 | ||
|
|
aa8d5ed0cc | ||
|
|
a86080a0b7 | ||
|
|
59685e2d6b | ||
|
|
582f99b438 | ||
|
|
26c7c3e500 | ||
|
|
785e14a725 | ||
|
|
7ad9a36b9d | ||
|
|
9831612507 | ||
|
|
207d5cfb61 | ||
|
|
c10b429dcb | ||
|
|
8f38471e29 | ||
|
|
25254c7622 | ||
|
|
7d062fb08c | ||
|
|
37e5a78779 | ||
|
|
07e810fd51 | ||
|
|
224e602e59 | ||
|
|
be710ecb52 | ||
|
|
4810ab8727 | ||
|
|
5a2798dddb | ||
|
|
36d7d0b9a7 | ||
|
|
b1812ebe5a | ||
|
|
683fcf0dd2 | ||
|
|
39197ea3ae | ||
|
|
48bd32570f | ||
|
|
49ef42d36a | ||
|
|
fe583468ce | ||
|
|
3f4d3ee1c0 | ||
|
|
dd3b659f9e | ||
|
|
dc47c3819a | ||
|
|
e6ca983442 | ||
|
|
ca96cfc6e6 | ||
|
|
60681d7fb6 | ||
|
|
e53ad24e8c | ||
|
|
b62fa406d8 | ||
|
|
d066ff71f5 | ||
|
|
3e2c3fc94d | ||
|
|
c1b9079b73 | ||
|
|
b9401d574f | ||
|
|
eba548ca88 | ||
|
|
b4d7ec07f4 | ||
|
|
4753e1e61b | ||
|
|
8d7888eb4f | ||
|
|
54a7460fa0 | ||
|
|
5c135d25d6 | ||
|
|
8391a69dc5 | ||
|
|
1b9beadf2b | ||
|
|
05f588fd19 | ||
|
|
d01a50d301 | ||
|
|
3b53bbe478 | ||
|
|
685299ab75 | ||
|
|
1a8561115b | ||
|
|
c32b1ea48b | ||
|
|
ea05fcbcf5 | ||
|
|
2d44e8c85e | ||
|
|
21c677fc2d | ||
|
|
800f0af04e | ||
|
|
398bac82d9 | ||
|
|
cd16de763c | ||
|
|
694ab27649 | ||
|
|
61f2595852 | ||
|
|
be3370396a | ||
|
|
fed9ebe39d | ||
|
|
6c677e0d11 | ||
|
|
320e29e03f | ||
|
|
7f65ad4957 | ||
|
|
372e905dad | ||
|
|
7027211e58 | ||
|
|
f0ccc91890 | ||
|
|
136e286ef4 | ||
|
|
e54962e17f | ||
|
|
39aa635971 | ||
|
|
61e511cc3e | ||
|
|
dd9e715599 | ||
|
|
9bdb7affb1 | ||
|
|
9a881562b9 | ||
|
|
656f4f13d0 | ||
|
|
9eb967cabf | ||
|
|
1bf5ac350f | ||
|
|
313d0a358f | ||
|
|
81f3ffa3af | ||
|
|
9ea42680b0 | ||
|
|
018bcbf629 | ||
|
|
0733d37c67 | ||
|
|
b0968e29e8 | ||
|
|
fac4ef81b2 | ||
|
|
e494e138fe | ||
|
|
5805a37d27 | ||
|
|
ad04a6fcc4 | ||
|
|
7084a4361e | ||
|
|
a009299433 | ||
|
|
1c038760ce | ||
|
|
eafa942a30 | ||
|
|
05468dfc8d | ||
|
|
ff7ed00714 | ||
|
|
3c0094a5fe | ||
|
|
923c0e24b1 | ||
|
|
3b57e86cd3 | ||
|
|
1a6987558a | ||
|
|
a15d54c4a8 | ||
|
|
3c4c1222d8 | ||
|
|
250def49d5 | ||
|
|
b1e3d147f5 | ||
|
|
6c89b81d7b | ||
|
|
7c7969ed55 | ||
|
|
29920f8c9c | ||
|
|
9ebb916902 | ||
|
|
4369359286 | ||
|
|
1dab94c625 | ||
|
|
6c0f804f32 | ||
|
|
7991f67863 | ||
|
|
22ab1c4901 | ||
|
|
53cb92038a | ||
|
|
4425378b37 | ||
|
|
7fda78af40 | ||
|
|
6e8320a6dc | ||
|
|
99682ecbdb | ||
|
|
bf657a33e3 | ||
|
|
bab1b9302e | ||
|
|
8ce6f43e35 | ||
|
|
ecee324c00 | ||
|
|
0934a39d73 | ||
|
|
7673ef084d | ||
|
|
55e010ca52 | ||
|
|
1ef242a5c1 | ||
|
|
071c71efbc | ||
|
|
798775775b | ||
|
|
2ca601ef22 | ||
|
|
1cfb326e2f | ||
|
|
675fbee1f3 | ||
|
|
d055f0edac | ||
|
|
1f48b16acb | ||
|
|
41d4857d73 | ||
|
|
f7dbf9a20b | ||
|
|
d7a3a0bce3 | ||
|
|
7483cdebfb | ||
|
|
e7e44b96ee | ||
|
|
43388a06ca | ||
|
|
ace3f452c3 | ||
|
|
fb9d10772a | ||
|
|
a5014a8c71 | ||
|
|
8ce4b39fed | ||
|
|
f01f94a691 | ||
|
|
04cd5e80ee | ||
|
|
4fd1500312 | ||
|
|
5b74d8c444 | ||
|
|
1d683ea83e | ||
|
|
38652b168a | ||
|
|
cca8c10f33 | ||
|
|
2ffa265d8c | ||
|
|
ad850412d2 | ||
|
|
4f0c2bf376 | ||
|
|
fa75251c76 | ||
|
|
3fefebd05d | ||
|
|
9d7529118e | ||
|
|
507e7672c2 | ||
|
|
9c81d374b1 | ||
|
|
38c3703d08 | ||
|
|
973dc13cc0 | ||
|
|
bca93f6c83 | ||
|
|
caf6bfb76f | ||
|
|
76180184a5 | ||
|
|
0e1e954768 | ||
|
|
b031817fce | ||
|
|
6b2e63e66c | ||
|
|
085a1e512f | ||
|
|
31cb23f586 | ||
|
|
6a7ca4311e | ||
|
|
d87078bee6 | ||
|
|
50228116e1 | ||
|
|
95033f3f76 | ||
|
|
a8acbe5cfb | ||
|
|
f9d4c4dbac | ||
|
|
17abc6c736 | ||
|
|
94bd9564d0 | ||
|
|
c6cb6595be | ||
|
|
a2f25c2f3b | ||
|
|
5d3c4ed96c | ||
|
|
7cec8f2285 | ||
|
|
86777e7863 | ||
|
|
853fea16b4 | ||
|
|
9cf76b1233 | ||
|
|
66a65aab02 | ||
|
|
5581915bc0 | ||
|
|
ee7f4e1d52 | ||
|
|
8c65985cd0 | ||
|
|
23a58eb5da | ||
|
|
9193eef1c9 | ||
|
|
e90e9bc352 | ||
|
|
a1d860f818 | ||
|
|
d733d68b0c | ||
|
|
4a96d65408 | ||
|
|
1e16ed5e55 | ||
|
|
782352ae56 | ||
|
|
d97ba4eb0d | ||
|
|
282246fff2 | ||
|
|
b3059164aa | ||
|
|
64166319ee | ||
|
|
b8e732e526 | ||
|
|
f0d926ebba | ||
|
|
1e48d10617 | ||
|
|
ce9d706716 | ||
|
|
81abbca12f | ||
|
|
2cd67b296e | ||
|
|
7976d6d805 | ||
|
|
df395786bd | ||
|
|
2412aae68f | ||
|
|
0a42e2969a | ||
|
|
b51e6b0485 | ||
|
|
e1ed7c65e7 | ||
|
|
cf89d74561 | ||
|
|
38aec4d875 | ||
|
|
23f0a27acc | ||
|
|
447cb7a726 | ||
|
|
fa5a339434 | ||
|
|
7a295dd5fa | ||
|
|
2895b0acca | ||
|
|
ab9cdd7fce | ||
|
|
cc6fa9acbf | ||
|
|
e14dcccd37 | ||
|
|
27526399f5 | ||
|
|
8009e8108b | ||
|
|
b45d48f4f1 | ||
|
|
b9f1950320 | ||
|
|
6de2b4559e | ||
|
|
0661f537cf | ||
|
|
b737b2e7fc | ||
|
|
d9b3f276b8 | ||
|
|
53ab0168e4 | ||
|
|
01f0c35651 | ||
|
|
75d55783c0 | ||
|
|
f03aaef72f | ||
|
|
f54e426bb1 | ||
|
|
5b94ddc703 | ||
|
|
477461325d | ||
|
|
3094af8a5e | ||
|
|
add7dcc763 | ||
|
|
df7acbcad4 | ||
|
|
15b91126d5 | ||
|
|
2b24a7b520 | ||
|
|
b404c7583b | ||
|
|
6ce337ca38 | ||
|
|
d0caa630af | ||
|
|
8a48d604a8 | ||
|
|
80b0aa3842 | ||
|
|
c6a383590d | ||
|
|
fd34958ffa | ||
|
|
530a34a3f3 | ||
|
|
90093b5d8c | ||
|
|
939dad5900 | ||
|
|
85717527d9 | ||
|
|
768be74f74 | ||
|
|
a885ffd64b | ||
|
|
e25f1ee72f | ||
|
|
6e943832d5 | ||
|
|
3a3bc2ffb1 | ||
|
|
90a421e4af | ||
|
|
bc72ffb6b2 | ||
|
|
a30f0aca85 | ||
|
|
2ea2ec90d2 | ||
|
|
22670acfbe | ||
|
|
358a5af98e | ||
|
|
c70bd05494 | ||
|
|
0b4d52a141 | ||
|
|
a47c86c54c | ||
|
|
082ea3c295 | ||
|
|
a4177ad30b | ||
|
|
3603766f1c | ||
|
|
951429fe67 | ||
|
|
f5ff7e15cf | ||
|
|
c9c95f2e9e | ||
|
|
bc79fba49a | ||
|
|
b51fb32054 | ||
|
|
c9ecd023fa | ||
|
|
c28aa819b6 | ||
|
|
f6ca45c384 | ||
|
|
75de34de90 | ||
|
|
429a0d00af | ||
|
|
acf933646b | ||
|
|
b427202237 | ||
|
|
8eaa9463c1 | ||
|
|
e15f04c01b | ||
|
|
626baab73d | ||
|
|
5e8f861eac | ||
|
|
9217553a3c | ||
|
|
ab20dc98f7 | ||
|
|
9f1315fa64 | ||
|
|
46d158d023 | ||
|
|
acd80370e6 | ||
|
|
9ad19bfe52 | ||
|
|
eed14719db | ||
|
|
589c821f9b | ||
|
|
a09795c8a7 | ||
|
|
52df29917b | ||
|
|
16ae081c4c | ||
|
|
489d1629fb | ||
|
|
9be8aebfff | ||
|
|
e53fa1a5a2 | ||
|
|
92d1e226d3 | ||
|
|
64dbb7ed9c | ||
|
|
21b0f4b0d2 | ||
|
|
fc448e49d5 | ||
|
|
7a21e4bb0d | ||
|
|
47ca8a61ea | ||
|
|
1c3f889f6e | ||
|
|
6f4a0f9cbb | ||
|
|
67c1957eb0 | ||
|
|
3d7796f38c | ||
|
|
2d431dacbc | ||
|
|
17468c8863 | ||
|
|
475670de7d | ||
|
|
f9efb67bc2 | ||
|
|
9766ff1805 | ||
|
|
cc4227e3f2 | ||
|
|
ba2e8149c8 | ||
|
|
b48371e971 | ||
|
|
8b074767db | ||
|
|
e5bc26c75a | ||
|
|
959fa74ca5 | ||
|
|
ac57970229 | ||
|
|
9fb8cfc1b3 | ||
|
|
06ad6c53f7 | ||
|
|
a9b0b14149 | ||
|
|
9a454e714d | ||
|
|
319b3d8434 | ||
|
|
2fec2b4107 | ||
|
|
382aa26859 | ||
|
|
d7854b6dfa | ||
|
|
e3b6c12925 | ||
|
|
d9224348ce | ||
|
|
6b91c6f430 | ||
|
|
7e9b96e354 | ||
|
|
8a8d4619de | ||
|
|
3af0902f28 | ||
|
|
6b4c1a4239 | ||
|
|
783d29794a | ||
|
|
a094c50f5a | ||
|
|
621e8cf0ff | ||
|
|
4bd9336139 | ||
|
|
c517833663 | ||
|
|
8e4cc8df00 | ||
|
|
94f4c4cd2d | ||
|
|
c4c99999bc | ||
|
|
6abd3a4ed6 | ||
|
|
9e94120d68 | ||
|
|
ba088b8fc0 | ||
|
|
98ac1817cb | ||
|
|
65a31e34c9 | ||
|
|
264f1ef992 | ||
|
|
b30bbc0e74 | ||
|
|
7a77686878 | ||
|
|
0c4200306b | ||
|
|
619b1b4e2a | ||
|
|
57d22664f4 | ||
|
|
38339b7cd9 | ||
|
|
d5cb19aeab | ||
|
|
3d04e56228 | ||
|
|
3e8f7684f2 | ||
|
|
c11527780a | ||
|
|
5a204741b9 | ||
|
|
b23e8a77fc | ||
|
|
e926266c62 | ||
|
|
1eca4f8c0d | ||
|
|
edb1824006 | ||
|
|
6666262e51 | ||
|
|
221ee6c26b | ||
|
|
d3d4afd223 | ||
|
|
f55f64b5b9 | ||
|
|
69fbb9a87d | ||
|
|
8e50e8e8c3 | ||
|
|
8cdf71b539 | ||
|
|
e7f4b63212 | ||
|
|
12adf3be32 | ||
|
|
087516a783 | ||
|
|
1b2a2fc7f9 | ||
|
|
3e205dba15 | ||
|
|
ff874575e1 | ||
|
|
1e1516c968 | ||
|
|
aeb6de996c | ||
|
|
82d87111fc | ||
|
|
49953d53ed | ||
|
|
13a4133da5 | ||
|
|
a02ae19de2 | ||
|
|
9617f22fcd | ||
|
|
e156d62e44 | ||
|
|
f4e8352f5a | ||
|
|
deb7f72be2 | ||
|
|
a5a57fa2be | ||
|
|
c3fb1d52f4 | ||
|
|
9820dce775 | ||
|
|
426df2c9ab | ||
|
|
20c7a00af5 | ||
|
|
00d0f1e9d9 | ||
|
|
4cecac4ea4 | ||
|
|
b0e2bde84d | ||
|
|
49851c8795 | ||
|
|
7bdb39c743 | ||
|
|
09495582c4 | ||
|
|
f15be9582a | ||
|
|
c022107515 | ||
|
|
373b593c3e | ||
|
|
ca06c0e09f | ||
|
|
bd1086c244 | ||
|
|
69c8bf7959 | ||
|
|
db6b4f1344 | ||
|
|
05db6e3981 | ||
|
|
2623eeb82e | ||
|
|
cbebadc16a | ||
|
|
614d6d81e5 | ||
|
|
cac451c83e | ||
|
|
54a86c69e1 | ||
|
|
ea8f5c0f33 | ||
|
|
340d576931 | ||
|
|
7db8820042 | ||
|
|
54761b22fd | ||
|
|
253f13640c | ||
|
|
97110c9676 | ||
|
|
9805c4d907 | ||
|
|
56d548ad10 | ||
|
|
c196f6ee08 | ||
|
|
db55841e7d | ||
|
|
fb70ef7b1c | ||
|
|
fa82223c50 | ||
|
|
6f3cd87993 | ||
|
|
3ca7ac613d | ||
|
|
fe5b2f97e3 | ||
|
|
220bf92a3c | ||
|
|
5219fd59e8 | ||
|
|
4832da5cda | ||
|
|
4ef3dcffc4 | ||
|
|
fbe4768658 | ||
|
|
f63de3cc30 | ||
|
|
7c7d9e07a2 | ||
|
|
708f1e17f4 | ||
|
|
8fc48cf24a |
@@ -0,0 +1,12 @@
|
||||
## Expected behavior
|
||||
|
||||
## Actual behavior
|
||||
|
||||
## Steps to reproduce the behavior
|
||||
|
||||
## mc --version
|
||||
- (paste output of `mc --version`)
|
||||
|
||||
## System information
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Bug report template
|
||||
title: ''
|
||||
labels: community, triage
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
## Expected behavior
|
||||
|
||||
## Actual behavior
|
||||
|
||||
## Steps to reproduce the behavior
|
||||
|
||||
## mc --version
|
||||
- (paste output of `mc --version`)
|
||||
|
||||
## System information
|
||||
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: MinIO Community Support
|
||||
url: https://slack.min.io
|
||||
about: Please ask and answer questions here.
|
||||
@@ -0,0 +1,39 @@
|
||||
# Configuration for Lock Threads - https://github.com/dessant/lock-threads-app
|
||||
|
||||
# Number of days of inactivity before a closed issue or pull request is locked
|
||||
daysUntilLock: 365
|
||||
|
||||
# Skip issues and pull requests created before a given timestamp. Timestamp must
|
||||
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable
|
||||
skipCreatedBefore: false
|
||||
|
||||
# Issues and pull requests with these labels will be ignored. Set to `[]` to disable
|
||||
exemptLabels: []
|
||||
|
||||
# Label to add before locking, such as `outdated`. Set to `false` to disable
|
||||
lockLabel: false
|
||||
|
||||
# Comment to post before locking. Set to `false` to disable
|
||||
lockComment: >-
|
||||
|
||||
This thread has been automatically locked since there has not been
|
||||
any recent activity after it was closed. Please open a new issue for
|
||||
related bugs.
|
||||
|
||||
# Assign `resolved` as the reason for locking. Set to `false` to disable
|
||||
setLockReason: true
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
only: issues
|
||||
|
||||
# Optionally, specify configuration settings just for `issues` or `pulls`
|
||||
# issues:
|
||||
# exemptLabels:
|
||||
# - help-wanted
|
||||
# lockLabel: outdated
|
||||
|
||||
# pulls:
|
||||
# daysUntilLock: 30
|
||||
|
||||
# Repository to extend settings from
|
||||
# _extends: repo
|
||||
@@ -0,0 +1,59 @@
|
||||
# Configuration for probot-stale - https://github.com/probot/stale
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
||||
daysUntilStale: 90
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
|
||||
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
|
||||
daysUntilClose: 30
|
||||
|
||||
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
|
||||
onlyLabels: []
|
||||
|
||||
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
||||
exemptLabels:
|
||||
- "security"
|
||||
- "pending discussion"
|
||||
|
||||
# Set to true to ignore issues in a project (defaults to false)
|
||||
exemptProjects: false
|
||||
|
||||
# Set to true to ignore issues in a milestone (defaults to false)
|
||||
exemptMilestones: false
|
||||
|
||||
# Set to true to ignore issues with an assignee (defaults to false)
|
||||
exemptAssignees: false
|
||||
|
||||
# Label to use when marking as stale
|
||||
staleLabel: stale
|
||||
|
||||
# Comment to post when marking as stale. Set to `false` to disable
|
||||
markComment: >-
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed after 21 days if no further activity
|
||||
occurs. Thank you for your contributions.
|
||||
# Comment to post when removing the stale label.
|
||||
# unmarkComment: >
|
||||
# Your comment here.
|
||||
|
||||
# Comment to post when closing a stale Issue or Pull Request.
|
||||
# closeComment: >
|
||||
# Your comment here.
|
||||
|
||||
# Limit the number of actions per hour, from 1-30. Default is 30
|
||||
limitPerRun: 1
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
# only: issues
|
||||
|
||||
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
|
||||
# pulls:
|
||||
# daysUntilStale: 30
|
||||
# markComment: >
|
||||
# This pull request has been automatically marked as stale because it has not had
|
||||
# recent activity. It will be closed if no further activity occurs. Thank you
|
||||
# for your contributions.
|
||||
|
||||
# issues:
|
||||
# exemptLabels:
|
||||
# - confirmed
|
||||
@@ -0,0 +1,75 @@
|
||||
name: Go
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
# This ensures that previous jobs for the PR are canceled when the PR is
|
||||
# updated.
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Test on Go ${{ matrix.go-version }} and ${{ matrix.os }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
env:
|
||||
GO111MODULE: on
|
||||
strategy:
|
||||
matrix:
|
||||
go-version: [1.17.x, 1.18.x]
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
steps:
|
||||
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
|
||||
uses: actions/setup-go@v1
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
id: go
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v1
|
||||
|
||||
- name: Build on ${{ matrix.os }}
|
||||
if: matrix.os == 'windows-latest'
|
||||
run: |
|
||||
go build --ldflags="-s -w" -o %GOPATH%\bin\mc.exe
|
||||
go test -v -race --timeout 30m ./...
|
||||
- name: Build on ${{ matrix.os }}
|
||||
if: matrix.os == 'macos-latest'
|
||||
run: |
|
||||
go build --ldflags="-s -w" -o %GOPATH%\bin\mc
|
||||
go test -v -race --timeout 30m ./...
|
||||
- name: Build on ${{ matrix.os }}
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
env:
|
||||
ACCESS_KEY: minioadmin
|
||||
SECRET_KEY: minioadmin
|
||||
ENABLE_HTTPS: 1
|
||||
MINIO_CI_CD: 1
|
||||
SERVER_ENDPOINT: localhost:9000
|
||||
run: |
|
||||
wget https://dl.min.io/server/minio/release/linux-amd64/minio && chmod +x minio
|
||||
mkdir -p ~/.minio/certs/ && cp testdata/localhost.crt ~/.minio/certs/public.crt && cp testdata/localhost.key ~/.minio/certs/private.key
|
||||
sudo cp testdata/localhost.crt /usr/local/share/ca-certificates/ && sudo update-ca-certificates
|
||||
./minio server /tmp/test-xl/{1...4}/ & sleep 10
|
||||
make
|
||||
make test-race
|
||||
make verify
|
||||
make crosscompile
|
||||
vetchecks: # Run vet checks against one version.
|
||||
env:
|
||||
CGO_ENABLED: 0
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17.x
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Test 386
|
||||
run: GOOS=linux GOARCH=386 go test -short ./...
|
||||
+10
-1
@@ -1,4 +1,13 @@
|
||||
cover.out
|
||||
mc
|
||||
*~
|
||||
*.test
|
||||
release
|
||||
experimental
|
||||
coverage.txt
|
||||
*.tar.bz2
|
||||
parts/
|
||||
prime/
|
||||
stage/
|
||||
mc
|
||||
.run*
|
||||
.idea/
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
linters-settings:
|
||||
golint:
|
||||
min-confidence: 0
|
||||
|
||||
misspell:
|
||||
locale: US
|
||||
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- typecheck
|
||||
- goimports
|
||||
- misspell
|
||||
- govet
|
||||
- revive
|
||||
- ineffassign
|
||||
- deadcode
|
||||
- structcheck
|
||||
- gomodguard
|
||||
- gofmt
|
||||
- unused
|
||||
- structcheck
|
||||
- varcheck
|
||||
- gofumpt
|
||||
|
||||
linters-settings:
|
||||
gofumpt:
|
||||
lang-version: "1.17"
|
||||
|
||||
# Choose whether or not to use the extra rules that are disabled
|
||||
# by default
|
||||
extra-rules: false
|
||||
|
||||
issues:
|
||||
exclude-use-default: false
|
||||
exclude:
|
||||
- instead of using struct literal
|
||||
- should have a package comment
|
||||
- error strings should not be capitalized or end with punctuation or a newline
|
||||
|
||||
service:
|
||||
golangci-lint-version: 1.43.0 # use the fixed version to not introduce new linters unexpectedly
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
project_name: mc
|
||||
|
||||
release:
|
||||
name_template: "Version {{.Version}}"
|
||||
disable: true
|
||||
github:
|
||||
owner: minio
|
||||
name: mc
|
||||
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
- GO111MODULE=on
|
||||
|
||||
before:
|
||||
hooks:
|
||||
- make clean
|
||||
- go generate ./...
|
||||
- go mod tidy
|
||||
- go mod download
|
||||
|
||||
builds:
|
||||
-
|
||||
goos:
|
||||
- linux
|
||||
- darwin
|
||||
- windows
|
||||
- freebsd
|
||||
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
- arm
|
||||
- ppc64le
|
||||
- s390x
|
||||
|
||||
goarm:
|
||||
- 7
|
||||
|
||||
ignore:
|
||||
- goos: darwin
|
||||
goarch: arm64
|
||||
- goos: darwin
|
||||
goarch: arm
|
||||
- goos: darwin
|
||||
goarch: ppc64le
|
||||
- goos: darwin
|
||||
goarch: s390x
|
||||
- goos: windows
|
||||
goarch: arm64
|
||||
- goos: windows
|
||||
goarch: arm
|
||||
- goos: windows
|
||||
goarch: ppc64le
|
||||
- goos: windows
|
||||
goarch: s390x
|
||||
- goos: freebsd
|
||||
goarch: arm
|
||||
- goos: freebsd
|
||||
goarch: arm64
|
||||
- goos: freebsd
|
||||
goarch: ppc64le
|
||||
- goos: freebsd
|
||||
goarch: s390x
|
||||
|
||||
flags:
|
||||
- -tags=kqueue
|
||||
- -trimpath
|
||||
|
||||
ldflags:
|
||||
- "-s -w -X github.com/minio/mc/cmd.Version={{.Version}} -X github.com/minio/mc/cmd.ReleaseTag={{.Tag}} -X github.com/minio/mc/cmd.CommitID={{.FullCommit}} -X github.com/minio/mc/cmd.ShortCommitID={{.ShortCommit}}"
|
||||
|
||||
archives:
|
||||
-
|
||||
format: binary
|
||||
name_template: "{{ .Binary }}-release/{{ .Os }}-{{ .Arch }}/{{ .Binary }}.{{ .Version }}"
|
||||
|
||||
nfpms:
|
||||
-
|
||||
id: minio
|
||||
package_name: mc
|
||||
vendor: MinIO, Inc.
|
||||
homepage: https://min.io/
|
||||
maintainer: dev@min.io
|
||||
description: MinIO Client (mc) provides a modern alternative to UNIX commands like ls, cat, cp, mirror, diff, find etc. It supports filesystems and Amazon S3 compatible cloud storage service (AWS Signature v2 and v4).
|
||||
license: Apache 2.0
|
||||
bindir: /usr/bin
|
||||
formats:
|
||||
- deb
|
||||
- rpm
|
||||
overrides:
|
||||
deb:
|
||||
file_name_template: "{{ .Binary }}-release/debs/{{ .ProjectName }}-{{ .Version }}_{{ .Arch }}"
|
||||
replacements:
|
||||
arm: armv7
|
||||
files:
|
||||
"NOTICE": "/usr/share/mc/NOTICE"
|
||||
"CREDITS": "/usr/share/mc/CREDITS"
|
||||
"LICENSE": "/usr/share/mc/LICENSE"
|
||||
"README.md": "/usr/share/mc/README.md"
|
||||
rpm:
|
||||
file_name_template: "{{ .Binary }}-release/rpms/{{ .ProjectName }}-{{ .Version }}.{{ .Arch }}"
|
||||
replacements:
|
||||
amd64: x86_64
|
||||
arm64: aarch64
|
||||
arm: armv7
|
||||
files:
|
||||
"NOTICE": "/usr/share/mc/NOTICE"
|
||||
"CREDITS": "/usr/share/mc/CREDITS"
|
||||
"LICENSE": "/usr/share/mc/LICENSE"
|
||||
"README.md": "/usr/share/mc/README.md"
|
||||
|
||||
checksum:
|
||||
algorithm: sha256
|
||||
|
||||
signs:
|
||||
-
|
||||
signature: "${artifact}.asc"
|
||||
cmd: "sh"
|
||||
args:
|
||||
- '-c'
|
||||
- 'gpg --quiet --detach-sign -a ${artifact}'
|
||||
artifacts: all
|
||||
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^Update yaml files'
|
||||
|
||||
dockers:
|
||||
-
|
||||
goos: linux
|
||||
goarch: amd64
|
||||
dockerfile: Dockerfile.release
|
||||
image_templates:
|
||||
- minio/mc:{{ .Tag }}
|
||||
- minio/mc:latest
|
||||
|
||||
-
|
||||
goos: linux
|
||||
goarch: ppc64le
|
||||
dockerfile: Dockerfile.ppc64le.release
|
||||
image_templates:
|
||||
- minio/mc:{{ .Tag }}-ppc64le
|
||||
|
||||
-
|
||||
goos: linux
|
||||
goarch: s390x
|
||||
dockerfile: Dockerfile.s390x.release
|
||||
image_templates:
|
||||
- minio/mc:{{ .Tag }}-s390x
|
||||
|
||||
-
|
||||
goos: linux
|
||||
goarch: arm64
|
||||
goarm: ''
|
||||
dockerfile: Dockerfile.arm64.release
|
||||
image_templates:
|
||||
- minio/mc:{{ .Tag }}-arm64
|
||||
|
||||
-
|
||||
goos: linux
|
||||
goarch: arm
|
||||
goarm: '7'
|
||||
dockerfile: Dockerfile.arm.release
|
||||
image_templates:
|
||||
- minio/mc:{{ .Tag }}-arm
|
||||
@@ -6,10 +6,10 @@
|
||||
#
|
||||
# For explanation on this file format: man git-shortlog
|
||||
|
||||
Anand Babu (AB) Periasamy <ab@minio.io> Anand Babu (AB) Periasamy <abperiasamy@users.noreply.github.com>
|
||||
Anand Babu (AB) Periasamy <ab@minio.io> <ab@unlocksmith.org>
|
||||
Anand Babu (AB) Periasamy <ab@min.io> Anand Babu (AB) Periasamy <abperiasamy@users.noreply.github.com>
|
||||
Anand Babu (AB) Periasamy <ab@min.io> <ab@unlocksmith.org>
|
||||
Anis Elleuch <vadmeste@gmail.com>
|
||||
Frederick F. Kautz IV <fkautz@minio.io> <fkautz@alumni.cmu.edu>
|
||||
Harshavardhana <harsha@minio.io> <harsha@harshavardhana.net>
|
||||
Krishna Srinivas <krishna@minio.io> <krishna.srinivas@gmail.com>
|
||||
Frederick F. Kautz IV <fkautz@min.io> <fkautz@alumni.cmu.edu>
|
||||
Harshavardhana <harsha@min.io> <harsha@harshavardhana.net>
|
||||
Krishna Srinivas <krishna@min.io> <krishna.srinivas@gmail.com>
|
||||
Bosky <bosky@helpshift.com>
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
sudo: false
|
||||
language: go
|
||||
|
||||
script:
|
||||
- make test GOFLAGS="-race"
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
|
||||
env:
|
||||
- ARCH=x86_64
|
||||
- ARCH=i686
|
||||
|
||||
go:
|
||||
- 1.5.2
|
||||
- 1.5.3
|
||||
|
||||
script:
|
||||
- diff -au <(gofmt -d *.go) <(printf "")
|
||||
- diff -au <(gofmt -d pkg) <(printf "")
|
||||
|
||||
notifications:
|
||||
slack:
|
||||
secure: McinxQ4R/Yu2r/U8lVsdAIQ195Rf+3/Ku6DViWyqLHsTt5fTnVrSfbIKs8vy0t2A0bRLO6zv2xOSMWjfiimZLPMgMbMqLtTFEzUzB8RZyx2n2xgmL8q3gjXcLA3vkBreaRYCzJzX6DjvrxRfhyOg+BQHpLpACWik3FS/7VIdDCI=
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
## mc (MinIO Client) v/s Midnight Commander (mc)
|
||||
|
||||
There has been some amount of [requests](https://github.com/minio/mc/issues?q=is%3Aissue+midnight+commander+is%3Aclosed) on renaming this project to avoid the conflict with Midnight Commander for Unix distributions. We struggled with this, it is harder to find a name sweeter and shorter than `mc` for MinIO Client.
|
||||
|
||||
Besides `mc` is a single static binary and can reside inside your application and is fully self contained. Midnight Commander (mc) is a free software clone of Norton Commander (nc). MinIO and Midnight shares no code or ideas. Only their abbreviation matches.
|
||||
|
||||
Package managers are free to choose a different name if they like. One such solution [pointed out](https://github.com/minio/mc/issues/873#issuecomment-267583013) by one of our community members.
|
||||
|
||||
```
|
||||
mv ./mc ./mcli
|
||||
```
|
||||
+4
-8
@@ -1,6 +1,6 @@
|
||||
### Setup your mc Github Repository
|
||||
Fork [mc upstream](https://github.com/minio/mc/fork) source repository to your own personal repository.
|
||||
```sh
|
||||
```
|
||||
$ mkdir -p $GOPATH/src/github.com/minio
|
||||
$ cd $GOPATH/src/github.com/minio
|
||||
$ git clone https://github.com/$USER_ID/mc
|
||||
@@ -20,20 +20,16 @@ $ mc --help
|
||||
- Push to the branch (git push origin my-new-feature)
|
||||
- Create new Pull Request
|
||||
|
||||
* If you have additional dependencies for ``mc``, ``mc`` manages its dependencies using [govendor](https://github.com/kardianos/govendor)
|
||||
* If you have additional dependencies for ``mc``, ``mc`` manages its dependencies using `go mod`
|
||||
- Run `go get foo/bar`
|
||||
- Edit your code to import foo/bar
|
||||
- Run `make pkg-add PKG=foo/bar` from top-level folder
|
||||
|
||||
* If you have dependencies which needs to be removed from ``mc``
|
||||
- Edit your code to not import foo/bar
|
||||
- Run `make pkg-remove PKG=foo/bar` from top-level folder
|
||||
- Run `GO111MODULE=on go mod tidy` from top-level folder
|
||||
|
||||
* When you're ready to create a pull request, be sure to:
|
||||
- Have test cases for the new code. If you have questions about how to do it, please ask in your pull request.
|
||||
- Run `go fmt`
|
||||
- Squash your commits into a single commit. `git rebase -i`. It's okay to force update your pull request.
|
||||
- Make sure `make build` completes.
|
||||
- Make sure `make install` completes.
|
||||
|
||||
* Read [Effective Go](https://github.com/golang/go/wiki/CodeReviewComments) article from Golang project
|
||||
- `mc` project is conformant with Golang style
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
## Contributors
|
||||
<!-- DO NOT EDIT - CONTRIBUTORS.md is autogenerated from git commit log by contributors.sh script. -->
|
||||
|
||||
- Anand Babu (AB) Periasamy <ab@minio.io>
|
||||
- Anis Elleuch <vadmeste@gmail.com>
|
||||
- Bosky <bosky@helpshift.com>
|
||||
- Frederick F. Kautz IV <fkautz@minio.io>
|
||||
- Harshavardhana <harsha@minio.io>
|
||||
- Krishna Srinivas <krishna@minio.io>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
FROM golang:1.17-alpine as builder
|
||||
|
||||
LABEL maintainer="MinIO Inc <dev@min.io>"
|
||||
|
||||
ENV GOPATH /go
|
||||
ENV CGO_ENABLED 0
|
||||
ENV GO111MODULE on
|
||||
|
||||
RUN \
|
||||
apk add --no-cache git && \
|
||||
git clone https://github.com/minio/mc && cd mc && \
|
||||
go install -v -ldflags "$(go run buildscripts/gen-ldflags.go)"
|
||||
|
||||
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
COPY --from=builder /go/bin/mc /usr/bin/mc
|
||||
COPY --from=builder /go/mc/CREDITS /licenses/CREDITS
|
||||
COPY --from=builder /go/mc/LICENSE /licenses/LICENSE
|
||||
|
||||
RUN \
|
||||
microdnf update --nodocs && \
|
||||
microdnf install ca-certificates --nodocs && \
|
||||
microdnf clean all
|
||||
|
||||
ENTRYPOINT ["mc"]
|
||||
@@ -0,0 +1,14 @@
|
||||
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5
|
||||
|
||||
LABEL maintainer="MinIO Inc <dev@min.io>"
|
||||
|
||||
COPY mc /usr/bin/
|
||||
COPY CREDITS /licenses/CREDITS
|
||||
COPY LICENSE /licenses/LICENSE
|
||||
|
||||
RUN \
|
||||
microdnf update --nodocs && \
|
||||
microdnf install ca-certificates --nodocs && \
|
||||
microdnf clean all
|
||||
|
||||
ENTRYPOINT ["mc"]
|
||||
@@ -0,0 +1,19 @@
|
||||
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5
|
||||
|
||||
ARG TARGETARCH
|
||||
|
||||
ARG RELEASE
|
||||
|
||||
LABEL maintainer="MinIO Inc <dev@min.io>"
|
||||
|
||||
COPY CREDITS /licenses/CREDITS
|
||||
COPY LICENSE /licenses/LICENSE
|
||||
|
||||
RUN \
|
||||
microdnf update --nodocs && \
|
||||
microdnf install curl ca-certificates shadow-utils --nodocs && \
|
||||
microdnf clean all && \
|
||||
curl -s -q https://dl.minio.io/client/mc/release/linux-${TARGETARCH}/archive/mc.${RELEASE} -o /usr/bin/mc && \
|
||||
chmod +x /usr/bin/mc
|
||||
|
||||
ENTRYPOINT ["mc"]
|
||||
@@ -1,86 +0,0 @@
|
||||
## Ubuntu (Kylin) 14.04
|
||||
### Build Dependencies
|
||||
This installation guide is based on Ubuntu 14.04+ on x86-64 platform.
|
||||
|
||||
##### Install Git, GCC
|
||||
```sh
|
||||
$ sudo apt-get install git build-essential
|
||||
```
|
||||
|
||||
##### Install Go 1.5+
|
||||
|
||||
Download Go 1.5+ from [https://golang.org/dl/](https://golang.org/dl/).
|
||||
|
||||
```sh
|
||||
$ wget https://storage.googleapis.com/golang/go1.5.1.linux-amd64.tar.gz
|
||||
$ mkdir -p ${HOME}/bin/
|
||||
$ mkdir -p ${HOME}/go/
|
||||
$ tar -C ${HOME}/bin/ -xzf go1.5.1.linux-amd64.tar.gz
|
||||
```
|
||||
##### Setup GOROOT and GOPATH
|
||||
|
||||
Add the following exports to your ``~/.bashrc``. Environment variable GOROOT specifies the location of your golang binaries
|
||||
and GOPATH specifies the location of your project workspace.
|
||||
|
||||
```sh
|
||||
export GOROOT=${HOME}/bin/go
|
||||
export GOPATH=${HOME}/go
|
||||
export PATH=$PATH:${HOME}/bin/go/bin:${GOPATH}/bin
|
||||
```
|
||||
|
||||
##### Source the new environment
|
||||
|
||||
```sh
|
||||
$ source ~/.bashrc
|
||||
```
|
||||
|
||||
##### Testing it all
|
||||
```sh
|
||||
$ go env
|
||||
```
|
||||
|
||||
## OS X (Yosemite) 10.10
|
||||
### Build Dependencies
|
||||
This installation document assumes OS X Yosemite 10.10+ on x86-64 platform.
|
||||
|
||||
##### Install brew
|
||||
```sh
|
||||
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
||||
```
|
||||
|
||||
##### Install Git, Python
|
||||
```sh
|
||||
$ brew install git python
|
||||
```
|
||||
|
||||
##### Install Go 1.5+
|
||||
|
||||
Install golang binaries using `brew`
|
||||
|
||||
```sh
|
||||
$ brew install go
|
||||
$ mkdir -p $HOME/go
|
||||
```
|
||||
|
||||
##### Setup GOROOT and GOPATH
|
||||
|
||||
Add the following exports to your ``~/.bash_profile``. Environment variable GOROOT specifies the location of your golang binaries
|
||||
and GOPATH specifies the location of your project workspace.
|
||||
|
||||
```sh
|
||||
export GOPATH=${HOME}/go
|
||||
export GOVERSION=$(brew list go | head -n 1 | cut -d '/' -f 6)
|
||||
export GOROOT=$(brew --prefix)/Cellar/go/${GOVERSION}/libexec
|
||||
export PATH=$PATH:${GOPATH}/bin
|
||||
```
|
||||
|
||||
##### Source the new environment
|
||||
|
||||
```sh
|
||||
$ source ~/.bash_profile
|
||||
```
|
||||
|
||||
##### Testing it all
|
||||
```sh
|
||||
$ go env
|
||||
```
|
||||
@@ -1,202 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
Preamble
|
||||
|
||||
1. Definitions.
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
0. Definitions.
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
1. Source Code.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
2. Basic Permissions.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
@@ -1,85 +1,76 @@
|
||||
PWD := $(shell pwd)
|
||||
GOPATH := $(shell go env GOPATH)
|
||||
LDFLAGS := $(shell go run buildscripts/gen-ldflags.go)
|
||||
|
||||
GOARCH := $(shell go env GOARCH)
|
||||
GOOS := $(shell go env GOOS)
|
||||
|
||||
BUILD_LDFLAGS := '$(LDFLAGS)'
|
||||
|
||||
all: install
|
||||
VERSION ?= $(shell git describe --tags)
|
||||
TAG ?= "minio/mc:$(VERSION)"
|
||||
|
||||
checkdeps:
|
||||
@echo "Checking deps:"
|
||||
all: build
|
||||
|
||||
checks:
|
||||
@echo "Checking dependencies"
|
||||
@(env bash $(PWD)/buildscripts/checkdeps.sh)
|
||||
|
||||
checkgopath:
|
||||
@echo "Checking if project is at ${GOPATH}"
|
||||
@for mcpath in $(echo ${GOPATH} | sed 's/:/\n/g'); do if [ ! -d ${mcpath}/src/github.com/minio/mc ]; then echo "Project not found in ${mcpath}, please follow instructions provided at https://github.com/minio/minio/blob/master/CONTRIBUTING.md#setup-your-minio-github-repository" && exit 1; fi done
|
||||
@echo "BUILD_LDFLAGS: ${BUILD_LDFLAGS}"
|
||||
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.46.2
|
||||
@echo "Installing stringer" && go install -v golang.org/x/tools/cmd/stringer@latest
|
||||
|
||||
getdeps: checkdeps checkgopath
|
||||
@go get github.com/golang/lint/golint && echo "Installed golint:"
|
||||
@go get golang.org/x/tools/cmd/vet && echo "Installed vet:"
|
||||
@go get github.com/fzipp/gocyclo && echo "Installed gocyclo:"
|
||||
@go get github.com/remyoudompheng/go-misc/deadcode && echo "Installed deadcode:"
|
||||
crosscompile:
|
||||
@(env bash $(PWD)/buildscripts/cross-compile.sh)
|
||||
|
||||
# verifiers: getdeps vet fmt lint cyclo deadcode
|
||||
verifiers: getdeps vet fmt lint cyclo deadcode
|
||||
verifiers: getdeps vet lint
|
||||
|
||||
docker: build
|
||||
@docker build -t $(TAG) . -f Dockerfile.dev
|
||||
|
||||
vet:
|
||||
@echo "Running $@:"
|
||||
@GO15VENDOREXPERIMENT=1 go tool vet -all *.go
|
||||
@GO15VENDOREXPERIMENT=1 go tool vet -all ./pkg
|
||||
@GO15VENDOREXPERIMENT=1 go tool vet -shadow=true *.go
|
||||
@GO15VENDOREXPERIMENT=1 go tool vet -shadow=true ./pkg
|
||||
@echo "Running $@"
|
||||
@GO111MODULE=on go vet github.com/minio/mc/...
|
||||
|
||||
fmt:
|
||||
@echo "Running $@:"
|
||||
@GO15VENDOREXPERIMENT=1 gofmt -s -l *.go
|
||||
@GO15VENDOREXPERIMENT=1 gofmt -s -l pkg
|
||||
lint:
|
||||
@echo "Running $@:"
|
||||
@GO15VENDOREXPERIMENT=1 golint .
|
||||
@GO15VENDOREXPERIMENT=1 golint github.com/minio/mc/pkg...
|
||||
@echo "Running $@ check"
|
||||
@GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=5m --config ./.golangci.yml
|
||||
|
||||
cyclo:
|
||||
@echo "Running $@:"
|
||||
@GO15VENDOREXPERIMENT=1 gocyclo -over 40 *.go
|
||||
@GO15VENDOREXPERIMENT=1 gocyclo -over 40 pkg
|
||||
# Builds mc, runs the verifiers then runs the tests.
|
||||
check: test
|
||||
test: verifiers build
|
||||
@echo "Running unit tests"
|
||||
@GO111MODULE=on CGO_ENABLED=0 go test -tags kqueue ./... 1>/dev/null
|
||||
@echo "Running functional tests"
|
||||
@(env bash $(PWD)/functional-tests.sh)
|
||||
|
||||
deadcode:
|
||||
@echo "Running $@:"
|
||||
@GO15VENDOREXPERIMENT=1 deadcode
|
||||
test-race: verifiers build
|
||||
@echo "Running unit tests under -race"
|
||||
@GO111MODULE=on go test -race -v --timeout 20m ./... 1>/dev/null
|
||||
|
||||
build: verifiers
|
||||
@echo "Installing mc:"
|
||||
# Verify mc binary
|
||||
verify:
|
||||
@echo "Verifying build with race"
|
||||
@GO111MODULE=on CGO_ENABLED=1 go build -race -tags kqueue -trimpath --ldflags "$(LDFLAGS)" -o $(PWD)/mc 1>/dev/null
|
||||
@echo "Running functional tests"
|
||||
@(env bash $(PWD)/functional-tests.sh)
|
||||
|
||||
test: verifiers
|
||||
@echo "Running all testing:"
|
||||
@GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) ./
|
||||
@GO15VENDOREXPERIMENT=1 go test $(GOFLAGS) github.com/minio/mc/pkg...
|
||||
# Builds mc locally.
|
||||
build: checks
|
||||
@echo "Building mc binary to './mc'"
|
||||
@GO111MODULE=on CGO_ENABLED=0 go build -trimpath -tags kqueue --ldflags $(BUILD_LDFLAGS) -o $(PWD)/mc
|
||||
|
||||
gomake-all: build
|
||||
@GO15VENDOREXPERIMENT=1 go build --ldflags $(BUILD_LDFLAGS) -o $(GOPATH)/bin/mc
|
||||
@mkdir -p $(HOME)/.mc
|
||||
|
||||
coverage:
|
||||
@GO15VENDOREXPERIMENT=1 go test -race -coverprofile=cover.out ./
|
||||
@go tool cover -html=cover.out && echo "Visit your browser"
|
||||
|
||||
pkg-add:
|
||||
@GO15VENDOREXPERIMENT=1 govendor add $(PKG)
|
||||
|
||||
pkg-update:
|
||||
@GO15VENDOREXPERIMENT=1 govendor update $(PKG)
|
||||
|
||||
pkg-remove:
|
||||
@GO15VENDOREXPERIMENT=1 govendor remove $(PKG)
|
||||
|
||||
install: gomake-all
|
||||
|
||||
all-tests: test
|
||||
# TODO disable them for now.
|
||||
#@./tests/test-minio.sh
|
||||
|
||||
release:
|
||||
@./release.sh
|
||||
# Builds MinIO and installs it to $GOPATH/bin.
|
||||
install: build
|
||||
@echo "Installing mc binary to '$(GOPATH)/bin/mc'"
|
||||
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/mc $(GOPATH)/bin/mc
|
||||
@echo "Installation successful. To learn more, try \"mc --help\"."
|
||||
|
||||
clean:
|
||||
@rm -fv cover.out
|
||||
@rm -fv mc
|
||||
@echo "Cleaning up all the generated files"
|
||||
@find . -name '*.test' | xargs rm -fv
|
||||
@find . -name '*~' | xargs rm -fv
|
||||
@rm -rvf mc
|
||||
@rm -rvf build
|
||||
@rm -rvf release
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
Minio Client (C) 2014, 2015 Minio, Inc.
|
||||
MinIO Client (C) 2014-2020 MinIO, Inc.
|
||||
|
||||
This product includes software developed at Minio, Inc.
|
||||
(https://minio.io/).
|
||||
This product includes software developed at MinIO, Inc.
|
||||
(https://min.io/).
|
||||
|
||||
The Minio project contains unmodified/modified subcomponents too with
|
||||
The MinIO project contains unmodified/modified subcomponents too with
|
||||
separate copyright notices and license terms. Your use of the source
|
||||
code for the these subcomponents is subject to the terms and conditions
|
||||
of the following licenses.
|
||||
|
||||
@@ -1,106 +1,245 @@
|
||||
# Minio Client (mc) [](https://gitter.im/minio/minio?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
# MinIO Client Quickstart Guide
|
||||
[](https://slack.min.io) [](https://goreportcard.com/report/minio/mc) [](https://hub.docker.com/r/minio/mc/) [](https://github.com/minio/mc/blob/master/LICENSE)
|
||||
|
||||
``mc`` provides minimal tools to work with Amazon S3 compatible cloud storage and filesystems. It has features like resumable uploads/downloads, progress bar, parallel copy. ``mc`` is written in golang and released under [Apache license v2](./LICENSE).
|
||||
MinIO Client (mc) provides a modern alternative to UNIX commands like ls, cat, cp, mirror, diff, find etc. It supports filesystems and Amazon S3 compatible cloud storage service (AWS Signature v2 and v4).
|
||||
|
||||
## Commands
|
||||
|
||||
``mc`` implements the following commands
|
||||
```
|
||||
ls List files and folders.
|
||||
mb Make a bucket or folder.
|
||||
cat Display contents of a file.
|
||||
pipe Write contents of stdin to one or more targets. When no target is specified, it writes to stdout.
|
||||
share Generate URL for sharing.
|
||||
cp Copy one or more objects to a target.
|
||||
mirror Mirror folders recursively from a single source to many destinations.
|
||||
diff Compute differences between two folders.
|
||||
rm Remove file or bucket [WARNING: Use with care].
|
||||
access Manage bucket access permissions.
|
||||
session Manage saved sessions of cp and mirror operations.
|
||||
config Manage configuration file.
|
||||
update Check for a new software update.
|
||||
version Print version.
|
||||
alias set, remove and list aliases in configuration file
|
||||
ls list buckets and objects
|
||||
mb make a bucket
|
||||
rb remove a bucket
|
||||
cp copy objects
|
||||
mirror synchronize object(s) to a remote site
|
||||
cat display object contents
|
||||
head display first 'n' lines of an object
|
||||
pipe stream STDIN to an object
|
||||
share generate URL for temporary access to an object
|
||||
find search for objects
|
||||
sql run sql queries on objects
|
||||
stat show object metadata
|
||||
mv move objects
|
||||
tree list buckets and objects in a tree format
|
||||
du summarize disk usage recursively
|
||||
retention set retention for object(s)
|
||||
legalhold set legal hold for object(s)
|
||||
diff list differences in object name, size, and date between two buckets
|
||||
rm remove objects
|
||||
encrypt manage bucket encryption config
|
||||
event manage object notifications
|
||||
watch listen for object notification events
|
||||
undo undo PUT/DELETE operations
|
||||
policy manage anonymous access to buckets and objects
|
||||
tag manage tags for bucket(s) and object(s)
|
||||
ilm manage bucket lifecycle
|
||||
version manage bucket versioning
|
||||
replicate configure server side bucket replication
|
||||
admin manage MinIO servers
|
||||
update update mc to latest release
|
||||
```
|
||||
|
||||
## Install [](https://travis-ci.org/minio/mc) [](https://ci.appveyor.com/project/harshavardhana/mc)
|
||||
## Docker Container
|
||||
### Stable
|
||||
```
|
||||
docker pull minio/mc
|
||||
docker run minio/mc ls play
|
||||
```
|
||||
|
||||
#### GNU/Linux
|
||||
### Edge
|
||||
```
|
||||
docker pull minio/mc:edge
|
||||
docker run minio/mc:edge ls play
|
||||
```
|
||||
|
||||
Download ``mc`` for:
|
||||
**Note:** Above examples run `mc` against MinIO [_play_ environment](#test-your-setup) by default. To run `mc` against other S3 compatible servers, start the container this way:
|
||||
|
||||
- ``64-bit Intel`` from https://dl.minio.io/client/mc/release/linux-amd64/mc
|
||||
- ``32-bit Intel`` from https://dl.minio.io/client/mc/release/linux-386/mc
|
||||
- ``32-bit ARM`` from https://dl.minio.io/client/mc/release/linux-arm/mc
|
||||
```
|
||||
docker run -it --entrypoint=/bin/sh minio/mc
|
||||
```
|
||||
|
||||
~~~
|
||||
$ chmod +x mc
|
||||
$ ./mc --help
|
||||
~~~
|
||||
then use the [`mc alias` command](#add-a-cloud-storage-service).
|
||||
|
||||
#### OS X
|
||||
### GitLab CI
|
||||
When using the Docker container in GitLab CI, you must [set the entrypoint to an empty string](https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#override-the-entrypoint-of-an-image).
|
||||
|
||||
Download ``mc`` from https://dl.minio.io/client/mc/release/darwin-amd64/mc
|
||||
```
|
||||
deploy:
|
||||
image:
|
||||
name: minio/mc
|
||||
entrypoint: ['']
|
||||
stage: deploy
|
||||
before_script:
|
||||
- mc alias set minio $MINIO_HOST $MINIO_ACCESS_KEY $MINIO_SECRET_KEY
|
||||
script:
|
||||
- mc cp <source> <destination>
|
||||
```
|
||||
|
||||
~~~
|
||||
$ chmod 755 mc
|
||||
$ ./mc --help
|
||||
~~~
|
||||
## macOS
|
||||
### Homebrew
|
||||
Install mc packages using [Homebrew](http://brew.sh/)
|
||||
|
||||
#### Microsoft Windows
|
||||
```
|
||||
brew install minio/stable/mc
|
||||
mc --help
|
||||
```
|
||||
|
||||
Download ``mc`` for:
|
||||
## GNU/Linux
|
||||
### Binary Download
|
||||
| Platform | Architecture | URL |
|
||||
| ---------- | -------- |------|
|
||||
|GNU/Linux|64-bit Intel|https://dl.min.io/client/mc/release/linux-amd64/mc |
|
||||
||64-bit PPC|https://dl.min.io/client/mc/release/linux-ppc64le/mc |
|
||||
|
||||
- ``64-bit`` from https://dl.minio.io/client/mc/release/windows-amd64/mc.exe
|
||||
- ``32-bit`` from https://dl.minio.io/client/mc/release/windows-386/mc.exe
|
||||
```
|
||||
wget https://dl.min.io/client/mc/release/linux-amd64/mc
|
||||
chmod +x mc
|
||||
./mc --help
|
||||
```
|
||||
|
||||
~~~
|
||||
C:\Users\Username\Downloads> mc.exe --help
|
||||
~~~
|
||||
## Microsoft Windows
|
||||
### Binary Download
|
||||
| Platform | Architecture | URL |
|
||||
| ---------- | -------- |------|
|
||||
|Microsoft Windows|64-bit Intel|https://dl.min.io/client/mc/release/windows-amd64/mc.exe |
|
||||
|
||||
#### Source
|
||||
<blockquote>
|
||||
NOTE: Source installation is intended for only developers and advanced users. ‘mc update’ continuous delivery mechanism is not supported for ‘go get’ based binary builds. Please download official releases from https://minio.io/#mc.
|
||||
</blockquote>
|
||||
```
|
||||
mc.exe --help
|
||||
```
|
||||
|
||||
If you do not have a working Golang environment, please follow [Install Golang](./INSTALLGO.md).
|
||||
## Install from Source
|
||||
Source installation is only intended for developers and advanced users. If you do not have a working Golang environment, please follow [How to install Golang](https://golang.org/doc/install). Minimum version required is [go1.17](https://golang.org/dl/#stable)
|
||||
|
||||
```sh
|
||||
$ GO15VENDOREXPERIMENT=1 go get -u github.com/minio/mc
|
||||
go install github.com/minio/mc@latest
|
||||
```
|
||||
|
||||
## Public Minio Server
|
||||
## Add a Cloud Storage Service
|
||||
If you are planning to use `mc` only on POSIX compatible filesystems, you may skip this step and proceed to [everyday use](#everyday-use).
|
||||
|
||||
Minio cloud storage server is hosted at ``https://play.minio.io:9000`` for public use. This service is primarily intended for developers and users to familiarize themselves with Amazon S3 compatible cloud storage. Minio runs with filesystem backend with auto-expiry for objects in about 24 hours. No account signup is required, which means S3 compatible tools and applications can access this service without access and secret keys.
|
||||
To add one or more Amazon S3 compatible hosts, please follow the instructions below. `mc` stores all its configuration information in ``~/.mc/config.json`` file.
|
||||
|
||||
## Configuring mc for Amazon S3
|
||||
|
||||
Get your AccessKeyID and SecretAccessKey by following [AWS Credentials Guide](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSGettingStartedGuide/AWSCredentials.html).
|
||||
|
||||
Once you have them update your ``~/.mc/config.json`` configuration file.
|
||||
```
|
||||
$ mc config host add <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> S3v4
|
||||
mc alias set <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> --api <API-SIGNATURE> --path <BUCKET-LOOKUP-TYPE>
|
||||
```
|
||||
|
||||
Example
|
||||
`<ALIAS>` is simply a short name to your cloud storage service. S3 end-point, access and secret keys are supplied by your cloud storage provider. API signature is an optional argument. By default, it is set to "S3v4".
|
||||
|
||||
Path is an optional argument. It is used to indicate whether dns or path style url requests are supported by the server. It accepts "on", "off" as valid values to enable/disable path style requests.. By default, it is set to "auto" and SDK automatically determines the type of url lookup to use.
|
||||
|
||||
### Example - MinIO Cloud Storage
|
||||
MinIO server startup banner displays URL, access and secret keys.
|
||||
|
||||
```
|
||||
$ mc config host add mys3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
|
||||
mc alias set minio http://192.168.1.51 BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
|
||||
```
|
||||
|
||||
NOTE: ``S3v4`` is default if not specified.
|
||||
### Example - Amazon S3 Cloud Storage
|
||||
Get your AccessKeyID and SecretAccessKey by following [AWS Credentials Guide](http://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html).
|
||||
|
||||
## Configure mc for Google Cloud Storage
|
||||
|
||||
Get your AccessKeyID and SecretAccessKey by following [Google Credentials Guide](https://cloud.google.com/storage/docs/migrating?hl=en#keys).
|
||||
|
||||
Once you have them update your ``~/.mc/config.json`` configuration file.
|
||||
```
|
||||
$ mc config host add <ALIAS> https://storage.googleapis.com <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> S3v2
|
||||
mc alias set s3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
|
||||
```
|
||||
|
||||
NOTE: Google Cloud Storage only supports Legacy Signature Version ``2``, so you have to pick - ``S3v2``
|
||||
**Note**: As an IAM user on Amazon S3 you need to make sure the user has full access to the buckets or set the following restricted policy for your IAM user
|
||||
|
||||
## Contribute to Minio Client
|
||||
Please follow Minio [Contributor's Guide](./CONTRIBUTING.md)
|
||||
```json
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
"Statement": [
|
||||
{
|
||||
"Sid": "AllowBucketStat",
|
||||
"Effect": "Allow",
|
||||
"Action": [
|
||||
"s3:HeadBucket"
|
||||
],
|
||||
"Resource": "*"
|
||||
},
|
||||
{
|
||||
"Sid": "AllowThisBucketOnly",
|
||||
"Effect": "Allow",
|
||||
"Action": "s3:*",
|
||||
"Resource": [
|
||||
"arn:aws:s3:::<your-restricted-bucket>/*",
|
||||
"arn:aws:s3:::<your-restricted-bucket>"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Jobs
|
||||
If you think in Lisp or Haskell and hack in go, you would blend right in. Send your github link to callhome@minio.io.
|
||||
### Example - Google Cloud Storage
|
||||
Get your AccessKeyID and SecretAccessKey by following [Google Credentials Guide](https://cloud.google.com/storage/docs/migrating?hl=en#keys)
|
||||
|
||||
```
|
||||
mc alias set gcs https://storage.googleapis.com BKIKJAA5BMMU2RHO6IBB V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12
|
||||
```
|
||||
|
||||
### Example - IBM Cloud Object Storage
|
||||
See [the complete guide](docs/minio-client-complete-guide.md) for IBM instructions.
|
||||
|
||||
## Test Your Setup
|
||||
`mc` is pre-configured with https://play.min.io, aliased as "play". It is a hosted MinIO server for testing and development purpose. To test Amazon S3, simply replace "play" with "s3" or the alias you used at the time of setup.
|
||||
|
||||
*Example:*
|
||||
|
||||
List all buckets from https://play.min.io
|
||||
|
||||
```
|
||||
mc ls play
|
||||
[2016-03-22 19:47:48 PDT] 0B my-bucketname/
|
||||
[2016-03-22 22:01:07 PDT] 0B mytestbucket/
|
||||
[2016-03-22 20:04:39 PDT] 0B mybucketname/
|
||||
[2016-01-28 17:23:11 PST] 0B newbucket/
|
||||
[2016-03-20 09:08:36 PDT] 0B s3git-test/
|
||||
```
|
||||
|
||||
Make a bucket
|
||||
`mb` command creates a new bucket.
|
||||
|
||||
*Example:*
|
||||
```
|
||||
mc mb play/mybucket
|
||||
Bucket created successfully `play/mybucket`.
|
||||
```
|
||||
|
||||
Copy Objects
|
||||
`cp` command copies data from one or more sources to a target.
|
||||
|
||||
*Example:*
|
||||
```
|
||||
mc cp myobject.txt play/mybucket
|
||||
myobject.txt: 14 B / 14 B ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.00 % 41 B/s 0
|
||||
```
|
||||
|
||||
## Everyday Use
|
||||
|
||||
### Shell aliases
|
||||
You may add shell aliases to override your common Unix tools.
|
||||
|
||||
```
|
||||
alias ls='mc ls'
|
||||
alias cp='mc cp'
|
||||
alias cat='mc cat'
|
||||
alias mkdir='mc mb'
|
||||
alias pipe='mc pipe'
|
||||
alias find='mc find'
|
||||
```
|
||||
|
||||
### Shell autocompletion
|
||||
In case you are using bash, zsh or fish. Shell completion is embedded by default in `mc`, to install auto-completion use `mc --autocompletion`. Restart the shell, mc will auto-complete commands as shown below.
|
||||
|
||||
```
|
||||
mc <TAB>
|
||||
admin config diff find ls mirror policy session sql update watch
|
||||
cat cp event head mb pipe rm share stat version
|
||||
```
|
||||
|
||||
## Explore Further
|
||||
- [MinIO Client Complete Guide](https://docs.min.io/docs/minio-client-complete-guide)
|
||||
- [MinIO Quickstart Guide](https://docs.min.io/docs/minio-quickstart-guide)
|
||||
- [The MinIO documentation website](https://docs.min.io)
|
||||
|
||||
## Contribute to MinIO Project
|
||||
Please follow MinIO [Contributor's Guide](https://github.com/minio/mc/blob/master/CONTRIBUTING.md)
|
||||
|
||||
## License
|
||||
Use of `mc` is governed by the GNU AGPLv3 license that can be found in the [LICENSE](https://github.com/minio/mc/blob/master/LICENSE) file.
|
||||
|
||||
+173
@@ -0,0 +1,173 @@
|
||||
# MinIO客户端快速入门指南
|
||||
[](https://slack.min.io) [](https://goreportcard.com/report/minio/mc) [](https://hub.docker.com/r/minio/mc/)
|
||||
|
||||
MinIO Client (mc)为ls,cat,cp,mirror,diff,find等UNIX命令提供了一种替代方案。它支持文件系统和兼容Amazon S3的云存储服务(AWS Signature v2和v4)。
|
||||
|
||||
|
||||
```
|
||||
ls 列出文件和文件夹。
|
||||
mb 创建一个存储桶或一个文件夹。
|
||||
cat 显示文件和对象内容。
|
||||
pipe 将一个STDIN重定向到一个对象或者文件或者STDOUT。
|
||||
share 生成用于共享的URL。
|
||||
cp 拷贝文件和对象。
|
||||
mirror 给存储桶和文件夹做镜像。
|
||||
find 基于参数查找文件。
|
||||
diff 对两个文件夹或者存储桶比较差异。
|
||||
rm 删除文件和对象。
|
||||
events 管理对象通知。
|
||||
watch 监听文件和对象的事件。
|
||||
policy 管理访问策略。
|
||||
session 为cp命令管理保存的会话。
|
||||
config 管理mc配置文件。
|
||||
update 检查软件更新。
|
||||
version 输出版本信息。
|
||||
```
|
||||
|
||||
## Docker容器
|
||||
### 稳定版
|
||||
```
|
||||
docker pull minio/mc
|
||||
docker run minio/mc ls play
|
||||
```
|
||||
|
||||
### 尝鲜版
|
||||
```
|
||||
docker pull minio/mc:edge
|
||||
docker run minio/mc:edge ls play
|
||||
```
|
||||
|
||||
**注意:** 上述示例默认使用MinIO[演示环境](#test-your-setup)做演示,如果想用`mc`操作其它S3兼容的服务,采用下面的方式来启动容器:
|
||||
|
||||
```
|
||||
docker run -it --entrypoint=/bin/sh minio/mc
|
||||
```
|
||||
|
||||
然后使用[`mc config`命令](#add-a-cloud-storage-service)。
|
||||
|
||||
## macOS
|
||||
### Homebrew
|
||||
使用[Homebrew](http://brew.sh/)安装mc。
|
||||
|
||||
```
|
||||
brew install minio/stable/mc
|
||||
mc --help
|
||||
```
|
||||
|
||||
## GNU/Linux
|
||||
### 下载二进制文件
|
||||
| 平台 | CPU架构 | URL |
|
||||
| ---------- | -------- |------|
|
||||
|GNU/Linux|64-bit Intel|https://dl.min.io/client/mc/release/linux-amd64/mc |
|
||||
|
||||
```
|
||||
chmod +x mc
|
||||
./mc --help
|
||||
```
|
||||
|
||||
## Microsoft Windows
|
||||
### 下载二进制文件
|
||||
| 平台 | CPU架构 | URL |
|
||||
| ---------- | -------- |------|
|
||||
|Microsoft Windows|64-bit Intel|https://dl.min.io/client/mc/release/windows-amd64/mc.exe |
|
||||
|
||||
```
|
||||
mc.exe --help
|
||||
```
|
||||
|
||||
## 通过源码安装
|
||||
通过源码安装仅适用于开发人员和高级用户。`mc update`命令不支持基于源码安装的更新通知。请从https://min.io/download/#minio-client下载官方版本。
|
||||
|
||||
如果您没有Golang环境,请参照[如何安装Golang](https://golang.org/doc/install)。
|
||||
|
||||
```
|
||||
go get -d github.com/minio/mc
|
||||
cd ${GOPATH}/src/github.com/minio/mc
|
||||
make
|
||||
```
|
||||
|
||||
## 添加一个云存储服务
|
||||
如果你打算仅在POSIX兼容文件系统中使用`mc`,那你可以直接略过本节,跳到[日常使用](#everyday-use)。
|
||||
|
||||
添加一个或多个S3兼容的服务,请参考下面说明。`mc`将所有的配置信息都存储在``~/.mc/config.json``文件中。
|
||||
|
||||
```
|
||||
mc alias set <ALIAS> <YOUR-S3-ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> [--api API-SIGNATURE]
|
||||
```
|
||||
|
||||
别名就是给你的云存储服务起了一个短点的外号。S3 endpoint,access key和secret key是你的云存储服务提供的。API签名是可选参数,默认情况下,它被设置为"S3v4"。
|
||||
|
||||
### 示例-MinIO云存储
|
||||
从MinIO服务获得URL、access key和secret key。
|
||||
|
||||
```
|
||||
mc alias set minio http://192.168.1.51 BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 --api s3v4
|
||||
```
|
||||
|
||||
### 示例-Amazon S3云存储
|
||||
参考[AWS Credentials指南](http://docs.aws.amazon.com/general/latest/gr/aws-security-credentials.html)获取你的AccessKeyID和SecretAccessKey。
|
||||
|
||||
```
|
||||
mc alias set s3 https://s3.amazonaws.com BKIKJAA5BMMU2RHO6IBB V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 --api s3v4
|
||||
```
|
||||
|
||||
### 示例-Google云存储
|
||||
参考[Google Credentials Guide](https://cloud.google.com/storage/docs/migrating?hl=en#keys)获取你的AccessKeyID和SecretAccessKey。
|
||||
|
||||
```
|
||||
mc alias set gcs https://storage.googleapis.com BKIKJAA5BMMU2RHO6IBB V8f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12 --api s3v2
|
||||
```
|
||||
|
||||
注意:Google云存储只支持旧版签名版本V2,所以你需要选择S3v2。
|
||||
|
||||
## 验证
|
||||
`mc`预先配置了云存储服务URL:https://play.min.io,别名“play”。它是一个用于研发和测试的MinIO服务。如果想测试Amazon S3,你可以将“play”替换为“s3”。
|
||||
|
||||
*示例:*
|
||||
|
||||
列出https://play.min.io上的所有存储桶。
|
||||
|
||||
```
|
||||
mc ls play
|
||||
[2016-03-22 19:47:48 PDT] 0B my-bucketname/
|
||||
[2016-03-22 22:01:07 PDT] 0B mytestbucket/
|
||||
[2016-03-22 20:04:39 PDT] 0B mybucketname/
|
||||
[2016-01-28 17:23:11 PST] 0B newbucket/
|
||||
[2016-03-20 09:08:36 PDT] 0B s3git-test/
|
||||
```
|
||||
<a name="everyday-use"></a>
|
||||
## 日常使用
|
||||
|
||||
### Shell别名
|
||||
你可以添加shell别名来覆盖默认的Unix工具命令。
|
||||
|
||||
```
|
||||
alias ls='mc ls'
|
||||
alias cp='mc cp'
|
||||
alias cat='mc cat'
|
||||
alias mkdir='mc mb'
|
||||
alias pipe='mc pipe'
|
||||
alias find='mc find'
|
||||
```
|
||||
|
||||
### Shell自动补全
|
||||
你也可以下载[`autocomplete/bash_autocomplete`](https://raw.githubusercontent.com/minio/mc/master/autocomplete/bash_autocomplete)到`/etc/bash_completion.d/`,然后将其重命名为`mc`。别忘了在这个文件运行source命令让其在你的当前shell上可用。
|
||||
|
||||
```
|
||||
sudo wget https://raw.githubusercontent.com/minio/mc/master/autocomplete/bash_autocomplete -O /etc/bash_completion.d/mc
|
||||
source /etc/bash_completion.d/mc
|
||||
```
|
||||
|
||||
```
|
||||
mc <TAB>
|
||||
admin config diff ls mirror policy session update watch
|
||||
cat cp events mb pipe rm share version
|
||||
```
|
||||
|
||||
## 了解更多
|
||||
- [MinIO Client完全指南](https://docs.min.io/docs/minio-client-complete-guide)
|
||||
- [MinIO快速入门](https://docs.min.io/docs/minio-quickstart-guide)
|
||||
- [MinIO官方文档](https://docs.min.io)
|
||||
|
||||
## 贡献
|
||||
请遵守MinIO[贡献者指南](https://github.com/minio/mc/blob/master/docs/zh_CN/CONTRIBUTING.md)
|
||||
@@ -0,0 +1 @@
|
||||
theme: jekyll-theme-minimal
|
||||
-205
@@ -1,205 +0,0 @@
|
||||
/*
|
||||
* Minio Client, (C) 2015 Minio, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/console"
|
||||
"github.com/minio/minio-xl/pkg/probe"
|
||||
)
|
||||
|
||||
var (
|
||||
accessFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "help, h",
|
||||
Usage: "Help of access.",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// Set access permissions.
|
||||
var accessCmd = cli.Command{
|
||||
Name: "access",
|
||||
Usage: "Manage bucket access permissions.",
|
||||
Action: mainAccess,
|
||||
Flags: append(accessFlags, globalFlags...),
|
||||
CustomHelpTemplate: `Name:
|
||||
mc {{.Name}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
mc {{.Name}} [FLAGS] set PERMISSION TARGET [TARGET...]
|
||||
mc {{.Name}} [FLAGS] get TARGET [TARGET...]
|
||||
|
||||
PERMISSION:
|
||||
Allowed permissions are: [private, readonly, public, authorized].
|
||||
|
||||
FLAGS:
|
||||
{{range .Flags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Set bucket to "private" on Amazon S3 cloud storage.
|
||||
$ mc {{.Name}} set private s3/burningman2011
|
||||
|
||||
2. Set bucket to "public" on Amazon S3 cloud storage.
|
||||
$ mc {{.Name}} set public s3/shared
|
||||
|
||||
3. Set bucket to "authenticated" on Amazon S3 cloud storage to provide read access to IAM Authenticated Users group.
|
||||
$ mc {{.Name}} set authorized s3/shared-authenticated
|
||||
|
||||
4. Get bucket permissions.
|
||||
$ mc {{.Name}} get s3/shared
|
||||
|
||||
5. Get bucket permissions.
|
||||
$ mc {{.Name}} get gcs/miniocloud
|
||||
`,
|
||||
}
|
||||
|
||||
// accessMessage is container for access command on bucket success and failure messages.
|
||||
type accessMessage struct {
|
||||
Operation string `json:"operation"`
|
||||
Status string `json:"status"`
|
||||
Bucket string `json:"bucket"`
|
||||
Perms accessPerms `json:"permission"`
|
||||
}
|
||||
|
||||
// String colorized access message.
|
||||
func (s accessMessage) String() string {
|
||||
if s.Operation == "set" {
|
||||
return console.Colorize("Access",
|
||||
"Set access permission ‘"+string(s.Perms)+"’ updated successfully for ‘"+s.Bucket+"’")
|
||||
}
|
||||
if s.Operation == "get" {
|
||||
return console.Colorize("Access",
|
||||
"Access permission for ‘"+s.Bucket+"’"+" is ‘"+string(s.Perms)+"’")
|
||||
}
|
||||
// nothing to print
|
||||
return ""
|
||||
}
|
||||
|
||||
// JSON jsonified access message.
|
||||
func (s accessMessage) JSON() string {
|
||||
accessJSONBytes, e := json.Marshal(s)
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(accessJSONBytes)
|
||||
}
|
||||
|
||||
// checkAccessSyntax check for incoming syntax.
|
||||
func checkAccessSyntax(ctx *cli.Context) {
|
||||
if !ctx.Args().Present() {
|
||||
cli.ShowCommandHelpAndExit(ctx, "access", 1) // last argument is exit code.
|
||||
}
|
||||
if len(ctx.Args()) < 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "access", 1) // last argument is exit code.
|
||||
}
|
||||
switch ctx.Args().First() {
|
||||
case "set":
|
||||
if len(ctx.Args().Tail()) < 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "access", 1) // last argument is exit code.
|
||||
}
|
||||
perms := accessPerms(ctx.Args().Tail().Get(0))
|
||||
if !perms.isValidAccessPERM() {
|
||||
fatalIf(errDummy().Trace(),
|
||||
"Unrecognized permission ‘"+perms.String()+"’. Allowed values are [private, public, readonly, authorized].")
|
||||
}
|
||||
for _, arg := range ctx.Args().Tail().Tail() {
|
||||
if strings.TrimSpace(arg) == "" {
|
||||
fatalIf(errInvalidArgument().Trace(), "Unable to validate empty argument.")
|
||||
}
|
||||
}
|
||||
case "get":
|
||||
if len(ctx.Args().Tail()) < 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "access", 1) // last argument is exit code.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// doSetAccess do set access.
|
||||
func doSetAccess(targetURL string, targetPERMS accessPerms) *probe.Error {
|
||||
clnt, err := newClient(targetURL)
|
||||
if err != nil {
|
||||
return err.Trace(targetURL)
|
||||
}
|
||||
if err = clnt.SetBucketAccess(targetPERMS.String()); err != nil {
|
||||
return err.Trace(targetURL, targetPERMS.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// doGetAccess do get access.
|
||||
func doGetAccess(targetURL string) (perms accessPerms, err *probe.Error) {
|
||||
clnt, err := newClient(targetURL)
|
||||
if err != nil {
|
||||
return "", err.Trace(targetURL)
|
||||
}
|
||||
acl, err := clnt.GetBucketAccess()
|
||||
if err != nil {
|
||||
return "", err.Trace(targetURL)
|
||||
}
|
||||
return aclToPerms(acl), nil
|
||||
}
|
||||
|
||||
func mainAccess(ctx *cli.Context) {
|
||||
// Set global flags from context.
|
||||
setGlobalsFromContext(ctx)
|
||||
|
||||
// check 'access' cli arguments.
|
||||
checkAccessSyntax(ctx)
|
||||
|
||||
// Additional command speific theme customization.
|
||||
console.SetColor("Access", color.New(color.FgGreen, color.Bold))
|
||||
|
||||
switch ctx.Args().First() {
|
||||
case "set":
|
||||
perms := accessPerms(ctx.Args().Tail().First())
|
||||
URLs := ctx.Args().Tail().Tail()
|
||||
for _, targetURL := range URLs {
|
||||
err := doSetAccess(targetURL, perms)
|
||||
// Upon error, print and continue.
|
||||
if err != nil {
|
||||
errorIf(err.Trace(targetURL, string(perms)),
|
||||
"Unable to set access permission ‘"+string(perms)+"’ for ‘"+targetURL+"’.")
|
||||
continue
|
||||
}
|
||||
printMsg(accessMessage{
|
||||
Status: "success",
|
||||
Operation: "set",
|
||||
Bucket: targetURL,
|
||||
Perms: perms,
|
||||
})
|
||||
}
|
||||
case "get":
|
||||
URLs := ctx.Args().Tail()
|
||||
for _, targetURL := range URLs {
|
||||
perms, err := doGetAccess(targetURL)
|
||||
if err != nil {
|
||||
errorIf(err.Trace(targetURL), "Unable to get access permission for ‘"+targetURL+"’.")
|
||||
continue
|
||||
}
|
||||
printMsg(accessMessage{
|
||||
Status: "success",
|
||||
Operation: "get",
|
||||
Bucket: targetURL,
|
||||
Perms: perms,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Minio Client (C) 2015 Minio, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
// isValidAccessPERM - is provided access perm string supported.
|
||||
func (b accessPerms) isValidAccessPERM() bool {
|
||||
switch true {
|
||||
case b.isPrivate():
|
||||
fallthrough
|
||||
case b.isReadOnly():
|
||||
fallthrough
|
||||
case b.isPublic():
|
||||
fallthrough
|
||||
case b.isAuthorized():
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// accessPerms - access level.
|
||||
type accessPerms string
|
||||
|
||||
// different types of Access perm's currently supported by accesss command.
|
||||
const (
|
||||
accessPrivate = accessPerms("private")
|
||||
accessReadOnly = accessPerms("readonly")
|
||||
accessPublic = accessPerms("public")
|
||||
accessAuthorized = accessPerms("authorized")
|
||||
)
|
||||
|
||||
func (b accessPerms) String() string {
|
||||
if !b.isValidAccessPERM() {
|
||||
return string(b)
|
||||
}
|
||||
if b.isReadOnly() {
|
||||
return "public-read"
|
||||
}
|
||||
if b.isPublic() {
|
||||
return "public-read-write"
|
||||
}
|
||||
if b.isAuthorized() {
|
||||
return "authenticated-read"
|
||||
}
|
||||
return "private"
|
||||
}
|
||||
|
||||
// convert acl's to access perms
|
||||
func aclToPerms(acl string) accessPerms {
|
||||
switch acl {
|
||||
case "private":
|
||||
return accessPerms("private")
|
||||
case "public-read":
|
||||
return accessPerms("readonly")
|
||||
case "public-read-write":
|
||||
return accessPerms("public")
|
||||
case "authenticated-read":
|
||||
return accessPerms("authorized")
|
||||
default:
|
||||
return accessPerms(acl)
|
||||
}
|
||||
}
|
||||
|
||||
// isPrivate - is acl Private.
|
||||
func (b accessPerms) isPrivate() bool {
|
||||
return b == accessPrivate
|
||||
}
|
||||
|
||||
// isPublicRead - is acl PublicRead.
|
||||
func (b accessPerms) isReadOnly() bool {
|
||||
return b == accessReadOnly
|
||||
}
|
||||
|
||||
// isPublicReadWrite - is acl PublicReadWrite.
|
||||
func (b accessPerms) isPublic() bool {
|
||||
return b == accessPublic
|
||||
}
|
||||
|
||||
// isAuthorized - is acl AuthorizedRead.
|
||||
func (b accessPerms) isAuthorized() bool {
|
||||
return b == accessAuthorized
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Minio Client (C) 2015 Minio, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type objectAPIHandler struct {
|
||||
lock *sync.Mutex
|
||||
bucket string
|
||||
object map[string][]byte
|
||||
}
|
||||
|
||||
func (h objectAPIHandler) getHandler(w http.ResponseWriter, r *http.Request) {
|
||||
h.lock.Lock()
|
||||
defer h.lock.Unlock()
|
||||
switch {
|
||||
case r.URL.Path == "/":
|
||||
response := []byte("<ListAllMyBucketsResult xmlns=\"http://doc.s3.amazonaws.com/2006-03-01\"><Buckets><Bucket><Name>bucket</Name><CreationDate>2015-05-20T23:05:09.230Z</CreationDate></Bucket></Buckets><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner></ListAllMyBucketsResult>")
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(response)))
|
||||
w.Write(response)
|
||||
return
|
||||
case r.URL.Path == "/bucket":
|
||||
_, ok := r.URL.Query()["acl"]
|
||||
if ok {
|
||||
response := []byte("<?xml version=\"1.0\" encoding=\"UTF-8\"?><AccessControlPolicy><Owner><ID>75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a</ID><DisplayName>CustomersName@amazon.com</DisplayName></Owner><AccessControlList><Grant><Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\"><ID>75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a</ID><DisplayName>CustomersName@amazon.com</DisplayName></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>")
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(response)))
|
||||
w.Write(response)
|
||||
return
|
||||
}
|
||||
fallthrough
|
||||
case r.URL.Path == "/bucket":
|
||||
response := []byte("<ListBucketResult xmlns=\"http://doc.s3.amazonaws.com/2006-03-01\"><Contents><ETag>b1946ac92492d2347c6235b4d2611184</ETag><Key>object0</Key><LastModified>2015-05-21T18:24:21.097Z</LastModified><Size>22061</Size><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><ETag>b1946ac92492d2347c6235b4d2611184</ETag><Key>object1</Key><LastModified>2015-05-21T18:24:21.097Z</LastModified><Size>22061</Size><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><ETag>b1946ac92492d2347c6235b4d2611184</ETag><Key>object2</Key><LastModified>2015-05-21T18:24:21.097Z</LastModified><Size>22061</Size><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><ETag>b1946ac92492d2347c6235b4d2611184</ETag><Key>object3</Key><LastModified>2015-05-21T18:24:21.097Z</LastModified><Size>22061</Size><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><ETag>b1946ac92492d2347c6235b4d2611184</ETag><Key>object4</Key><LastModified>2015-05-21T18:24:21.097Z</LastModified><Size>22061</Size><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><ETag>b1946ac92492d2347c6235b4d2611184</ETag><Key>object5</Key><LastModified>2015-05-21T18:24:21.097Z</LastModified><Size>22061</Size><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><ETag>b1946ac92492d2347c6235b4d2611184</ETag><Key>object6</Key><LastModified>2015-05-21T18:24:21.097Z</LastModified><Size>22061</Size><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Contents><ETag>b1946ac92492d2347c6235b4d2611184</ETag><Key>object7</Key><LastModified>2015-05-21T18:24:21.097Z</LastModified><Size>22061</Size><Owner><ID>minio</ID><DisplayName>minio</DisplayName></Owner><StorageClass>STANDARD</StorageClass></Contents><Delimiter></Delimiter><EncodingType></EncodingType><IsTruncated>false</IsTruncated><Marker></Marker><MaxKeys>1000</MaxKeys><Name>testbucket</Name><NextMarker></NextMarker><Prefix></Prefix></ListBucketResult>")
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(response)))
|
||||
w.Write(response)
|
||||
return
|
||||
case r.URL.Path != "":
|
||||
if _, ok := h.object[filepath.Base(r.URL.Path)]; !ok {
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(h.object[filepath.Base(r.URL.Path)])))
|
||||
w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
|
||||
w.Header().Set("ETag", "b1946ac92492d2347c6235b4d2611184")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
io.Copy(w, bytes.NewReader(h.object[filepath.Base(r.URL.Path)]))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (h objectAPIHandler) headHandler(w http.ResponseWriter, r *http.Request) {
|
||||
h.lock.Lock()
|
||||
defer h.lock.Unlock()
|
||||
switch {
|
||||
case r.URL.Path == "/":
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
case r.URL.Path == "/bucket":
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
case r.URL.Path != "":
|
||||
w.Header().Set("Content-Length", strconv.Itoa(len(h.object[filepath.Base(r.URL.Path)])))
|
||||
w.Header().Set("Last-Modified", time.Now().UTC().Format(http.TimeFormat))
|
||||
w.Header().Set("ETag", "b1946ac92492d2347c6235b4d2611184")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func isValidBucket(bucket string) bool {
|
||||
if len(bucket) < 3 || len(bucket) > 63 {
|
||||
return false
|
||||
}
|
||||
if bucket[0] == '.' || bucket[len(bucket)-1] == '.' {
|
||||
return false
|
||||
}
|
||||
if match, _ := regexp.MatchString("\\.\\.", bucket); match == true {
|
||||
return false
|
||||
}
|
||||
// We don't support buckets with '.' in them
|
||||
match, _ := regexp.MatchString("^[a-zA-Z][a-zA-Z0-9\\-]+[a-zA-Z0-9]$", bucket)
|
||||
return match
|
||||
}
|
||||
|
||||
func (h objectAPIHandler) putHandler(w http.ResponseWriter, r *http.Request) {
|
||||
h.lock.Lock()
|
||||
defer h.lock.Unlock()
|
||||
switch {
|
||||
case r.URL.Path == "/":
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
case r.URL.Path == "/bucket":
|
||||
_, ok := r.URL.Query()["acl"]
|
||||
if ok {
|
||||
switch r.Header.Get("x-amz-acl") {
|
||||
case "public-read-write":
|
||||
fallthrough
|
||||
case "public-read":
|
||||
fallthrough
|
||||
case "private":
|
||||
fallthrough
|
||||
case "authenticated-read":
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
default:
|
||||
w.WriteHeader(http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
case r.URL.Path != "":
|
||||
if !isValidBucket(strings.Split(r.URL.Path, "/")[1]) {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
length, e := strconv.Atoi(r.Header.Get("Content-Length"))
|
||||
if e != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
var buffer bytes.Buffer
|
||||
if _, e = io.CopyN(&buffer, r.Body, int64(length)); e != nil {
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
h.object[filepath.Base(r.URL.Path)] = buffer.Bytes()
|
||||
w.Header().Set("ETag", "b1946ac92492d2347c6235b4d2611184")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (h objectAPIHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
switch {
|
||||
case r.Method == "GET":
|
||||
h.getHandler(w, r)
|
||||
case r.Method == "HEAD":
|
||||
h.headHandler(w, r)
|
||||
case r.Method == "PUT":
|
||||
h.putHandler(w, r)
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
# version format
|
||||
version: "{build}"
|
||||
|
||||
# Operating system (build VM template)
|
||||
os: Windows Server 2012 R2
|
||||
|
||||
clone_folder: c:\gopath\src\github.com\minio\mc
|
||||
|
||||
# environment variables
|
||||
environment:
|
||||
GOPATH: c:\gopath
|
||||
GO15VENDOREXPERIMENT: 1
|
||||
|
||||
# scripts that run after cloning repository
|
||||
install:
|
||||
- set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
|
||||
- go version
|
||||
- go env
|
||||
- go get -u github.com/golang/lint/golint
|
||||
- go get -u golang.org/x/tools/cmd/vet
|
||||
- go get -u github.com/fzipp/gocyclo
|
||||
- go get -u github.com/remyoudompheng/go-misc/deadcode
|
||||
- go get -u github.com/alecthomas/gometalinter
|
||||
- go get -u github.com/client9/misspell
|
||||
|
||||
# to run your custom scripts instead of automatic MSBuild
|
||||
build_script:
|
||||
- go tool vet -all ./pkg
|
||||
- go tool vet -shadow=true ./pkg
|
||||
- gofmt -s -l pkg
|
||||
- golint .
|
||||
- golint github.com/minio/mc/pkg...
|
||||
- gometalinter --disable-all --linter='misspell:misspell ./*.go:PATH:LINE:COL:MESSAGE' --enable=misspell ./...
|
||||
- gocyclo -over 40 pkg
|
||||
- deadcode
|
||||
- go test -race .
|
||||
- go test -race github.com/minio/mc/pkg...
|
||||
- go run buildscripts/gen-ldflags.go > temp.txt
|
||||
- set /p LDFLAGS=<temp.txt
|
||||
- go build -ldflags="%LDFLAGS%" -o %GOPATH%\bin\mc.exe
|
||||
- mc version
|
||||
|
||||
# to disable automatic tests
|
||||
test: off
|
||||
|
||||
# to disable deployment
|
||||
deploy: off
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Minio Client (C) 2014, 2015 Minio, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
var (
|
||||
// mcVersion - version time.RFC3339.
|
||||
mcVersion = "UNOFFICIAL.GOGET"
|
||||
// mcReleaseTag - release tag in TAG.%Y-%m-%dT%H-%M-%SZ.
|
||||
mcReleaseTag = "UNOFFICIAL.GOGET"
|
||||
// mcCommitID - latest commit id.
|
||||
mcCommitID = "UNOFFICIAL.GOGET"
|
||||
// mcShortCommitID - first 12 characters from mcCommitID.
|
||||
mcShortCommitID = mcCommitID[:12]
|
||||
)
|
||||
@@ -0,0 +1,24 @@
|
||||
## FIXME:
|
||||
## In OSX, 'sort -V' option does not exist, hence
|
||||
## we have our own version compare function.
|
||||
## Once OSX has the option, below function is good enough.
|
||||
##
|
||||
## check_minimum_version() {
|
||||
## versions=($(echo -e "$1\n$2" | sort -V))
|
||||
## return [ "$1" == "${versions[0]}" ]
|
||||
## }
|
||||
##
|
||||
check_minimum_version() {
|
||||
IFS='.' read -r -a varray1 <<< "$1"
|
||||
IFS='.' read -r -a varray2 <<< "$2"
|
||||
|
||||
for i in "${!varray1[@]}"; do
|
||||
if [[ ${varray1[i]} -lt ${varray2[i]} ]]; then
|
||||
return 0
|
||||
elif [[ ${varray1[i]} -gt ${varray2[i]} ]]; then
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
Executable
+128
@@ -0,0 +1,128 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2015-2021 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/>.
|
||||
#
|
||||
|
||||
_init() {
|
||||
# Save release LDFLAGS
|
||||
LDFLAGS=$(go run buildscripts/gen-ldflags.go)
|
||||
|
||||
# Extract release tag
|
||||
release_tag=$(echo $LDFLAGS | awk {'print $6'} | cut -f2 -d=)
|
||||
|
||||
# Verify release tag.
|
||||
if [ -z "$release_tag" ]; then
|
||||
echo "Release tag cannot be empty. Please check return value of \`go run buildscripts/gen-ldflags.go\`"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Extract release string.
|
||||
release_str=$(echo $MC_RELEASE | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
# Verify release string.
|
||||
if [ -z "$release_str" ]; then
|
||||
echo "Release string cannot be empty. Please set \`MC_RELEASE\` env variable."
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# List of supported architectures
|
||||
SUPPORTED_OSARCH='linux/amd64 linux/ppc64le windows/amd64 darwin/amd64'
|
||||
|
||||
## System binaries
|
||||
CP=`which cp`
|
||||
SHASUM=`which shasum`
|
||||
SHA256SUM="${SHASUM} -a 256"
|
||||
SED=`which sed`
|
||||
}
|
||||
|
||||
go_build() {
|
||||
local osarch=$1
|
||||
os=$(echo $osarch | cut -f1 -d'/')
|
||||
arch=$(echo $osarch | cut -f2 -d'/')
|
||||
package=$(go list -f '{{.ImportPath}}')
|
||||
echo -n "-->"
|
||||
printf "%15s:%s\n" "${osarch}" "${package}"
|
||||
|
||||
# Release binary name
|
||||
release_bin="$release_str/$os-$arch/$(basename $package).$release_tag"
|
||||
# Release binary downloadable name
|
||||
release_real_bin="$release_str/$os-$arch/$(basename $package)"
|
||||
|
||||
# Release sha1sum name
|
||||
release_shasum="$release_str/$os-$arch/$(basename $package).${release_tag}.shasum"
|
||||
# Release sha1sum default
|
||||
release_shasum_default="$release_str/$os-$arch/$(basename $package).shasum"
|
||||
|
||||
# Release sha256sum name
|
||||
release_sha256sum="$release_str/$os-$arch/$(basename $package).${release_tag}.sha256sum"
|
||||
# Release sha256sum default
|
||||
release_sha256sum_default="$release_str/$os-$arch/$(basename $package).sha256sum"
|
||||
|
||||
# Go build to build the binary.
|
||||
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -tags kqueue --ldflags "${LDFLAGS}" -o $release_bin
|
||||
|
||||
# Create copy
|
||||
if [ $os == "windows" ]; then
|
||||
$CP -p $release_bin ${release_real_bin}.exe
|
||||
else
|
||||
$CP -p $release_bin $release_real_bin
|
||||
fi
|
||||
|
||||
# Calculate sha1sum
|
||||
shasum_str=$(${SHASUM} ${release_bin})
|
||||
echo ${shasum_str} | $SED "s/$release_str\/$os-$arch\///g" > $release_shasum
|
||||
$CP -p $release_shasum $release_shasum_default
|
||||
|
||||
# Calculate sha256sum
|
||||
sha256sum_str=$(${SHA256SUM} ${release_bin})
|
||||
echo ${sha256sum_str} | $SED "s/$release_str\/$os-$arch\///g" > $release_sha256sum
|
||||
$CP -p $release_sha256sum $release_sha256sum_default
|
||||
}
|
||||
|
||||
main() {
|
||||
# Build releases.
|
||||
echo "Executing $release_str builds for OS: ${SUPPORTED_OSARCH}"
|
||||
echo "Choose an OS Arch from the below"
|
||||
for osarch in ${SUPPORTED_OSARCH}; do
|
||||
echo ${osarch}
|
||||
done
|
||||
|
||||
read -p "If you want to build for all, Just press Enter: " chosen_osarch
|
||||
if [ "$chosen_osarch" = "" ] || [ "$chosen_osarch" = "all" ]; then
|
||||
for each_osarch in ${SUPPORTED_OSARCH}; do
|
||||
go_build ${each_osarch}
|
||||
done
|
||||
else
|
||||
local found=0
|
||||
for each_osarch in ${SUPPORTED_OSARCH}; do
|
||||
if [ "$chosen_osarch" = "$each_osarch" ]; then
|
||||
found=1
|
||||
fi
|
||||
done
|
||||
if [ ${found} -eq 1 ]; then
|
||||
go_build ${chosen_osarch}
|
||||
else
|
||||
echo "Unknown architecture \"${chosen_osarch}\""
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# Run main.
|
||||
_init && main
|
||||
+84
-165
@@ -1,19 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Minio Client, (C) 2015 Minio, Inc.
|
||||
# Copyright (c) 2015-2021 MinIO, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
# This file is part of MinIO Object Storage stack
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
# 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.
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# 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/>.
|
||||
#
|
||||
|
||||
# shellcheck source=buildscripts/build.env
|
||||
. "$(pwd)/buildscripts/build.env"
|
||||
|
||||
_init() {
|
||||
|
||||
@@ -21,14 +27,26 @@ _init() {
|
||||
|
||||
## Minimum required versions for build dependencies
|
||||
GIT_VERSION="1.0"
|
||||
GO_VERSION="1.5.1"
|
||||
GO_VERSION="1.13"
|
||||
OSX_VERSION="10.8"
|
||||
UNAME=$(uname -sm)
|
||||
|
||||
## Check all dependencies are present
|
||||
MISSING=""
|
||||
KNAME=$(uname -s)
|
||||
ARCH=$(uname -m)
|
||||
case "${KNAME}" in
|
||||
SunOS )
|
||||
ARCH=$(isainfo -k)
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
## FIXME:
|
||||
## In OSX, 'readlink -f' option does not exist, hence
|
||||
## we have our own readlink -f behavior here.
|
||||
## Once OSX has the option, below function is good enough.
|
||||
##
|
||||
## readlink() {
|
||||
## return /bin/readlink -f "$1"
|
||||
## }
|
||||
##
|
||||
readlink() {
|
||||
TARGET_FILE=$1
|
||||
|
||||
@@ -50,169 +68,70 @@ readlink() {
|
||||
echo $RESULT
|
||||
}
|
||||
|
||||
###
|
||||
#
|
||||
# Takes two arguments
|
||||
# arg1: version number in `x.x.x` format
|
||||
# arg2: version number in `x.x.x` format
|
||||
#
|
||||
# example: check_version "$version1" "$version2"
|
||||
#
|
||||
# returns:
|
||||
# 0 - Installed version is equal to required
|
||||
# 1 - Installed version is greater than required
|
||||
# 2 - Installed version is lesser than required
|
||||
# 3 - If args have length zero
|
||||
#
|
||||
####
|
||||
check_version() {
|
||||
## validate args
|
||||
[[ -z "$1" ]] && return 3
|
||||
[[ -z "$2" ]] && return 3
|
||||
|
||||
if [[ $1 == $2 ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local IFS=.
|
||||
local i ver1=($1) ver2=($2)
|
||||
# fill empty fields in ver1 with zeros
|
||||
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)); do
|
||||
ver1[i]=0
|
||||
done
|
||||
for ((i=0; i<${#ver1[@]}; i++)); do
|
||||
if [[ -z ${ver2[i]} ]]; then
|
||||
# fill empty fields in ver2 with zeros
|
||||
ver2[i]=0
|
||||
fi
|
||||
if ((10#${ver1[i]} > 10#${ver2[i]})); then
|
||||
|
||||
return 1
|
||||
fi
|
||||
if ((10#${ver1[i]} < 10#${ver2[i]})); then
|
||||
## Installed version is lesser than required - Bad condition
|
||||
return 2
|
||||
fi
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
check_golang_env() {
|
||||
echo ${GOROOT:?} 2>&1 >/dev/null
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "ERROR"
|
||||
echo "GOROOT environment variable missing, please refer to Go installation document"
|
||||
echo "https://github.com/minio/mc/blob/master/INSTALLGO.md#install-go-13"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ${GOPATH:?} 2>&1 >/dev/null
|
||||
if [ $? -eq 1 ]; then
|
||||
echo "ERROR"
|
||||
echo "GOPATH environment variable missing, please refer to Go installation document"
|
||||
echo "https://github.com/minio/mc/blob/master/INSTALLGO.md#install-go-13"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local go_binary_path=$(which go)
|
||||
|
||||
if [ -z "${go_binary_path}" ] ; then
|
||||
echo "Cannot find go binary in your PATH configuration, please refer to Go installation document"
|
||||
echo "https://github.com/minio/mc/blob/master/INSTALLGO.md#install-go-13"
|
||||
exit -1
|
||||
fi
|
||||
|
||||
local new_go_binary_path=${go_binary_path}
|
||||
if [ -h "${go_binary_path}" ]; then
|
||||
new_go_binary_path=$(readlink ${go_binary_path})
|
||||
fi
|
||||
|
||||
if [[ !"$(dirname ${new_go_binary_path})" =~ *"${GOROOT%%*(/)}"* ]] ; then
|
||||
echo "The go binary found in your PATH configuration does not belong to the Go installation pointed by your GOROOT environment," \
|
||||
"please refer to Go installation document"
|
||||
echo "https://github.com/minio/mc/blob/master/INSTALLGO.md#install-go-13"
|
||||
exit -1
|
||||
fi
|
||||
}
|
||||
|
||||
is_supported_os() {
|
||||
case ${UNAME%% *} in
|
||||
"Linux")
|
||||
os="linux"
|
||||
;;
|
||||
"Darwin")
|
||||
osx_host_version=$(env sw_vers -productVersion)
|
||||
check_version "${osx_host_version}" "${OSX_VERSION}"
|
||||
[[ $? -ge 2 ]] && die "Minimum OSX version supported is ${OSX_VERSION}"
|
||||
;;
|
||||
"*")
|
||||
echo "Exiting.. unsupported operating system found"
|
||||
exit 1;
|
||||
esac
|
||||
}
|
||||
|
||||
is_supported_arch() {
|
||||
local supported
|
||||
case ${UNAME##* } in
|
||||
"x86_64")
|
||||
supported=1
|
||||
;;
|
||||
"arm"*)
|
||||
supported=1
|
||||
assert_is_supported_arch() {
|
||||
case "${ARCH}" in
|
||||
x86_64 | amd64 | ppc64le | aarch64 | arm* | s390x )
|
||||
return
|
||||
;;
|
||||
*)
|
||||
supported=0
|
||||
;;
|
||||
echo "Arch '${ARCH}' is not supported. Supported Arch: [x86_64, amd64, ppc64le, aarch64, arm*, s390x]"
|
||||
exit 1
|
||||
esac
|
||||
if [ $supported -eq 0 ]; then
|
||||
echo "Invalid arch: ${UNAME} not supported, please use x86_64/amd64"
|
||||
exit 1;
|
||||
}
|
||||
|
||||
assert_is_supported_os() {
|
||||
case "${KNAME}" in
|
||||
Linux | FreeBSD | OpenBSD | NetBSD | DragonFly | SunOS )
|
||||
return
|
||||
;;
|
||||
Darwin )
|
||||
osx_host_version=$(env sw_vers -productVersion)
|
||||
if ! check_minimum_version "${OSX_VERSION}" "${osx_host_version}"; then
|
||||
echo "OSX version '${osx_host_version}' is not supported. Minimum supported version: ${OSX_VERSION}"
|
||||
exit 1
|
||||
fi
|
||||
return
|
||||
;;
|
||||
*)
|
||||
echo "OS '${KNAME}' is not supported. Supported OS: [Linux, FreeBSD, OpenBSD, NetBSD, Darwin, DragonFly]"
|
||||
exit 1
|
||||
esac
|
||||
}
|
||||
|
||||
assert_check_golang_env() {
|
||||
if ! which go >/dev/null 2>&1; then
|
||||
echo "Cannot find go binary in your PATH configuration, please refer to Go installation document at https://golang.org/doc/install"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
installed_go_version=$(go version | sed 's/^.* go\([0-9.]*\).*$/\1/')
|
||||
if ! check_minimum_version "${GO_VERSION}" "${installed_go_version}"; then
|
||||
echo "Go runtime version '${installed_go_version}' is unsupported. Minimum supported version: ${GO_VERSION} to compile."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
check_deps() {
|
||||
check_version "$(env go version 2>/dev/null | sed 's/^.* go\([0-9.]*\).*$/\1/')" "${GO_VERSION}"
|
||||
if [ $? -ge 2 ]; then
|
||||
MISSING="${MISSING} golang(>=${GO_VERSION})"
|
||||
fi
|
||||
|
||||
check_version "$(env git --version 2>/dev/null | sed -e 's/^.* \([0-9.\].*\).*$/\1/' -e 's/^\([0-9.\]*\).*/\1/g')" "${GIT_VERSION}"
|
||||
if [ $? -ge 2 ]; then
|
||||
MISSING="${MISSING} git(>=${GIT_VERSION})"
|
||||
assert_check_deps() {
|
||||
# support unusual Git versions such as: 2.7.4 (Apple Git-66)
|
||||
installed_git_version=$(git version | perl -ne '$_ =~ m/git version (.*?)( |$)/; print "$1\n";')
|
||||
if ! check_minimum_version "${GIT_VERSION}" "${installed_git_version}"; then
|
||||
echo "Git version '${installed_git_version}' is not supported. Minimum supported version: ${GIT_VERSION}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
echo -n "Check for supported arch.. "
|
||||
is_supported_arch
|
||||
## Check for supported arch
|
||||
assert_is_supported_arch
|
||||
|
||||
echo -n "Check for supported os.. "
|
||||
is_supported_os
|
||||
## Check for supported os
|
||||
assert_is_supported_os
|
||||
|
||||
echo -n "Checking if proper environment variables are set.. "
|
||||
check_golang_env
|
||||
## Check for Go environment
|
||||
assert_check_golang_env
|
||||
|
||||
echo "Done"
|
||||
echo "Using GOPATH=${GOPATH} and GOROOT=${GOROOT}"
|
||||
|
||||
echo -n "Checking dependencies for Minio Client.. "
|
||||
check_deps
|
||||
|
||||
## If dependencies are missing, warn the user and abort
|
||||
if [ "x${MISSING}" != "x" ]; then
|
||||
echo "ERROR"
|
||||
echo
|
||||
echo "The following build tools are missing:"
|
||||
echo
|
||||
echo "** ${MISSING} **"
|
||||
echo
|
||||
echo "Please install them "
|
||||
echo "${MISSING}"
|
||||
echo
|
||||
echo "Follow https://github.com/minio/mc/blob/master/INSTALLGO.md for further instructions"
|
||||
exit 1
|
||||
fi
|
||||
echo "Done"
|
||||
## Check for dependencies
|
||||
assert_check_deps
|
||||
}
|
||||
|
||||
_init && main "$@"
|
||||
|
||||
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2015-2021 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/>.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
# Enable tracing if set.
|
||||
[ -n "$BASH_XTRACEFD" ] && set -x
|
||||
|
||||
function _init() {
|
||||
## All binaries are static make sure to disable CGO.
|
||||
export CGO_ENABLED=0
|
||||
|
||||
## List of architectures and OS to test coss compilation.
|
||||
SUPPORTED_OSARCH="linux/ppc64le linux/mips64 linux/arm64 linux/s390x darwin/arm64 darwin/amd64 freebsd/amd64 windows/amd64 linux/arm linux/386 netbsd/amd64 linux/mips openbsd/amd64"
|
||||
}
|
||||
|
||||
function _build() {
|
||||
local osarch=$1
|
||||
IFS=/ read -r -a arr <<<"$osarch"
|
||||
os="${arr[0]}"
|
||||
arch="${arr[1]}"
|
||||
package=$(go list -f '{{.ImportPath}}')
|
||||
printf -- "--> %15s:%s\n" "${osarch}" "${package}"
|
||||
|
||||
# Go build to build the binary.
|
||||
export GOOS=$os
|
||||
export GOARCH=$arch
|
||||
export GO111MODULE=on
|
||||
export CGO_ENABLED=0
|
||||
go build -tags kqueue -o /dev/null
|
||||
}
|
||||
|
||||
function main() {
|
||||
echo "Testing builds for OS/Arch: ${SUPPORTED_OSARCH}"
|
||||
for each_osarch in ${SUPPORTED_OSARCH}; do
|
||||
_build "${each_osarch}"
|
||||
done
|
||||
}
|
||||
|
||||
_init && main "$@"
|
||||
+29
-22
@@ -1,20 +1,22 @@
|
||||
//go:build ignore
|
||||
// +build ignore
|
||||
|
||||
/*
|
||||
* Mc Client (C) 2014, 2015 Mc, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright (c) 2015-2021 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 main
|
||||
|
||||
@@ -26,18 +28,23 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func genLDFlags(version string) string {
|
||||
func genLDFlags(now time.Time) string {
|
||||
version := now.Format(time.RFC3339)
|
||||
releaseTag := releaseTag(version)
|
||||
copyrightYear := fmt.Sprintf("%d", now.Year())
|
||||
|
||||
var ldflagsStr string
|
||||
ldflagsStr = "-X main.mcVersion=" + version + " "
|
||||
ldflagsStr = ldflagsStr + "-X main.mcReleaseTag=" + releaseTag(version) + " "
|
||||
ldflagsStr = ldflagsStr + "-X main.mcCommitID=" + commitID() + " "
|
||||
ldflagsStr = ldflagsStr + "-X main.mcShortCommitID=" + commitID()[:12]
|
||||
ldflagsStr = "-s -w -X github.com/minio/mc/cmd.Version=" + version + " "
|
||||
ldflagsStr = ldflagsStr + "-X github.com/minio/mc/cmd.CopyrightYear=" + copyrightYear + " "
|
||||
ldflagsStr = ldflagsStr + "-X github.com/minio/mc/cmd.ReleaseTag=" + releaseTag + " "
|
||||
ldflagsStr = ldflagsStr + "-X github.com/minio/mc/cmd.CommitID=" + commitID() + " "
|
||||
ldflagsStr = ldflagsStr + "-X github.com/minio/mc/cmd.ShortCommitID=" + commitID()[:12]
|
||||
return ldflagsStr
|
||||
}
|
||||
|
||||
// genReleaseTag prints release tag to the console for easy git tagging.
|
||||
func releaseTag(version string) string {
|
||||
relPrefix := "UNOFFICIAL"
|
||||
relPrefix := "DEVELOPMENT"
|
||||
if prefix := os.Getenv("MC_RELEASE"); prefix != "" {
|
||||
relPrefix = prefix
|
||||
}
|
||||
@@ -66,5 +73,5 @@ func commitID() string {
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println(genLDFlags(time.Now().UTC().Format(time.RFC3339)))
|
||||
fmt.Println(genLDFlags(time.Now().UTC()))
|
||||
}
|
||||
|
||||
-152
@@ -1,152 +0,0 @@
|
||||
/*
|
||||
* Minio Client, (C) 2015 Minio, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/minio-xl/pkg/probe"
|
||||
)
|
||||
|
||||
var (
|
||||
catFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "help, h",
|
||||
Usage: "Help of cat",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
// Display contents of a file.
|
||||
var catCmd = cli.Command{
|
||||
Name: "cat",
|
||||
Usage: "Display contents of a file.",
|
||||
Action: mainCat,
|
||||
Flags: append(catFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
mc {{.Name}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
mc {{.Name}} [FLAGS] SOURCE [SOURCE...]
|
||||
|
||||
FLAGS:
|
||||
{{range .Flags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Stream an object from Amazon S3 cloud storage to mplayer standard input.
|
||||
$ mc {{.Name}} s3/ferenginar/klingon_opera_aktuh_maylotah.ogg | mplayer -
|
||||
|
||||
2. Concantenate contents of file1.txt and stdin to standard output.
|
||||
$ mc {{.Name}} file1.txt - > file.txt
|
||||
|
||||
3. Concantenate multiple files to one.
|
||||
$ mc {{.Name}} part.* > complete.img
|
||||
|
||||
`,
|
||||
}
|
||||
|
||||
// checkCatSyntax performs command-line input validation for cat command.
|
||||
func checkCatSyntax(ctx *cli.Context) {
|
||||
args := ctx.Args()
|
||||
if !args.Present() {
|
||||
args = []string{"-"}
|
||||
}
|
||||
for _, arg := range args {
|
||||
if strings.HasPrefix(arg, "-") && len(arg) > 1 {
|
||||
fatalIf(probe.NewError(errors.New("")), fmt.Sprintf("Unknown flag ‘%s’ passed.", arg))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// catURL displays contents of a URL to stdout.
|
||||
func catURL(sourceURL string) *probe.Error {
|
||||
var reader io.Reader
|
||||
switch sourceURL {
|
||||
case "-":
|
||||
reader = os.Stdin
|
||||
default:
|
||||
// Ignore size, since os.Stat() would not return proper size all the
|
||||
// time for local filesystem for example /proc files.
|
||||
var err *probe.Error
|
||||
if reader, err = getSourceStream(sourceURL); err != nil {
|
||||
return err.Trace(sourceURL)
|
||||
}
|
||||
}
|
||||
return catOut(reader).Trace(sourceURL)
|
||||
}
|
||||
|
||||
// catOut reads from reader stream and writes to stdout.
|
||||
func catOut(r io.Reader) *probe.Error {
|
||||
// Read till EOF.
|
||||
if _, e := io.Copy(os.Stdout, r); e != nil {
|
||||
switch e := e.(type) {
|
||||
case *os.PathError:
|
||||
if e.Err == syscall.EPIPE {
|
||||
// stdout closed by the user. Gracefully exit.
|
||||
return nil
|
||||
}
|
||||
return probe.NewError(e)
|
||||
default:
|
||||
return probe.NewError(e)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// mainCat is the main entry point for cat command.
|
||||
func mainCat(ctx *cli.Context) {
|
||||
// Set global flags from context.
|
||||
setGlobalsFromContext(ctx)
|
||||
|
||||
// check 'cat' cli arguments.
|
||||
checkCatSyntax(ctx)
|
||||
|
||||
// Set command flags from context.
|
||||
stdinMode := false
|
||||
if !ctx.Args().Present() {
|
||||
stdinMode = true
|
||||
}
|
||||
|
||||
// handle std input data.
|
||||
if stdinMode {
|
||||
fatalIf(catOut(os.Stdin).Trace(), "Unable to read from standard input.")
|
||||
return
|
||||
}
|
||||
|
||||
// if Args contain ‘-’, we need to preserve its order specially.
|
||||
args := []string(ctx.Args())
|
||||
if ctx.Args().First() == "-" {
|
||||
for i, arg := range os.Args {
|
||||
if arg == "cat" {
|
||||
// Overwrite ctx.Args with os.Args.
|
||||
args = os.Args[i+1:]
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Convert arguments to URLs: expand alias, fix format.
|
||||
for _, url := range args {
|
||||
fatalIf(catURL(url).Trace(url), "Unable to read from ‘"+url+"’.")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2015-2021 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 "path/filepath"
|
||||
|
||||
// isValidAccessPERM - is provided access perm string supported.
|
||||
func (b accessPerms) isValidAccessPERM() bool {
|
||||
switch b {
|
||||
case accessNone, accessDownload, accessUpload, accessPrivate, accessPublic:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (b accessPerms) isValidAccessFile() bool {
|
||||
return filepath.Ext(string(b)) == ".json"
|
||||
}
|
||||
|
||||
// accessPerms - access level.
|
||||
type accessPerms string
|
||||
|
||||
// different types of Access perm's currently supported by policy command.
|
||||
const (
|
||||
accessNone = accessPerms("none")
|
||||
accessDownload = accessPerms("download")
|
||||
accessUpload = accessPerms("upload")
|
||||
accessPrivate = accessPerms("private")
|
||||
accessPublic = accessPerms("public")
|
||||
accessCustom = accessPerms("custom")
|
||||
)
|
||||
@@ -1,25 +1,31 @@
|
||||
/*
|
||||
* Minio Client (C) 2014, 2015 Minio, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright (c) 2015-2021 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 main
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/cheggaaa/pb"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
// accounter keeps tabs of ongoing data transfer information.
|
||||
@@ -51,7 +57,7 @@ func newAccounter(total int64) *accounter {
|
||||
|
||||
// write calculate the final speed.
|
||||
func (a *accounter) write(current int64) float64 {
|
||||
fromStart := time.Now().Sub(a.startTime)
|
||||
fromStart := time.Since(a.startTime)
|
||||
currentFromStart := current - a.startValue
|
||||
if currentFromStart > 0 {
|
||||
speed := float64(currentFromStart) / (float64(fromStart) / float64(time.Second))
|
||||
@@ -75,9 +81,30 @@ func (a *accounter) writer() {
|
||||
|
||||
// accountStat cantainer for current stats captured.
|
||||
type accountStat struct {
|
||||
Total int64
|
||||
Transferred int64
|
||||
Speed float64
|
||||
Status string `json:"status"`
|
||||
Total int64 `json:"total"`
|
||||
Transferred int64 `json:"transferred"`
|
||||
Speed float64 `json:"speed"`
|
||||
}
|
||||
|
||||
func (c accountStat) JSON() string {
|
||||
c.Status = "success"
|
||||
accountMessageBytes, e := json.MarshalIndent(c, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(accountMessageBytes)
|
||||
}
|
||||
|
||||
func (c accountStat) String() string {
|
||||
speedBox := pb.Format(int64(c.Speed)).To(pb.U_BYTES).String()
|
||||
if speedBox == "" {
|
||||
speedBox = "0 MB"
|
||||
} else {
|
||||
speedBox = speedBox + "/s"
|
||||
}
|
||||
message := fmt.Sprintf("Total: %s, Transferred: %s, Speed: %s", pb.Format(c.Total).To(pb.U_BYTES),
|
||||
pb.Format(c.Transferred).To(pb.U_BYTES), speedBox)
|
||||
return message
|
||||
}
|
||||
|
||||
// Stat provides current stats captured.
|
||||
@@ -86,7 +113,7 @@ func (a *accounter) Stat() accountStat {
|
||||
a.finishOnce.Do(func() {
|
||||
close(a.isFinished)
|
||||
acntStat.Total = a.Total
|
||||
acntStat.Transferred = a.current
|
||||
acntStat.Transferred = atomic.LoadInt64(&a.current)
|
||||
acntStat.Speed = a.write(atomic.LoadInt64(&a.current))
|
||||
})
|
||||
return acntStat
|
||||
@@ -107,6 +134,14 @@ func (a *accounter) Set(n int64) *accounter {
|
||||
return a
|
||||
}
|
||||
|
||||
// Get gets current value atomically
|
||||
func (a *accounter) Get() int64 {
|
||||
return atomic.LoadInt64(&a.current)
|
||||
}
|
||||
|
||||
func (a *accounter) SetTotal(int64) {
|
||||
}
|
||||
|
||||
// Add add to current value atomically.
|
||||
func (a *accounter) Add(n int64) int64 {
|
||||
return atomic.AddInt64(&a.current, n)
|
||||
@@ -0,0 +1,169 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminQuotaFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "hard",
|
||||
Usage: "set a hard quota, disallowing writes after quota is reached",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "clear",
|
||||
Usage: "clears bucket quota configured for bucket",
|
||||
},
|
||||
}
|
||||
|
||||
// quotaMessage container for content message structure
|
||||
type quotaMessage struct {
|
||||
op string
|
||||
Status string `json:"status"`
|
||||
Bucket string `json:"bucket"`
|
||||
Quota uint64 `json:"quota,omitempty"`
|
||||
QuotaType string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
func (q quotaMessage) String() string {
|
||||
switch q.op {
|
||||
case "set":
|
||||
return console.Colorize("QuotaMessage",
|
||||
fmt.Sprintf("Successfully set bucket quota of %s with %s type on `%s`", humanize.IBytes(q.Quota), q.QuotaType, q.Bucket))
|
||||
case "unset":
|
||||
return console.Colorize("QuotaMessage",
|
||||
fmt.Sprintf("Successfully cleared bucket quota configured on `%s`", q.Bucket))
|
||||
default:
|
||||
return console.Colorize("QuotaInfo",
|
||||
fmt.Sprintf("Bucket `%s` has %s quota of %s", q.Bucket, q.QuotaType, humanize.IBytes(q.Quota)))
|
||||
}
|
||||
}
|
||||
|
||||
func (q quotaMessage) JSON() string {
|
||||
jsonMessageBytes, e := json.MarshalIndent(q, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(jsonMessageBytes)
|
||||
}
|
||||
|
||||
var adminBucketQuotaCmd = cli.Command{
|
||||
Name: "quota",
|
||||
Usage: "manage bucket quota",
|
||||
Action: mainAdminBucketQuota,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(adminQuotaFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET [--hard QUOTA | --clear]
|
||||
|
||||
QUOTA
|
||||
quota accepts human-readable case-insensitive number
|
||||
suffixes such as "k", "m", "g" and "t" referring to the metric units KB,
|
||||
MB, GB and TB respectively. Adding an "i" to these prefixes, uses the IEC
|
||||
units, so that "gi" refers to "gibibyte" or "GiB". A "b" at the end is
|
||||
also accepted. Without suffixes the unit is bytes.
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Display bucket quota configured for "mybucket" on MinIO.
|
||||
{{.Prompt}} {{.HelpName}} myminio/mybucket
|
||||
|
||||
3. Set hard quota of 1gb for a bucket "mybucket" on MinIO.
|
||||
{{.Prompt}} {{.HelpName}} myminio/mybucket --hard 1GB
|
||||
|
||||
4. Clear bucket quota configured for bucket "mybucket" on MinIO.
|
||||
{{.Prompt}} {{.HelpName}} myminio/mybucket --clear
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminBucketQuotaSyntax - validate all the passed arguments
|
||||
func checkAdminBucketQuotaSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) == 0 || len(ctx.Args()) > 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminBucketQuota is the handler for "mc admin bucket quota" command.
|
||||
func mainAdminBucketQuota(ctx *cli.Context) error {
|
||||
checkAdminBucketQuotaSyntax(ctx)
|
||||
|
||||
console.SetColor("QuotaMessage", color.New(color.FgGreen))
|
||||
console.SetColor("QuotaInfo", color.New(color.FgBlue))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
_, targetURL := url2Alias(args[0])
|
||||
if ctx.IsSet("hard") {
|
||||
qType := madmin.HardQuota
|
||||
quotaStr := ctx.String("hard")
|
||||
quota, e := humanize.ParseBytes(quotaStr)
|
||||
fatalIf(probe.NewError(e).Trace(quotaStr), "Unable to parse quota")
|
||||
if e = client.SetBucketQuota(globalContext, targetURL, &madmin.BucketQuota{Quota: quota, Type: qType}); e != nil {
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to set bucket quota")
|
||||
}
|
||||
printMsg(quotaMessage{
|
||||
op: "set",
|
||||
Bucket: targetURL,
|
||||
Quota: quota,
|
||||
QuotaType: string(qType),
|
||||
Status: "success",
|
||||
})
|
||||
} else if ctx.Bool("clear") {
|
||||
if err := client.SetBucketQuota(globalContext, targetURL, &madmin.BucketQuota{}); err != nil {
|
||||
fatalIf(probe.NewError(err).Trace(args...), "Unable to clear bucket quota config")
|
||||
}
|
||||
printMsg(quotaMessage{
|
||||
op: "unset",
|
||||
Bucket: targetURL,
|
||||
Status: "success",
|
||||
})
|
||||
|
||||
} else {
|
||||
qCfg, e := client.GetBucketQuota(globalContext, targetURL)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get bucket quota")
|
||||
printMsg(quotaMessage{
|
||||
op: "get",
|
||||
Bucket: targetURL,
|
||||
Quota: qCfg.Quota,
|
||||
QuotaType: string(qCfg.Type),
|
||||
Status: "success",
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/minio-go/v7/pkg/s3utils"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminBucketRemoteAddFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "path",
|
||||
Value: "auto",
|
||||
Usage: "bucket path lookup supported by the server. Valid options are '[on,off,auto]'",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "service",
|
||||
Usage: "type of service. Valid options are '[replication]'",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "region",
|
||||
Usage: "region of the destination bucket (optional)",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "bandwidth",
|
||||
Usage: "Set bandwidth limit in bits per second (K,B,G,T for metric and Ki,Bi,Gi,Ti for IEC units)",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "sync",
|
||||
Usage: "enable synchronous replication for this target. Default is async",
|
||||
},
|
||||
cli.UintFlag{
|
||||
Name: "healthcheck-seconds",
|
||||
Usage: "health check duration in seconds",
|
||||
Value: 60,
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "disable-proxy",
|
||||
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",
|
||||
Action: mainAdminBucketRemoteAdd,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(globalFlags, adminBucketRemoteAddFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET http(s)://ACCESSKEY:SECRETKEY@DEST_URL/DEST_BUCKET [--path | --region | --bandwidth] --service
|
||||
|
||||
TARGET:
|
||||
Also called as alias/sourcebucketname
|
||||
|
||||
DEST_BUCKET:
|
||||
Also called as remote target bucket.
|
||||
|
||||
DEST_URL:
|
||||
Also called as remote endpoint.
|
||||
|
||||
ACCESSKEY:
|
||||
Also called as username.
|
||||
|
||||
SECRETKEY:
|
||||
Also called as password.
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Set a new remote replication target "targetbucket" in region "us-west-1" on https://minio.siteb.example.com for bucket 'sourcebucket'.
|
||||
{{.Prompt}} {{.HelpName}} sitea/sourcebucket https://foobar:foo12345@minio.siteb.example.com/targetbucket \
|
||||
--service "replication" --region "us-west-1"
|
||||
|
||||
2. Set a new remote replication target 'targetbucket' in region "us-west-1" on https://minio.siteb.example.com for
|
||||
bucket 'sourcebucket' with bandwidth set to 2 gigabits per second. Enable synchronous replication to the target
|
||||
and perform health check of target every 100 seconds
|
||||
{{.Prompt}} {{.HelpName}} sitea/sourcebucket https://foobar:foo12345@minio.siteb.example.com/targetbucket \
|
||||
--service "replication" --region "us-west-1 --bandwidth "2G" --sync
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminBucketRemoteAddSyntax - validate all the passed arguments
|
||||
func checkAdminBucketRemoteAddSyntax(ctx *cli.Context) {
|
||||
argsNr := len(ctx.Args())
|
||||
if argsNr < 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
|
||||
}
|
||||
if argsNr > 2 {
|
||||
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
|
||||
"Incorrect number of arguments for remote add command.")
|
||||
}
|
||||
}
|
||||
|
||||
// RemoteMessage container for content message structure
|
||||
type RemoteMessage struct {
|
||||
op string
|
||||
Status string `json:"status"`
|
||||
AccessKey string `json:"accessKey,omitempty"`
|
||||
SecretKey string `json:"secretKey,omitempty"`
|
||||
SourceBucket string `json:"sourceBucket"`
|
||||
TargetURL string `json:"TargetURL,omitempty"`
|
||||
TargetBucket string `json:"TargetBucket,omitempty"`
|
||||
RemoteARN string `json:"RemoteARN,omitempty"`
|
||||
Path string `json:"path,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
ServiceType string `json:"service"`
|
||||
Bandwidth int64 `json:"bandwidth"`
|
||||
ReplicationSync bool `json:"replicationSync"`
|
||||
Proxy bool `json:"proxy"`
|
||||
HealthCheckDuration time.Duration `json:"healthcheckDuration"`
|
||||
ResetID string `json:"resetID"`
|
||||
ResetBefore time.Time `json:"resetBeforeDate"`
|
||||
}
|
||||
|
||||
func (r RemoteMessage) String() string {
|
||||
switch r.op {
|
||||
case "ls":
|
||||
message := console.Colorize("TargetURL", fmt.Sprintf("%s ", r.TargetURL))
|
||||
message += console.Colorize("SourceBucket", r.SourceBucket)
|
||||
message += console.Colorize("Arrow", "->")
|
||||
message += console.Colorize("TargetBucket", r.TargetBucket)
|
||||
message += " "
|
||||
message += console.Colorize("ARN", r.RemoteARN)
|
||||
syncStr := " "
|
||||
if r.ReplicationSync && r.ServiceType == string(madmin.ReplicationService) {
|
||||
syncStr = "sync"
|
||||
}
|
||||
message += " " + console.Colorize("SyncLabel", syncStr)
|
||||
proxyStr := " "
|
||||
if r.Proxy && r.ServiceType == string(madmin.ReplicationService) {
|
||||
proxyStr = "proxy"
|
||||
}
|
||||
message += " "
|
||||
message += console.Colorize("ProxyLabel", proxyStr)
|
||||
return message
|
||||
case "rm":
|
||||
return console.Colorize("RemoteMessage", "Removed remote target for `"+r.SourceBucket+"` bucket successfully.")
|
||||
case "add":
|
||||
return console.Colorize("RemoteMessage", "Remote ARN = `"+r.RemoteARN+"`.")
|
||||
case "edit":
|
||||
return console.Colorize("RemoteMessage", "Remote target updated successfully for target with ARN:`"+r.RemoteARN+"`.")
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// JSON returns jsonified message
|
||||
func (r RemoteMessage) JSON() string {
|
||||
r.Status = "success"
|
||||
jsonMessageBytes, e := json.MarshalIndent(r, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(jsonMessageBytes)
|
||||
}
|
||||
|
||||
func extractCredentialURL(argURL string) (accessKey, secretKey string, u *url.URL) {
|
||||
var parsedURL string
|
||||
if hostKeyTokens.MatchString(argURL) {
|
||||
fatalIf(errInvalidArgument().Trace(argURL), "temporary tokens are not allowed for remote targets")
|
||||
}
|
||||
if hostKeys.MatchString(argURL) {
|
||||
parts := hostKeys.FindStringSubmatch(argURL)
|
||||
if len(parts) != 5 {
|
||||
fatalIf(errInvalidArgument().Trace(argURL), "Unsupported remote target format, please check --help")
|
||||
}
|
||||
accessKey = parts[2]
|
||||
secretKey = parts[3]
|
||||
parsedURL = fmt.Sprintf("%s%s", parts[1], parts[4])
|
||||
}
|
||||
var e error
|
||||
if parsedURL == "" {
|
||||
fatalIf(errInvalidArgument().Trace(argURL), "No valid credentials were detected")
|
||||
}
|
||||
u, e = url.Parse(parsedURL)
|
||||
if e != nil {
|
||||
fatalIf(errInvalidArgument().Trace(parsedURL), "Unsupported URL format %v", e)
|
||||
}
|
||||
|
||||
return accessKey, secretKey, u
|
||||
}
|
||||
|
||||
// fetchRemoteTarget - returns the dest bucket, dest endpoint, access and secret key
|
||||
func fetchRemoteTarget(cli *cli.Context) (sourceBucket string, bktTarget *madmin.BucketTarget) {
|
||||
args := cli.Args()
|
||||
argCount := len(args)
|
||||
if argCount < 2 {
|
||||
fatalIf(probe.NewError(fmt.Errorf("Missing Remote target configuration")), "Unable to parse remote target")
|
||||
}
|
||||
_, sourceBucket = url2Alias(args[0])
|
||||
p := cli.String("path")
|
||||
if !isValidPath(p) {
|
||||
fatalIf(errInvalidArgument().Trace(p),
|
||||
"Unrecognized bucket path style. Valid options are `[on,off, auto]`.")
|
||||
}
|
||||
|
||||
tgtURL := args[1]
|
||||
accessKey, secretKey, u := extractCredentialURL(tgtURL)
|
||||
var tgtBucket string
|
||||
if u.Path != "" {
|
||||
tgtBucket = path.Clean(u.Path[1:])
|
||||
}
|
||||
if e := s3utils.CheckValidBucketName(tgtBucket); e != nil {
|
||||
fatalIf(probe.NewError(e).Trace(tgtURL), "Invalid target bucket specified")
|
||||
}
|
||||
|
||||
serviceType := cli.String("service")
|
||||
if !madmin.ServiceType(serviceType).IsValid() {
|
||||
fatalIf(errInvalidArgument().Trace(serviceType), "Invalid service type. Valid option is `[replication]`.")
|
||||
}
|
||||
if cli.IsSet("sync") && serviceType != string(madmin.ReplicationService) {
|
||||
fatalIf(errInvalidArgument(), "Invalid usage. --sync flag applies only to replication service")
|
||||
}
|
||||
bandwidthStr := cli.String("bandwidth")
|
||||
bandwidth, err := getBandwidthInBytes(bandwidthStr)
|
||||
if err != nil {
|
||||
fatalIf(errInvalidArgument().Trace(bandwidthStr), "Invalid bandwidth number")
|
||||
}
|
||||
console.SetColor(cred, color.New(color.FgYellow, color.Italic))
|
||||
creds := &madmin.Credentials{AccessKey: accessKey, SecretKey: secretKey}
|
||||
disableproxy := cli.Bool("disable-proxy")
|
||||
bktTarget = &madmin.BucketTarget{
|
||||
TargetBucket: tgtBucket,
|
||||
Secure: u.Scheme == "https",
|
||||
Credentials: creds,
|
||||
Endpoint: u.Host,
|
||||
Path: p,
|
||||
API: "s3v4",
|
||||
Type: madmin.ServiceType(serviceType),
|
||||
Region: cli.String("region"),
|
||||
BandwidthLimit: int64(bandwidth),
|
||||
ReplicationSync: cli.Bool("sync"),
|
||||
DisableProxy: disableproxy,
|
||||
HealthCheckDuration: time.Duration(cli.Uint("healthcheck-seconds")) * time.Second,
|
||||
}
|
||||
return sourceBucket, bktTarget
|
||||
}
|
||||
|
||||
func getBandwidthInBytes(bandwidthStr string) (bandwidth uint64, err error) {
|
||||
if bandwidthStr != "" {
|
||||
bandwidth, err = humanize.ParseBytes(bandwidthStr)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
bandwidth = bandwidth / 8
|
||||
return
|
||||
}
|
||||
|
||||
// mainAdminBucketRemoteAdd is the handle for "mc admin bucket remote set" command.
|
||||
func mainAdminBucketRemoteAdd(ctx *cli.Context) error {
|
||||
checkAdminBucketRemoteAddSyntax(ctx)
|
||||
console.SetColor("RemoteMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
// Create a new MinIO Admin Client
|
||||
client, cerr := newAdminClient(aliasedURL)
|
||||
fatalIf(cerr, "Unable to initialize admin connection.")
|
||||
|
||||
sourceBucket, bktTarget := fetchRemoteTarget(ctx)
|
||||
arn, e := client.SetRemoteTarget(globalContext, sourceBucket, bktTarget)
|
||||
if e != nil {
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to configure remote target")
|
||||
}
|
||||
|
||||
printMsg(RemoteMessage{
|
||||
op: ctx.Command.Name,
|
||||
TargetURL: bktTarget.URL().String(),
|
||||
TargetBucket: bktTarget.TargetBucket,
|
||||
AccessKey: bktTarget.Credentials.AccessKey,
|
||||
SourceBucket: sourceBucket,
|
||||
RemoteARN: arn,
|
||||
ReplicationSync: bktTarget.ReplicationSync,
|
||||
Proxy: !bktTarget.DisableProxy,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetBandwidthInBytes(t *testing.T) {
|
||||
type args struct {
|
||||
bandwidthStr string
|
||||
}
|
||||
f1 := 999.123457 * 1024 * 1024 / 8
|
||||
f2 := 10.123456790 * 1024 * 1024 * 1024 / 8
|
||||
f3 := 10000.123456790 * 1024 * 1024 * 1024 / 8
|
||||
f4 := (0.001*1024*1024*1024 + 1) / 8 // round up
|
||||
tests := []struct {
|
||||
name string
|
||||
args args
|
||||
want uint64
|
||||
}{
|
||||
{
|
||||
name: "1MegaByte",
|
||||
args: args{
|
||||
bandwidthStr: "1Mi",
|
||||
},
|
||||
want: 1024 * 1024 / 8,
|
||||
},
|
||||
{
|
||||
name: "1MegaBit",
|
||||
args: args{
|
||||
bandwidthStr: "1M",
|
||||
},
|
||||
want: 1000000 / 8,
|
||||
},
|
||||
{
|
||||
name: "1GigaBit",
|
||||
args: args{
|
||||
bandwidthStr: "1G",
|
||||
},
|
||||
want: 1000000000 / 8,
|
||||
},
|
||||
{
|
||||
name: "1GigaByte",
|
||||
args: args{
|
||||
bandwidthStr: "1Gi",
|
||||
},
|
||||
want: 1024 * 1024 * 1024 / 8,
|
||||
},
|
||||
{
|
||||
name: "FractionalMegaBits",
|
||||
args: args{
|
||||
bandwidthStr: "999.123456789123456789M",
|
||||
},
|
||||
want: 999123457 / 8,
|
||||
},
|
||||
{
|
||||
name: "FractionalGigaBits",
|
||||
args: args{
|
||||
bandwidthStr: "10.123456789123456789123456G",
|
||||
},
|
||||
want: 10123456789 / 8,
|
||||
},
|
||||
{
|
||||
name: "FractionalBigGigaBits",
|
||||
args: args{
|
||||
bandwidthStr: "10000.123456789123456789123456G",
|
||||
},
|
||||
want: 10000123456789 / 8,
|
||||
},
|
||||
{
|
||||
name: "FractionalMegaBytes",
|
||||
args: args{
|
||||
bandwidthStr: "999.123456789123456789Mi",
|
||||
},
|
||||
want: uint64(f1),
|
||||
},
|
||||
{
|
||||
name: "FractionalGigaBytes",
|
||||
args: args{
|
||||
bandwidthStr: "10.123456789123456789123456Gi",
|
||||
},
|
||||
want: uint64(f2),
|
||||
},
|
||||
{
|
||||
name: "FractionalBigGigaBytes",
|
||||
args: args{
|
||||
bandwidthStr: "10000.123456789123456789123456Gi",
|
||||
},
|
||||
want: uint64(f3),
|
||||
},
|
||||
{
|
||||
name: "SmallGiga",
|
||||
args: args{
|
||||
bandwidthStr: "0.001Gi",
|
||||
},
|
||||
want: uint64(f4),
|
||||
},
|
||||
{
|
||||
name: "LargeK",
|
||||
args: args{
|
||||
bandwidthStr: "1024Ki",
|
||||
},
|
||||
want: 1024 * 1024 / 8,
|
||||
},
|
||||
}
|
||||
t.Parallel()
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got, err := getBandwidthInBytes(tt.args.bandwidthStr); err != nil || got != tt.want {
|
||||
t.Errorf("getBandwidthInBytes() = %v, want %v", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminBandwidthInfoCmdFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "unit",
|
||||
Value: "b",
|
||||
Usage: "[b|bi|B|Bi] Display bandwidth in bits (IEC [bi] or SI [b]) or bytes (IEC [Bi] or SI [B])",
|
||||
},
|
||||
}
|
||||
|
||||
var adminBwInfoCmd = cli.Command{
|
||||
Name: "bandwidth",
|
||||
Usage: "Show bandwidth info for buckets on the MinIO server in bits or bytes per second. Ki,Bi,Mi,Gi represent IEC units.",
|
||||
Action: mainAdminBwInfo,
|
||||
Before: setGlobalsFromContext,
|
||||
OnUsageError: onUsageError,
|
||||
Flags: append(globalFlags, adminBandwidthInfoCmdFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} FLAGS TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Show the bandwidth usage for all the buckets in a MinIO server setup
|
||||
{{.Prompt}} {{.HelpName}} play/
|
||||
2. Show the bandwidth usage for the bucket 'source-bucket' in a MinIO server setup
|
||||
{{.Prompt}} {{.HelpName}} play/source-bucket
|
||||
`,
|
||||
}
|
||||
|
||||
func printTable(report madmin.Report, bits bool, iec bool) {
|
||||
bucketMaxLength := 63
|
||||
bucketColLength := 6
|
||||
var bucketKeys []string
|
||||
for bucket := range report.Report.BucketStats {
|
||||
if len(bucket) <= bucketMaxLength && len(bucket) > bucketColLength {
|
||||
bucketColLength = len(bucket)
|
||||
}
|
||||
bucketKeys = append(bucketKeys, bucket)
|
||||
}
|
||||
sort.Strings(bucketKeys)
|
||||
dspOrder := []col{colGreen} // Header
|
||||
for i := 0; i < len(report.Report.BucketStats); i++ {
|
||||
dspOrder = append(dspOrder, colGrey)
|
||||
}
|
||||
var printColors []*color.Color
|
||||
for _, c := range dspOrder {
|
||||
printColors = append(printColors, getPrintCol(c))
|
||||
}
|
||||
|
||||
cellText := make([][]string, len(report.Report.BucketStats)+1) // 1 for the header
|
||||
tbl := console.NewTable(printColors, []bool{false, false, false}, 0)
|
||||
bucketTitle := fmt.Sprintf("%-16v", "Bucket")
|
||||
cellText[0] = []string{
|
||||
bucketTitle,
|
||||
"Configured Max Bandwidth",
|
||||
"Current Bandwidth",
|
||||
}
|
||||
tbl.HeaderRowSeparator = true
|
||||
index := 1
|
||||
|
||||
for _, bucket := range bucketKeys {
|
||||
values := report.Report.BucketStats[bucket]
|
||||
if len(bucket) > bucketMaxLength {
|
||||
bucket = bucket[:bucketMaxLength] + ".."
|
||||
}
|
||||
var mul uint64
|
||||
mul = 1
|
||||
if bits {
|
||||
mul = 8
|
||||
}
|
||||
limit := humanize.Bytes(uint64(values.LimitInBytesPerSecond) * mul)
|
||||
current := humanize.Bytes(uint64(values.CurrentBandwidthInBytesPerSecond) * mul)
|
||||
if iec {
|
||||
limit = humanize.IBytes(uint64(values.LimitInBytesPerSecond)*mul) + "/sec"
|
||||
current = humanize.IBytes(uint64(values.CurrentBandwidthInBytesPerSecond)*mul) + "/sec"
|
||||
}
|
||||
if bits {
|
||||
limit = strings.ToLower(limit) + "/sec"
|
||||
current = strings.ToLower(current) + "/sec"
|
||||
}
|
||||
if values.LimitInBytesPerSecond == 0 {
|
||||
limit = "N/A" // N/A means cluster bandwidth is not configured
|
||||
}
|
||||
cellText[index] = []string{
|
||||
bucket,
|
||||
limit,
|
||||
current,
|
||||
}
|
||||
index++
|
||||
}
|
||||
if len(report.Report.BucketStats) > 0 {
|
||||
err := tbl.DisplayTable(cellText)
|
||||
if err != nil {
|
||||
console.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func checkAdminBwInfoSyntax(ctx *cli.Context) {
|
||||
u := ctx.String("unit")
|
||||
if u != "bi" &&
|
||||
u != "b" &&
|
||||
u != "Bi" &&
|
||||
u != "B" &&
|
||||
u != "" {
|
||||
cli.ShowCommandHelpAndExit(ctx, "bandwidth", globalErrorExitStatus)
|
||||
}
|
||||
if len(ctx.Args()) > 1 || len(ctx.Args()) == 0 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "bandwidth", globalErrorExitStatus)
|
||||
}
|
||||
}
|
||||
|
||||
func mainAdminBwInfo(ctx *cli.Context) {
|
||||
checkAdminBwInfoSyntax(ctx)
|
||||
aliasURL, bucket := getAliasAndBucket(ctx)
|
||||
client := getClient(aliasURL)
|
||||
reportCh := client.GetBucketBandwidth(globalContext, bucket)
|
||||
firstPrint := true
|
||||
bandwidthUnitsString := ctx.String("unit")
|
||||
for {
|
||||
select {
|
||||
case report := <-reportCh:
|
||||
if len(report.Report.BucketStats) == 0 {
|
||||
continue
|
||||
}
|
||||
if report.Err != nil {
|
||||
if strings.Contains(report.Err.Error(), "EOF") {
|
||||
continue
|
||||
}
|
||||
console.Error(report.Err)
|
||||
}
|
||||
printBandwidth(report, firstPrint, bandwidthUnitsString == "bi" || bandwidthUnitsString == "b",
|
||||
bandwidthUnitsString == "bi" || bandwidthUnitsString == "Bi")
|
||||
firstPrint = false
|
||||
case <-globalContext.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func printBandwidth(report madmin.Report, firstPrint bool, bits bool, iec bool) {
|
||||
rewindLines := len(report.Report.BucketStats) + 4
|
||||
if firstPrint {
|
||||
rewindLines = 0
|
||||
}
|
||||
if globalJSON {
|
||||
reportJSON, e := json.MarshalIndent(report, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal to JSON")
|
||||
console.Println(string(reportJSON))
|
||||
time.Sleep(1 * time.Second)
|
||||
return
|
||||
}
|
||||
if len(report.Report.BucketStats) > 0 {
|
||||
console.RewindLines(rewindLines)
|
||||
// For the next iteration, rewind lines
|
||||
printTable(report, bits, iec)
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/minio-go/v7/pkg/s3utils"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminBucketRemoteEditFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "arn",
|
||||
Usage: "ARN of target",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "sync",
|
||||
Usage: "enable synchronous replication for this target. Valid values are enable,disable.Defaults to disable if unset",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "proxy",
|
||||
Usage: "enable proxying in active-active replication. Valid values are enable,disable.By default proxying is enabled.",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "bandwidth",
|
||||
Usage: "Set bandwidth limit in bits per second (K,B,G,T for metric and Ki,Bi,Gi,Ti for IEC units)",
|
||||
},
|
||||
cli.UintFlag{
|
||||
Name: "healthcheck-seconds",
|
||||
Usage: "health check duration in seconds",
|
||||
Value: 60,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "path",
|
||||
Value: "auto",
|
||||
Usage: "bucket path lookup supported by the server. Valid options are '[on,off,auto]'",
|
||||
},
|
||||
}
|
||||
|
||||
var adminBucketRemoteEditCmd = cli.Command{
|
||||
Name: "edit",
|
||||
Usage: "edit remote target",
|
||||
Action: mainAdminBucketRemoteEdit,
|
||||
Before: setGlobalsFromContext,
|
||||
OnUsageError: onUsageError,
|
||||
Flags: append(globalFlags, adminBucketRemoteEditFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET http(s)://ACCESSKEY:SECRETKEY@DEST_URL/DEST_BUCKET --arn arn
|
||||
|
||||
TARGET:
|
||||
Also called as alias/sourcebucketname
|
||||
|
||||
DEST_BUCKET:
|
||||
Also called as remote target bucket.
|
||||
|
||||
DEST_URL:
|
||||
Also called as remote endpoint.
|
||||
|
||||
ACCESSKEY:
|
||||
Also called as username.
|
||||
|
||||
SECRETKEY:
|
||||
Also called as password.
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Edit credentials for existing remote target with arn where a remote target has been configured between sourcebucket on sitea to targetbucket on siteb.
|
||||
{{.DisableHistory}}
|
||||
{{.Prompt}} {{.HelpName}} sitea/sourcebucket \
|
||||
https://foobar:newpassword@minio.siteb.example.com/targetbucket \
|
||||
--arn "arn:minio:replication:us-west-1:993bc6b6-accd-45e3-884f-5f3e652aed2a:dest1"
|
||||
{{.EnableHistory}}
|
||||
|
||||
2. Edit remote target for sourceBucket on sitea with specified ARN to disable proxying and enable synchronous replication
|
||||
{{.Prompt}} {{.HelpName}} sitea/sourcebucket --sync "enable" --proxy "disable"
|
||||
--arn "arn:minio:replication:us-west-1:993bc6b6-accd-45e3-884f-5f3e652aed2a:dest1"
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminBucketRemoteEditSyntax - validate all the passed arguments
|
||||
func checkAdminBucketRemoteEditSyntax(ctx *cli.Context) {
|
||||
argsNr := len(ctx.Args())
|
||||
if argsNr > 2 || argsNr == 0 {
|
||||
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
|
||||
}
|
||||
if !ctx.IsSet("arn") {
|
||||
fatalIf(errInvalidArgument().Trace(ctx.Args()...), "--arn flag needs to be set")
|
||||
}
|
||||
}
|
||||
|
||||
// modifyRemoteTarget - modifies the dest credentials or updates sync , disable-proxy settings
|
||||
func modifyRemoteTarget(cli *cli.Context, targets []madmin.BucketTarget) (*madmin.BucketTarget, []madmin.TargetUpdateType) {
|
||||
args := cli.Args()
|
||||
foundIdx := -1
|
||||
arn := cli.String("arn")
|
||||
for i, t := range targets {
|
||||
if t.Arn == arn {
|
||||
foundIdx = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if foundIdx < 0 {
|
||||
fatalIf(errInvalidArgument().Trace(args...), "Unable to edit remote target - `"+arn+"` not found")
|
||||
}
|
||||
var ops []madmin.TargetUpdateType
|
||||
bktTarget := targets[foundIdx].Clone()
|
||||
if cli.IsSet("sync") {
|
||||
syncState := strings.ToLower(cli.String("sync"))
|
||||
switch syncState {
|
||||
case "enable", "disable":
|
||||
bktTarget.ReplicationSync = syncState == "enable"
|
||||
ops = append(ops, madmin.SyncUpdateType)
|
||||
default:
|
||||
fatalIf(errInvalidArgument().Trace(args...), "--sync can be either [enable|disable]")
|
||||
}
|
||||
}
|
||||
if cli.IsSet("proxy") {
|
||||
proxyState := strings.ToLower(cli.String("proxy"))
|
||||
switch proxyState {
|
||||
case "enable", "disable":
|
||||
bktTarget.DisableProxy = proxyState == "disable"
|
||||
ops = append(ops, madmin.ProxyUpdateType)
|
||||
|
||||
default:
|
||||
fatalIf(errInvalidArgument().Trace(args...), "--proxy can be either [enable|disable]")
|
||||
}
|
||||
}
|
||||
|
||||
if len(args) == 2 {
|
||||
_, sourceBucket := url2Alias(args[0])
|
||||
|
||||
tgtURL := args[1]
|
||||
accessKey, secretKey, u := extractCredentialURL(tgtURL)
|
||||
var tgtBucket string
|
||||
if u.Path != "" {
|
||||
tgtBucket = path.Clean(u.Path[1:])
|
||||
}
|
||||
if e := s3utils.CheckValidBucketName(tgtBucket); e != nil {
|
||||
fatalIf(probe.NewError(e).Trace(tgtURL), "Invalid target bucket specified")
|
||||
}
|
||||
secure := u.Scheme == "https"
|
||||
host := u.Host
|
||||
if u.Port() == "" {
|
||||
port := 80
|
||||
if secure {
|
||||
port = 443
|
||||
}
|
||||
host = host + ":" + strconv.Itoa(port)
|
||||
}
|
||||
console.SetColor(cred, color.New(color.FgYellow, color.Italic))
|
||||
creds := &madmin.Credentials{AccessKey: accessKey, SecretKey: secretKey}
|
||||
if tgtBucket != bktTarget.TargetBucket {
|
||||
fatalIf(errInvalidArgument().Trace(args...), "configured remote target bucket `"+tgtBucket+"` does not match "+bktTarget.TargetBucket+"` for this ARN `"+bktTarget.Arn+"`")
|
||||
}
|
||||
if sourceBucket != bktTarget.SourceBucket {
|
||||
fatalIf(errInvalidArgument().Trace(args...), "configured source bucket `"+sourceBucket+"` does not match "+bktTarget.SourceBucket+"` for this ARN `"+bktTarget.Arn+"`")
|
||||
}
|
||||
bktTarget.TargetBucket = tgtBucket
|
||||
bktTarget.Secure = secure
|
||||
bktTarget.Credentials = creds
|
||||
bktTarget.Endpoint = host
|
||||
ops = append(ops, madmin.CredentialsUpdateType)
|
||||
}
|
||||
if cli.IsSet("bandwidth") {
|
||||
bandwidthStr := cli.String("bandwidth")
|
||||
bandwidth, err := getBandwidthInBytes(bandwidthStr)
|
||||
if err != nil {
|
||||
fatalIf(errInvalidArgument().Trace(bandwidthStr), "Invalid bandwidth number")
|
||||
}
|
||||
bktTarget.BandwidthLimit = int64(bandwidth)
|
||||
ops = append(ops, madmin.BandwidthLimitUpdateType)
|
||||
|
||||
}
|
||||
if cli.IsSet("healthcheck-seconds") {
|
||||
bktTarget.HealthCheckDuration = time.Duration(cli.Uint("healthcheck-seconds")) * time.Second
|
||||
ops = append(ops, madmin.HealthCheckDurationUpdateType)
|
||||
}
|
||||
if cli.IsSet("path") {
|
||||
bktTarget.Path = cli.String("path")
|
||||
ops = append(ops, madmin.PathUpdateType)
|
||||
}
|
||||
return &bktTarget, ops
|
||||
}
|
||||
|
||||
// mainAdminBucketRemoteEdit is the handle for "mc admin bucket remote edit" command.
|
||||
func mainAdminBucketRemoteEdit(ctx *cli.Context) error {
|
||||
checkAdminBucketRemoteEditSyntax(ctx)
|
||||
|
||||
console.SetColor("RemoteMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
// Create a new MinIO Admin Client
|
||||
client, cerr := newAdminClient(aliasedURL)
|
||||
fatalIf(cerr, "Unable to initialize admin connection.")
|
||||
_, sourceBucket := url2Alias(args[0])
|
||||
|
||||
targets, e := client.ListRemoteTargets(globalContext, sourceBucket, "")
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to fetch remote target.")
|
||||
|
||||
bktTarget, ops := modifyRemoteTarget(ctx, targets)
|
||||
|
||||
arn, e := client.UpdateRemoteTarget(globalContext, bktTarget, ops...)
|
||||
if e != nil {
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to update remote target `"+bktTarget.Endpoint+"` from `"+bktTarget.SourceBucket+"` -> `"+bktTarget.TargetBucket+"`")
|
||||
}
|
||||
|
||||
printMsg(RemoteMessage{
|
||||
op: ctx.Command.Name,
|
||||
TargetURL: bktTarget.URL().String(),
|
||||
TargetBucket: bktTarget.TargetBucket,
|
||||
AccessKey: bktTarget.Credentials.AccessKey,
|
||||
SourceBucket: bktTarget.SourceBucket,
|
||||
RemoteARN: arn,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminBucketRemoteListFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "service",
|
||||
Usage: "type of service. valid options are '[replication]'",
|
||||
},
|
||||
}
|
||||
|
||||
var adminBucketRemoteListCmd = cli.Command{
|
||||
Name: "ls",
|
||||
Usage: "list remote target ARN(s)",
|
||||
Action: mainAdminBucketRemoteList,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(globalFlags, adminBucketRemoteListFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Get remote bucket target for replication on MinIO server for bucket 'srcbucket'.
|
||||
{{.Prompt}} {{.HelpName}} myminio/srcbucket --service "replication"
|
||||
|
||||
2. List all remote bucket target(s) on MinIO server for bucket 'srcbucket'.
|
||||
{{.Prompt}} {{.HelpName}} myminio/srcbucket
|
||||
|
||||
3. List all remote bucket target(s) on MinIO tenant.
|
||||
{{.Prompt}} {{.HelpName}} myminio
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminBucketRemoteListSyntax - validate all the passed arguments
|
||||
func checkAdminBucketRemoteListSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminBucketRemoteList is the handle for "mc admin bucket remote list" command.
|
||||
func mainAdminBucketRemoteList(ctx *cli.Context) error {
|
||||
checkAdminBucketRemoteListSyntax(ctx)
|
||||
|
||||
// Additional command specific theme customization.
|
||||
console.SetColor("RemoteListMessage", color.New(color.Bold, color.FgHiGreen))
|
||||
console.SetColor("RemoteListEmpty", color.New(color.FgYellow))
|
||||
console.SetColor("SourceBucket", color.New(color.FgYellow))
|
||||
console.SetColor("TargetBucket", color.New(color.FgYellow))
|
||||
console.SetColor("TargetURL", color.New(color.FgHiWhite))
|
||||
console.SetColor("ARN", color.New(color.FgCyan))
|
||||
console.SetColor("Arrow", color.New(color.FgHiWhite))
|
||||
console.SetColor("SyncLabel", color.New(color.FgHiYellow))
|
||||
console.SetColor("ProxyLabel", color.New(color.FgHiYellow))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
aliasedURL = filepath.Clean(aliasedURL)
|
||||
_, sourceBucket := url2Alias(aliasedURL)
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
targets, e := client.ListRemoteTargets(globalContext, sourceBucket, ctx.String("service"))
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to list remote target")
|
||||
printRemotes(ctx, aliasedURL, targets)
|
||||
return nil
|
||||
}
|
||||
|
||||
func printRemotes(ctx *cli.Context, urlStr string, targets []madmin.BucketTarget) {
|
||||
maxURLLen := 10
|
||||
maxTgtLen := 6
|
||||
maxSrcLen := 6
|
||||
maxArnLen := 3
|
||||
|
||||
if !globalJSON {
|
||||
if len(targets) == 0 {
|
||||
console.Print(console.Colorize("RemoteListEmpty", fmt.Sprintf("No remote targets found for `%s`. \n", urlStr)))
|
||||
return
|
||||
}
|
||||
for _, t := range targets {
|
||||
l := len(t.Endpoint)
|
||||
if l > maxURLLen {
|
||||
maxURLLen = l
|
||||
}
|
||||
if len(t.TargetBucket) > maxTgtLen {
|
||||
maxTgtLen = len(t.TargetBucket)
|
||||
}
|
||||
if len(t.SourceBucket) > maxSrcLen {
|
||||
maxSrcLen = len(t.SourceBucket)
|
||||
}
|
||||
if len(t.Arn) > maxArnLen {
|
||||
maxArnLen = len(t.Arn)
|
||||
}
|
||||
}
|
||||
if maxURLLen > 0 {
|
||||
console.Println(console.Colorize("RemoteListMessage", fmt.Sprintf("%-*.*s %-*.*s->%-*.*s %-*.*s %s %s", maxURLLen+8, maxURLLen+8, "Remote URL", maxSrcLen, maxSrcLen, "Source", maxTgtLen, maxTgtLen, "Target", maxArnLen, maxArnLen, "ARN", "SYNC", "PROXY")))
|
||||
}
|
||||
}
|
||||
for _, target := range targets {
|
||||
targetURL := target.URL().String()
|
||||
if !globalJSON {
|
||||
if maxURLLen > 0 {
|
||||
targetURL = fmt.Sprintf("%-*.*s", maxURLLen+8, maxURLLen+8, target.URL().String())
|
||||
}
|
||||
if maxTgtLen > 0 {
|
||||
target.TargetBucket = fmt.Sprintf("%-*.*s", maxTgtLen, maxTgtLen, target.TargetBucket)
|
||||
}
|
||||
|
||||
if maxSrcLen > 0 {
|
||||
target.SourceBucket = fmt.Sprintf("%-*.*s", maxSrcLen, maxSrcLen, target.SourceBucket)
|
||||
}
|
||||
if maxArnLen > 0 {
|
||||
target.Arn = fmt.Sprintf("%-*.*s", maxArnLen, maxArnLen, target.Arn)
|
||||
}
|
||||
}
|
||||
printMsg(RemoteMessage{
|
||||
op: ctx.Command.Name,
|
||||
AccessKey: target.Credentials.AccessKey,
|
||||
TargetBucket: target.TargetBucket,
|
||||
TargetURL: targetURL,
|
||||
SourceBucket: target.SourceBucket,
|
||||
RemoteARN: target.Arn,
|
||||
ServiceType: string(target.Type),
|
||||
ReplicationSync: target.ReplicationSync,
|
||||
Bandwidth: target.BandwidthLimit,
|
||||
Proxy: !target.DisableProxy,
|
||||
ResetID: target.ResetID,
|
||||
ResetBefore: target.ResetBeforeDate,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright (c) 2015-2021 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 adminBucketRemoteSubcommands = []cli.Command{
|
||||
adminBucketRemoteAddCmd,
|
||||
adminBucketRemoteEditCmd,
|
||||
adminBucketRemoteListCmd,
|
||||
adminBucketRemoteRmCmd,
|
||||
adminBwInfoCmd,
|
||||
}
|
||||
|
||||
var adminBucketRemoteCmd = cli.Command{
|
||||
Name: "remote",
|
||||
Usage: "configure remote target buckets",
|
||||
Action: mainadminBucketRemote,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: adminBucketRemoteSubcommands,
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
// mainadminBucketRemote is the handle for "mc admin bucket remote" command.
|
||||
func mainadminBucketRemote(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminBucketRemoteSubcommands)
|
||||
return nil
|
||||
// Sub-commands like "add", "ls", "rm" have their own main.
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
// Copyright (c) 2015-2021 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/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminBucketRemoteRmFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "arn",
|
||||
Usage: "ARN to be removed",
|
||||
},
|
||||
}
|
||||
|
||||
var adminBucketRemoteRmCmd = cli.Command{
|
||||
Name: "rm",
|
||||
Usage: "remove configured remote target",
|
||||
Action: mainAdminBucketRemoteRemove,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(globalFlags, adminBucketRemoteRmFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Remove existing remote target with arn "arn:minio:replication:us-west-1:993bc6b6-accd-45e3-884f-5f3e652aed2a:dest1"
|
||||
for bucket srcbucket on MinIO server.
|
||||
{{.Prompt}} {{.HelpName}} myminio/srcbucket --arn "arn:minio:replication:us-west-1:993bc6b6-accd-45e3-884f-5f3e652aed2a:dest1"
|
||||
`,
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminBucketRemoteRemove is the handle for "mc admin bucket remote rm" command.
|
||||
func mainAdminBucketRemoteRemove(ctx *cli.Context) error {
|
||||
checkAdminBucketRemoteRemoveSyntax(ctx)
|
||||
|
||||
console.SetColor("RemoteMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
// Create a new MinIO Admin Client
|
||||
client, cerr := newAdminClient(aliasedURL)
|
||||
fatalIf(cerr.Trace(aliasedURL), "Unable to initialize admin connection.")
|
||||
_, sourceBucket := url2Alias(args[0])
|
||||
if sourceBucket == "" {
|
||||
fatalIf(errInvalidArgument(), "Source bucket not specified in `"+args[0]+"`.")
|
||||
}
|
||||
arn := ctx.String("arn")
|
||||
if arn == "" {
|
||||
fatalIf(errInvalidArgument(), "ARN needs to be specified.")
|
||||
}
|
||||
fatalIf(probe.NewError(client.RemoveRemoteTarget(globalContext, sourceBucket, arn)).Trace(args...), "Unable to remove remote target")
|
||||
|
||||
printMsg(RemoteMessage{
|
||||
op: ctx.Command.Name,
|
||||
SourceBucket: sourceBucket,
|
||||
RemoteARN: arn,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2015-2021 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 adminBucketSubcommands = []cli.Command{
|
||||
adminBucketRemoteCmd,
|
||||
adminBucketQuotaCmd,
|
||||
}
|
||||
|
||||
var adminBucketCmd = cli.Command{
|
||||
Name: "bucket",
|
||||
Usage: "manage buckets defined in the MinIO server",
|
||||
Action: mainAdminBucket,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: adminBucketSubcommands,
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
// mainAdminBucket is the handle for "mc admin bucket" command.
|
||||
func mainAdminBucket(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminBucketSubcommands)
|
||||
return nil
|
||||
// Sub-commands like "quota", "remote" have their own main.
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
// 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 (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminClusterBucketExportCmd = cli.Command{
|
||||
Name: "export",
|
||||
Usage: "backup bucket metadata to a zip file",
|
||||
Action: mainClusterBucketExport,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} [FLAGS] TARGET/[BUCKET]
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Download all bucket metadata for a bucket into zip file.
|
||||
{{.Prompt}} {{.HelpName}} myminio/bucket
|
||||
|
||||
2. Download metadata of all buckets in cluster into zip file.
|
||||
{{.Prompt}} {{.HelpName}} myminio
|
||||
`,
|
||||
}
|
||||
|
||||
func checkBucketExportSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "export", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainClusterBucketExport - metadata export command
|
||||
func mainClusterBucketExport(ctx *cli.Context) error {
|
||||
// Check for command syntax
|
||||
checkBucketExportSyntax(ctx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
console.SetColor("File", color.New(color.FgWhite, color.Bold))
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
if err != nil {
|
||||
fatalIf(err.Trace(aliasedURL), "Unable to initialize admin client.")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Compute bucket and object from the aliased URL
|
||||
aliasedURL = filepath.ToSlash(aliasedURL)
|
||||
aliasedURL = filepath.Clean(aliasedURL)
|
||||
_, bucket := url2Alias(aliasedURL)
|
||||
|
||||
r, ierr := client.ExportBucketMetadata(context.Background(), bucket)
|
||||
fatalIf(probe.NewError(ierr).Trace(aliasedURL), "Unable to export bucket metadata.")
|
||||
|
||||
if bucket == "" {
|
||||
bucket = "allbuckets"
|
||||
}
|
||||
// Create bucket metadata zip file
|
||||
tmpFile, e := ioutil.TempFile("", fmt.Sprintf("%s-metadata-", bucket))
|
||||
fatalIf(probe.NewError(e), "Unable to download file data.")
|
||||
|
||||
ext := "zip"
|
||||
// Copy zip content to target download file
|
||||
_, e = io.Copy(tmpFile, r)
|
||||
fatalIf(probe.NewError(e), "Unable to download bucket metadata.")
|
||||
|
||||
// Close everything
|
||||
r.Close()
|
||||
tmpFile.Close()
|
||||
|
||||
// We use 4 bytes of the 32 bytes to identify the file.
|
||||
downloadPath := fmt.Sprintf("%s-metadata.%s", bucket, ext)
|
||||
fi, e := os.Stat(downloadPath)
|
||||
if e == nil && !fi.IsDir() {
|
||||
e = moveFile(downloadPath, downloadPath+"."+time.Now().Format(dateTimeFormatFilename))
|
||||
fatalIf(probe.NewError(e), "Unable to create a backup of "+downloadPath)
|
||||
} else {
|
||||
if !os.IsNotExist(e) {
|
||||
fatal(probe.NewError(e), "Unable to download file data")
|
||||
}
|
||||
}
|
||||
|
||||
fatalIf(probe.NewError(moveFile(tmpFile.Name(), downloadPath)), "Unable to rename downloaded data, file exists at %s", tmpFile.Name())
|
||||
|
||||
if !globalJSON {
|
||||
console.Infof("Bucket metadata successfully downloaded as %s\n", downloadPath)
|
||||
return nil
|
||||
}
|
||||
|
||||
v := struct {
|
||||
File string `json:"file"`
|
||||
Key string `json:"key,omitempty"`
|
||||
}{
|
||||
File: downloadPath,
|
||||
}
|
||||
b, e := json.Marshal(v)
|
||||
fatalIf(probe.NewError(e), "Unable to serialize data")
|
||||
console.Println(string(b))
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
// 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 (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/klauspost/compress/zip"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminClusterBucketImportCmd = cli.Command{
|
||||
Name: "import",
|
||||
Usage: "restore bucket metadata from a zip file",
|
||||
Action: mainClusterBucketImport,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} [FLAGS] TARGET/[BUCKET] /path/to/backups/bucket-metadata.zip
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Set bucket metadata for 'mybucket' from previously exported metadata zip file.
|
||||
{{.Prompt}} {{.HelpName}} myminio/mybucket /backups/mybucket-metadata.zip
|
||||
|
||||
2. Set bucket metadata for all buckets from previously exported metadata zip file.
|
||||
{{.Prompt}} {{.HelpName}} myminio /backups/cluster-bucket-metadata.zip
|
||||
`,
|
||||
}
|
||||
|
||||
func checkBucketImportSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "import", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainClusterBucketImport - bucket metadata import command
|
||||
func mainClusterBucketImport(ctx *cli.Context) error {
|
||||
// Check for command syntax
|
||||
checkBucketImportSyntax(ctx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
var r io.Reader
|
||||
var sz int64
|
||||
f, e := os.Open(args.Get(1))
|
||||
if e != nil {
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get bucket metadata")
|
||||
}
|
||||
if st, e := f.Stat(); e == nil {
|
||||
sz = st.Size()
|
||||
}
|
||||
defer f.Close()
|
||||
r = f
|
||||
|
||||
_, e = zip.NewReader(r.(io.ReaderAt), sz)
|
||||
fatalIf(probe.NewError(e).Trace(args...), fmt.Sprintf("Unable to read zip file %s", args.Get(1)))
|
||||
|
||||
f, e = os.Open(args.Get(1))
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get bucket metadata")
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
if err != nil {
|
||||
fatalIf(err.Trace(aliasedURL), "Unable to initialize admin client.")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Compute bucket and object from the aliased URL
|
||||
aliasedURL = filepath.ToSlash(aliasedURL)
|
||||
aliasedURL = filepath.Clean(aliasedURL)
|
||||
_, bucket := url2Alias(aliasedURL)
|
||||
|
||||
ierr := client.ImportBucketMetadata(context.Background(), bucket, f)
|
||||
fatalIf(probe.NewError(ierr).Trace(aliasedURL), "Unable to import bucket metadata.")
|
||||
if !globalJSON {
|
||||
console.Infof("Bucket metadata imported to %s from %s\n", bucket, args.Get(1))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
// 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 adminClusterBucketSubcommands = []cli.Command{
|
||||
adminClusterBucketImportCmd,
|
||||
adminClusterBucketExportCmd,
|
||||
}
|
||||
|
||||
var adminClusterBucketCmd = cli.Command{
|
||||
Name: "bucket",
|
||||
Usage: "manage bucket metadata on MinIO cluster",
|
||||
Action: mainAdminClusterBucket,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: adminClusterBucketSubcommands,
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
// mainAdminClusterBucket is the handle for "mc admin cluster bucket" command.
|
||||
func mainAdminClusterBucket(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminClusterBucketSubcommands)
|
||||
return nil
|
||||
// Sub-commands like "export", "import" have their own main.
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// 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 adminClusterSubcommands = []cli.Command{
|
||||
adminClusterBucketCmd,
|
||||
}
|
||||
|
||||
var adminClusterCmd = cli.Command{
|
||||
Name: "cluster",
|
||||
Usage: "manage MinIO cluster metadata",
|
||||
Action: mainAdminCluster,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: adminClusterSubcommands,
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
// mainAdminCluster is the handle for "mc admin cluster" command.
|
||||
func mainAdminCluster(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminClusterSubcommands)
|
||||
return nil
|
||||
// Sub-commands like "bucket", "iam" have their own main.
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
// Copyright (c) 2015-2021 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"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
var adminConfigExportCmd = cli.Command{
|
||||
Name: "export",
|
||||
Usage: "export all config keys to STDOUT",
|
||||
Before: setGlobalsFromContext,
|
||||
Action: mainAdminConfigExport,
|
||||
OnUsageError: onUsageError,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Export the current config from MinIO server
|
||||
{{.Prompt}} {{.HelpName}} play/ > config.txt
|
||||
`,
|
||||
}
|
||||
|
||||
// configExportMessage container to hold locks information.
|
||||
type configExportMessage struct {
|
||||
Status string `json:"status"`
|
||||
Value []byte `json:"value"`
|
||||
}
|
||||
|
||||
// String colorized service status message.
|
||||
func (u configExportMessage) String() string {
|
||||
return string(u.Value)
|
||||
}
|
||||
|
||||
// JSON jsonified service status Message message.
|
||||
func (u configExportMessage) JSON() string {
|
||||
u.Status = "success"
|
||||
statusJSONBytes, e := json.MarshalIndent(u, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(statusJSONBytes)
|
||||
}
|
||||
|
||||
// checkAdminConfigExportSyntax - validate all the passed arguments
|
||||
func checkAdminConfigExportSyntax(ctx *cli.Context) {
|
||||
if !ctx.Args().Present() || len(ctx.Args()) > 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "export", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func mainAdminConfigExport(ctx *cli.Context) error {
|
||||
checkAdminConfigExportSyntax(ctx)
|
||||
|
||||
// Export the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
// Call get config API
|
||||
buf, e := client.GetConfig(globalContext)
|
||||
fatalIf(probe.NewError(e), "Unable to get server config")
|
||||
|
||||
// Print
|
||||
printMsg(configExportMessage{
|
||||
Value: buf,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"strings"
|
||||
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
var adminConfigGetCmd = cli.Command{
|
||||
Name: "get",
|
||||
Usage: "interactively retrieve a config key parameters",
|
||||
Before: setGlobalsFromContext,
|
||||
Action: mainAdminConfigGet,
|
||||
OnUsageError: onUsageError,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Get the current region setting on MinIO server.
|
||||
{{.Prompt}} {{.HelpName}} play/ region
|
||||
region name=us-east-1
|
||||
|
||||
2. Get the current notification settings for Webhook target on MinIO server
|
||||
{{.Prompt}} {{.HelpName}} myminio/ notify_webhook
|
||||
notify_webhook endpoint="http://localhost:8080" auth_token= queue_limit=10000 queue_dir="/home/events"
|
||||
|
||||
3. Get the current compression settings on MinIO server
|
||||
{{.Prompt}} {{.HelpName}} myminio/ compression
|
||||
compression extensions=".txt,.csv" mime_types="text/*"
|
||||
`,
|
||||
}
|
||||
|
||||
// configGetMessage container to hold locks information.
|
||||
type configGetMessage struct {
|
||||
Status string `json:"status"`
|
||||
Value *madmin.Target `json:"value"`
|
||||
value []byte
|
||||
}
|
||||
|
||||
// String colorized service status message.
|
||||
func (u configGetMessage) String() string {
|
||||
return string(u.value)
|
||||
}
|
||||
|
||||
// JSON jsonified service status Message message.
|
||||
func (u configGetMessage) JSON() string {
|
||||
u.Status = "success"
|
||||
statusJSONBytes, e := json.MarshalIndent(u, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(statusJSONBytes)
|
||||
}
|
||||
|
||||
// checkAdminConfigGetSyntax - validate all the passed arguments
|
||||
func checkAdminConfigGetSyntax(ctx *cli.Context) {
|
||||
if !ctx.Args().Present() || len(ctx.Args()) < 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "get", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func mainAdminConfigGet(ctx *cli.Context) error {
|
||||
checkAdminConfigGetSyntax(ctx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
if len(ctx.Args()) == 1 {
|
||||
// Call get config API
|
||||
hr, e := client.HelpConfigKV(globalContext, "", "", false)
|
||||
fatalIf(probe.NewError(e), "Unable to get help for the sub-system")
|
||||
|
||||
// Print
|
||||
printMsg(configHelpMessage{
|
||||
Value: hr,
|
||||
envOnly: false,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
subSys := strings.Join(args.Tail(), " ")
|
||||
|
||||
// Call get config API
|
||||
buf, e := client.GetConfigKV(globalContext, subSys)
|
||||
fatalIf(probe.NewError(e), "Unable to get server '%s' config", args.Tail())
|
||||
|
||||
if globalJSON {
|
||||
hr, e := client.HelpConfigKV(globalContext, subSys, "", false)
|
||||
fatalIf(probe.NewError(e), "Unable to get help for "+subSys+" the sub-system")
|
||||
|
||||
tgt, e := madmin.ParseSubSysTarget(buf, hr)
|
||||
fatalIf(probe.NewError(e), "Unable to parse sub-system target "+subSys)
|
||||
|
||||
printMsg(configGetMessage{
|
||||
Value: tgt,
|
||||
value: buf,
|
||||
})
|
||||
} else {
|
||||
// Print
|
||||
printMsg(configGetMessage{
|
||||
value: buf,
|
||||
})
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
"text/template"
|
||||
|
||||
"github.com/fatih/color"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
)
|
||||
|
||||
// HelpTmpl template used by all sub-systems
|
||||
const HelpTmpl = `{{if ne .SubSys ""}}{{colorBlueBold "KEY:"}}
|
||||
{{if .MultipleTargets}}{{colorYellowBold .SubSys}}[:name]{{"\t"}}{{else}}{{colorYellowBold .SubSys}}{{"\t"}}{{end}}{{.Description}}
|
||||
|
||||
{{colorBlueBold "ARGS:"}}{{range .KeysHelp}}
|
||||
{{if .Optional}}{{colorYellowBold .Key}}{{else}}{{colorRedBold .Key}}*{{end}}{{"\t"}}({{.Type}}){{"\t"}}{{.Description}}{{end}}{{else}}{{colorBlueBold "KEYS:"}}{{range .KeysHelp}}
|
||||
{{colorGreenBold .Key}}{{"\t"}}{{.Description}}{{end}}{{end}}`
|
||||
|
||||
var funcMap = template.FuncMap{
|
||||
"colorBlueBold": color.New(color.FgBlue, color.Bold).SprintfFunc(),
|
||||
"colorYellowBold": color.New(color.FgYellow, color.Bold).SprintfFunc(),
|
||||
"colorCyanBold": color.New(color.FgCyan, color.Bold).SprintFunc(),
|
||||
"colorRedBold": color.New(color.FgRed, color.Bold).SprintfFunc(),
|
||||
"colorGreenBold": color.New(color.FgGreen, color.Bold).SprintfFunc(),
|
||||
}
|
||||
|
||||
// HelpTemplate - captures config help template
|
||||
var HelpTemplate = template.Must(template.New("config-help").Funcs(funcMap).Parse(HelpTmpl))
|
||||
|
||||
// HelpEnvTemplate - captures config help template
|
||||
var HelpEnvTemplate = template.Must(template.New("config-help-env").Funcs(funcMap).Parse(HelpTmpl))
|
||||
|
||||
// configHelpMessage container to hold locks information.
|
||||
type configHelpMessage struct {
|
||||
Status string `json:"status"`
|
||||
Value madmin.Help `json:"help"`
|
||||
envOnly bool
|
||||
}
|
||||
|
||||
// String colorized service status message.
|
||||
func (u configHelpMessage) String() string {
|
||||
var s strings.Builder
|
||||
w := tabwriter.NewWriter(&s, 1, 8, 2, ' ', 0)
|
||||
var e error
|
||||
if !u.envOnly {
|
||||
e = HelpTemplate.Execute(w, u.Value)
|
||||
} else {
|
||||
e = HelpEnvTemplate.Execute(w, u.Value)
|
||||
}
|
||||
fatalIf(probe.NewError(e), "Unable to initialize template writer")
|
||||
|
||||
w.Flush()
|
||||
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// JSON jsonified service status Message message.
|
||||
func (u configHelpMessage) JSON() string {
|
||||
u.Status = "success"
|
||||
statusJSONBytes, e := json.MarshalIndent(u, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(statusJSONBytes)
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
"text/template"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var historyListFlags = []cli.Flag{
|
||||
cli.IntFlag{
|
||||
Name: "count, n",
|
||||
Usage: "list only last 'n' entries",
|
||||
Value: 10,
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "clear, c",
|
||||
Usage: "clear all history",
|
||||
},
|
||||
}
|
||||
|
||||
var adminConfigHistoryCmd = cli.Command{
|
||||
Name: "history",
|
||||
Usage: "show all historic configuration changes",
|
||||
Before: setGlobalsFromContext,
|
||||
Action: mainAdminConfigHistory,
|
||||
OnUsageError: onUsageError,
|
||||
Flags: append(append([]cli.Flag{}, globalFlags...), historyListFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. List all history entries sorted by time.
|
||||
{{.Prompt}} {{.HelpName}} play/
|
||||
`,
|
||||
}
|
||||
|
||||
// History template used by all sub-systems
|
||||
const History = `{{range .}}{{colorYellowBold "RestoreId:"}} {{colorYellowBold .RestoreID}}
|
||||
Date: {{.CreateTime}}
|
||||
|
||||
{{.Targets}}
|
||||
|
||||
{{end}}`
|
||||
|
||||
// HistoryTemplate - captures history list template
|
||||
var HistoryTemplate = template.Must(template.New("history-list").Funcs(funcMap).Parse(History))
|
||||
|
||||
type historyEntry struct {
|
||||
RestoreID string `json:"restoreId"`
|
||||
CreateTime string `json:"createTime"`
|
||||
Targets string `json:"targets"`
|
||||
}
|
||||
|
||||
// configHistoryMessage container to hold locks information.
|
||||
type configHistoryMessage struct {
|
||||
Status string `json:"status"`
|
||||
Entries []historyEntry `json:"entries"`
|
||||
}
|
||||
|
||||
// String colorized service status message.
|
||||
func (u configHistoryMessage) String() string {
|
||||
var s strings.Builder
|
||||
w := tabwriter.NewWriter(&s, 1, 8, 2, ' ', 0)
|
||||
e := HistoryTemplate.Execute(w, u.Entries)
|
||||
fatalIf(probe.NewError(e), "Unable to initialize template writer")
|
||||
|
||||
w.Flush()
|
||||
return s.String()
|
||||
}
|
||||
|
||||
// JSON jsonified service status Message message.
|
||||
func (u configHistoryMessage) JSON() string {
|
||||
u.Status = "success"
|
||||
statusJSONBytes, e := json.MarshalIndent(u, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(statusJSONBytes)
|
||||
}
|
||||
|
||||
// checkAdminConfigHistorySyntax - validate all the passed arguments
|
||||
func checkAdminConfigHistorySyntax(ctx *cli.Context) {
|
||||
if !ctx.Args().Present() || len(ctx.Args()) > 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "history", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func mainAdminConfigHistory(ctx *cli.Context) error {
|
||||
checkAdminConfigHistorySyntax(ctx)
|
||||
|
||||
console.SetColor("ConfigHistoryMessageRestoreID", color.New(color.Bold))
|
||||
console.SetColor("ConfigHistoryMessageTime", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
if ctx.IsSet("clear") {
|
||||
fatalIf(probe.NewError(client.ClearConfigHistoryKV(globalContext, "all")), "Unable to clear server configuration.")
|
||||
|
||||
// Print
|
||||
printMsg(configHistoryMessage{})
|
||||
return nil
|
||||
}
|
||||
|
||||
chEntries, e := client.ListConfigHistoryKV(globalContext, ctx.Int("count"))
|
||||
fatalIf(probe.NewError(e), "Unable to list server history configuration.")
|
||||
|
||||
hentries := make([]historyEntry, len(chEntries))
|
||||
for i, chEntry := range chEntries {
|
||||
hentries[i] = historyEntry{
|
||||
RestoreID: chEntry.RestoreID,
|
||||
CreateTime: chEntry.CreateTimeFormatted(),
|
||||
}
|
||||
hentries[i].Targets = chEntry.Data
|
||||
}
|
||||
|
||||
// Print
|
||||
printMsg(configHistoryMessage{
|
||||
Entries: hentries,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminConfigImportCmd = cli.Command{
|
||||
Name: "import",
|
||||
Usage: "import multiple config keys from STDIN",
|
||||
Before: setGlobalsFromContext,
|
||||
Action: mainAdminConfigImport,
|
||||
OnUsageError: onUsageError,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Import the new local config and apply to the MinIO server
|
||||
{{.Prompt}} {{.HelpName}} play/ < config.txt
|
||||
`,
|
||||
}
|
||||
|
||||
// configImportMessage container to hold locks information.
|
||||
type configImportMessage struct {
|
||||
Status string `json:"status"`
|
||||
targetAlias string
|
||||
}
|
||||
|
||||
// String colorized service status message.
|
||||
func (u configImportMessage) String() (msg string) {
|
||||
msg += console.Colorize("SetConfigSuccess",
|
||||
"Setting new key has been successful.\n")
|
||||
suggestion := fmt.Sprintf("mc admin service restart %s", u.targetAlias)
|
||||
msg += console.Colorize("SetConfigSuccess",
|
||||
fmt.Sprintf("Please restart your server with `%s`.\n", suggestion))
|
||||
return msg
|
||||
}
|
||||
|
||||
// JSON jsonified service status Message message.
|
||||
func (u configImportMessage) JSON() string {
|
||||
u.Status = "success"
|
||||
statusJSONBytes, e := json.MarshalIndent(u, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(statusJSONBytes)
|
||||
}
|
||||
|
||||
// checkAdminConfigImportSyntax - validate all the passed arguments
|
||||
func checkAdminConfigImportSyntax(ctx *cli.Context) {
|
||||
if !ctx.Args().Present() || len(ctx.Args()) > 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "import", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func mainAdminConfigImport(ctx *cli.Context) error {
|
||||
checkAdminConfigImportSyntax(ctx)
|
||||
|
||||
// Set color preference of command outputs
|
||||
console.SetColor("SetConfigSuccess", color.New(color.FgGreen, color.Bold))
|
||||
|
||||
// Import the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
// Call set config API
|
||||
fatalIf(probe.NewError(client.SetConfig(globalContext, os.Stdin)), "Unable to set server config")
|
||||
|
||||
// Print
|
||||
printMsg(configImportMessage{
|
||||
targetAlias: aliasedURL,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminConfigEnvFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "env",
|
||||
Usage: "list all the env only help",
|
||||
},
|
||||
}
|
||||
|
||||
var adminConfigResetCmd = cli.Command{
|
||||
Name: "reset",
|
||||
Usage: "interactively reset a config key parameters",
|
||||
Before: setGlobalsFromContext,
|
||||
Action: mainAdminConfigReset,
|
||||
OnUsageError: onUsageError,
|
||||
Flags: append(adminConfigEnvFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Reset MQTT notifcation target 'name1' settings to default values.
|
||||
{{.Prompt}} {{.HelpName}} myminio/ notify_mqtt:name1
|
||||
`,
|
||||
}
|
||||
|
||||
// configResetMessage container to hold locks information.
|
||||
type configResetMessage struct {
|
||||
Status string `json:"status"`
|
||||
targetAlias string
|
||||
restart bool
|
||||
}
|
||||
|
||||
// String colorized service status message.
|
||||
func (u configResetMessage) String() (msg string) {
|
||||
msg += console.Colorize("ResetConfigSuccess",
|
||||
"Key is successfully reset.\n")
|
||||
suggestion := fmt.Sprintf("mc admin service restart %s", u.targetAlias)
|
||||
if u.restart {
|
||||
msg += console.Colorize("ResetConfigSuccess",
|
||||
fmt.Sprintf("Please restart your server with `%s`.\n", suggestion))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// JSON jsonified service status message.
|
||||
func (u configResetMessage) JSON() string {
|
||||
u.Status = "success"
|
||||
statusJSONBytes, e := json.MarshalIndent(u, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(statusJSONBytes)
|
||||
}
|
||||
|
||||
// checkAdminConfigResetSyntax - validate all the passed arguments
|
||||
func checkAdminConfigResetSyntax(ctx *cli.Context) {
|
||||
if !ctx.Args().Present() {
|
||||
cli.ShowCommandHelpAndExit(ctx, "reset", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// main config set function
|
||||
func mainAdminConfigReset(ctx *cli.Context) error {
|
||||
// Check command arguments
|
||||
checkAdminConfigResetSyntax(ctx)
|
||||
|
||||
// Reset color preference of command outputs
|
||||
console.SetColor("ResetConfigSuccess", color.New(color.FgGreen, color.Bold))
|
||||
console.SetColor("ResetConfigFailure", color.New(color.FgRed, color.Bold))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
if len(ctx.Args()) == 1 {
|
||||
// Call get config API
|
||||
hr, e := client.HelpConfigKV(globalContext, "", "", ctx.IsSet("env"))
|
||||
fatalIf(probe.NewError(e), "Unable to get help for the sub-system")
|
||||
|
||||
// Print
|
||||
printMsg(configHelpMessage{
|
||||
Value: hr,
|
||||
envOnly: ctx.IsSet("env"),
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Call reset config API
|
||||
input := strings.Join(args.Tail(), " ")
|
||||
restart, e := client.DelConfigKV(globalContext, input)
|
||||
fatalIf(probe.NewError(e), "Unable to reset '%s' on the server", input)
|
||||
|
||||
// Print set config result
|
||||
printMsg(configResetMessage{
|
||||
targetAlias: aliasedURL,
|
||||
restart: restart,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminConfigRestoreCmd = cli.Command{
|
||||
Name: "restore",
|
||||
Usage: "rollback back changes to a specific config history",
|
||||
Before: setGlobalsFromContext,
|
||||
Action: mainAdminConfigRestore,
|
||||
OnUsageError: onUsageError,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET RESTOREID
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Restore 'restore-id' history key value on MinIO server.
|
||||
{{.Prompt}} {{.HelpName}} play/ <restore-id>
|
||||
`,
|
||||
}
|
||||
|
||||
// configRestoreMessage container to hold locks information.
|
||||
type configRestoreMessage struct {
|
||||
Status string `json:"status"`
|
||||
RestoreID string `json:"restoreID"`
|
||||
targetAlias string
|
||||
}
|
||||
|
||||
// String colorized service status message.
|
||||
func (u configRestoreMessage) String() (msg string) {
|
||||
suggestion := fmt.Sprintf("mc admin service restart %s", u.targetAlias)
|
||||
msg += console.Colorize("ConfigRestoreMessage",
|
||||
fmt.Sprintf("Please restart your server with `%s`.\n", suggestion))
|
||||
msg += console.Colorize("ConfigRestoreMessage", "Restored "+u.RestoreID+" kv successfully.")
|
||||
return msg
|
||||
}
|
||||
|
||||
// JSON jsonified service status Message message.
|
||||
func (u configRestoreMessage) JSON() string {
|
||||
u.Status = "success"
|
||||
statusJSONBytes, e := json.MarshalIndent(u, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(statusJSONBytes)
|
||||
}
|
||||
|
||||
// checkAdminConfigRestoreSyntax - validate all the passed arguments
|
||||
func checkAdminConfigRestoreSyntax(ctx *cli.Context) {
|
||||
if !ctx.Args().Present() || len(ctx.Args()) > 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "restore", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func mainAdminConfigRestore(ctx *cli.Context) error {
|
||||
checkAdminConfigRestoreSyntax(ctx)
|
||||
|
||||
console.SetColor("ConfigRestoreMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
// Call get config API
|
||||
fatalIf(probe.NewError(client.RestoreConfigHistoryKV(globalContext, args.Get(1))), "Unable to restore server configuration.")
|
||||
|
||||
// Print
|
||||
printMsg(configRestoreMessage{
|
||||
RestoreID: args.Get(1),
|
||||
targetAlias: aliasedURL,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminConfigSetCmd = cli.Command{
|
||||
Name: "set",
|
||||
Usage: "interactively set a config key parameters",
|
||||
Before: setGlobalsFromContext,
|
||||
Action: mainAdminConfigSet,
|
||||
OnUsageError: onUsageError,
|
||||
Flags: append(adminConfigEnvFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Enable webhook notification target for MinIO server.
|
||||
{{.Prompt}} {{.HelpName}} myminio/ notify_webhook endpoint="http://localhost:8080/minio/events"
|
||||
|
||||
2. Change region name for the MinIO server to 'us-west-1'.
|
||||
{{.Prompt}} {{.HelpName}} myminio/ region name=us-west-1
|
||||
|
||||
3. Change healing settings on a distributed MinIO server setup.
|
||||
{{.Prompt}} {{.HelpName}} mydist/ heal max_delay=300ms max_io=50
|
||||
`,
|
||||
}
|
||||
|
||||
// configSetMessage container to hold locks information.
|
||||
type configSetMessage struct {
|
||||
Status string `json:"status"`
|
||||
targetAlias string
|
||||
restart bool
|
||||
}
|
||||
|
||||
// String colorized service status message.
|
||||
func (u configSetMessage) String() (msg string) {
|
||||
msg += console.Colorize("SetConfigSuccess",
|
||||
"Successfully applied new settings.")
|
||||
if u.restart {
|
||||
suggestion := color.RedString("mc admin service restart %s", u.targetAlias)
|
||||
msg += console.Colorize("SetConfigSuccess",
|
||||
fmt.Sprintf("\nPlease restart your server '%s'.", suggestion))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// JSON jsonified service status message.
|
||||
func (u configSetMessage) JSON() string {
|
||||
u.Status = "success"
|
||||
statusJSONBytes, e := json.MarshalIndent(u, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(statusJSONBytes)
|
||||
}
|
||||
|
||||
// checkAdminConfigSetSyntax - validate all the passed arguments
|
||||
func checkAdminConfigSetSyntax(ctx *cli.Context) {
|
||||
if !ctx.Args().Present() && len(ctx.Args()) < 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "set", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// main config set function
|
||||
func mainAdminConfigSet(ctx *cli.Context) error {
|
||||
// Check command arguments
|
||||
checkAdminConfigSetSyntax(ctx)
|
||||
|
||||
// Set color preference of command outputs
|
||||
console.SetColor("SetConfigSuccess", color.New(color.FgGreen, color.Bold))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
input := strings.Join(args.Tail(), " ")
|
||||
|
||||
if !strings.Contains(input, madmin.KvSeparator) {
|
||||
// Call get config API
|
||||
hr, e := client.HelpConfigKV(globalContext, args.Get(1), args.Get(2), ctx.IsSet("env"))
|
||||
fatalIf(probe.NewError(e), "Unable to get help for the sub-system")
|
||||
|
||||
// Print
|
||||
printMsg(configHelpMessage{
|
||||
Value: hr,
|
||||
envOnly: ctx.IsSet("env"),
|
||||
})
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
// Call set config API
|
||||
restart, e := client.SetConfigKV(globalContext, input)
|
||||
fatalIf(probe.NewError(e), "Unable to set '%s' to server", input)
|
||||
|
||||
// Print set config result
|
||||
printMsg(configSetMessage{
|
||||
targetAlias: aliasedURL,
|
||||
restart: restart,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2015-2021 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 adminConfigSubcommands = []cli.Command{
|
||||
adminConfigGetCmd,
|
||||
adminConfigSetCmd,
|
||||
adminConfigResetCmd,
|
||||
adminConfigHistoryCmd,
|
||||
adminConfigRestoreCmd,
|
||||
adminConfigExportCmd,
|
||||
adminConfigImportCmd,
|
||||
}
|
||||
|
||||
var adminConfigCmd = cli.Command{
|
||||
Name: "config",
|
||||
Usage: "manage MinIO server configuration",
|
||||
Action: mainAdminConfig,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: adminConfigSubcommands,
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
// mainAdminConfig is the handle for "mc admin config" command.
|
||||
func mainAdminConfig(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminConfigSubcommands)
|
||||
return nil
|
||||
// Sub-commands like "get", "set" have their own main.
|
||||
}
|
||||
@@ -0,0 +1,219 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
const logTimeFormat string = "15:04:05 MST 01/02/2006"
|
||||
|
||||
var adminConsoleFlags = []cli.Flag{
|
||||
cli.IntFlag{
|
||||
Name: "limit, l",
|
||||
Usage: "show last n log entries",
|
||||
Value: 10,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "type, t",
|
||||
Usage: "list error logs by type. Valid options are '[minio, application, all]'",
|
||||
Value: "all",
|
||||
},
|
||||
}
|
||||
|
||||
var adminConsoleCmd = cli.Command{
|
||||
Name: "console",
|
||||
Usage: "show console logs for MinIO server",
|
||||
Action: mainAdminConsole,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(adminConsoleFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} [FLAGS] TARGET [NODENAME]
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Show console logs for a MinIO server with alias 'play'
|
||||
{{.Prompt}} {{.HelpName}} play
|
||||
|
||||
2. Show last 5 log entries for node 'node1' on MinIO server with alias 'myminio'
|
||||
{{.Prompt}} {{.HelpName}} --limit 5 myminio node1
|
||||
|
||||
3. Show application error logs on MinIO server with alias 'play'
|
||||
{{.Prompt}} {{.HelpName}} --type application play
|
||||
`,
|
||||
}
|
||||
|
||||
func checkAdminLogSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) == 0 || len(ctx.Args()) > 3 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "console", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// Extend madmin.LogInfo to add String() and JSON() methods
|
||||
type logMessage struct {
|
||||
Status string `json:"status"`
|
||||
madmin.LogInfo
|
||||
}
|
||||
|
||||
// JSON - jsonify loginfo
|
||||
func (l logMessage) JSON() string {
|
||||
l.Status = "success"
|
||||
logJSON, err := json.MarshalIndent(&l, "", " ")
|
||||
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 {
|
||||
return lt
|
||||
}
|
||||
return tm.Format(logTimeFormat)
|
||||
}
|
||||
|
||||
// String - return colorized loginfo as string.
|
||||
func (l logMessage) String() string {
|
||||
var hostStr string
|
||||
b := &strings.Builder{}
|
||||
if l.NodeName != "" {
|
||||
hostStr = fmt.Sprintf("%s ", colorizedNodeName(l.NodeName))
|
||||
}
|
||||
log := l.LogInfo
|
||||
if log.ConsoleMsg != "" {
|
||||
if strings.HasPrefix(log.ConsoleMsg, "\n") {
|
||||
fmt.Fprintf(b, "%s\n", hostStr)
|
||||
log.ConsoleMsg = strings.TrimPrefix(log.ConsoleMsg, "\n")
|
||||
}
|
||||
fmt.Fprintf(b, "%s %s", hostStr, log.ConsoleMsg)
|
||||
return b.String()
|
||||
}
|
||||
if l.API != nil {
|
||||
apiString := "API: " + l.API.Name + "("
|
||||
if l.API.Args != nil && l.API.Args.Bucket != "" {
|
||||
apiString = apiString + "bucket=" + l.API.Args.Bucket
|
||||
}
|
||||
if l.API.Args != nil && l.API.Args.Object != "" {
|
||||
apiString = apiString + ", object=" + l.API.Args.Object
|
||||
}
|
||||
apiString += ")"
|
||||
fmt.Fprintf(b, "\n%s %s", hostStr, console.Colorize("API", apiString))
|
||||
}
|
||||
if l.Time != "" {
|
||||
fmt.Fprintf(b, "\n%s Time: %s", hostStr, getLogTime(l.Time))
|
||||
}
|
||||
if l.DeploymentID != "" {
|
||||
fmt.Fprintf(b, "\n%s DeploymentID: %s", hostStr, l.DeploymentID)
|
||||
}
|
||||
if l.RequestID != "" {
|
||||
fmt.Fprintf(b, "\n%s RequestID: %s", hostStr, l.RequestID)
|
||||
}
|
||||
if l.RemoteHost != "" {
|
||||
fmt.Fprintf(b, "\n%s RemoteHost: %s", hostStr, l.RemoteHost)
|
||||
}
|
||||
if l.UserAgent != "" {
|
||||
fmt.Fprintf(b, "\n%s UserAgent: %s", hostStr, l.UserAgent)
|
||||
}
|
||||
if l.Trace != nil {
|
||||
if l.Trace.Message != "" {
|
||||
fmt.Fprintf(b, "\n%s Error: %s", hostStr, console.Colorize("LogMessage", l.Trace.Message))
|
||||
}
|
||||
if l.Trace.Variables != nil {
|
||||
for key, value := range l.Trace.Variables {
|
||||
if value != "" {
|
||||
fmt.Fprintf(b, "\n%s %s=%s", hostStr, key, value)
|
||||
}
|
||||
}
|
||||
}
|
||||
if l.Trace.Source != nil {
|
||||
traceLength := len(l.Trace.Source)
|
||||
for i, element := range l.Trace.Source {
|
||||
fmt.Fprintf(b, "\n%s %8v: %s", hostStr, traceLength-i, element)
|
||||
}
|
||||
}
|
||||
}
|
||||
logMsg := strings.TrimPrefix(b.String(), "\n")
|
||||
return fmt.Sprintf("%s\n", logMsg)
|
||||
}
|
||||
|
||||
// mainAdminConsole - the entry function of console command
|
||||
func mainAdminConsole(ctx *cli.Context) error {
|
||||
// Check for command syntax
|
||||
checkAdminLogSyntax(ctx)
|
||||
console.SetColor("LogMessage", color.New(color.Bold, color.FgRed))
|
||||
console.SetColor("Api", color.New(color.Bold, color.FgWhite))
|
||||
for _, c := range colors {
|
||||
console.SetColor(fmt.Sprintf("Node%d", c), color.New(c))
|
||||
}
|
||||
aliasedURL := ctx.Args().Get(0)
|
||||
var node string
|
||||
if len(ctx.Args()) > 1 {
|
||||
node = ctx.Args().Get(1)
|
||||
}
|
||||
var limit int
|
||||
if ctx.IsSet("limit") {
|
||||
limit = ctx.Int("limit")
|
||||
if limit <= 0 {
|
||||
fatalIf(errInvalidArgument().Trace(ctx.Args()...), "please set a proper limit, for example: '--limit 5' to display last 5 logs, omit this flag to display all available logs")
|
||||
}
|
||||
}
|
||||
logType := strings.ToLower(ctx.String("type"))
|
||||
if logType != "minio" && logType != "application" && logType != "all" {
|
||||
fatalIf(errInvalidArgument().Trace(ctx.Args()...), "Invalid value for --type flag. Valid options are [minio, application, all]")
|
||||
}
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
if err != nil {
|
||||
fatalIf(err.Trace(aliasedURL), "Unable to initialize admin client.")
|
||||
return nil
|
||||
}
|
||||
|
||||
ctxt, cancel := context.WithCancel(globalContext)
|
||||
defer cancel()
|
||||
|
||||
// Start listening on all console log activity.
|
||||
logCh := client.GetLogs(ctxt, node, limit, logType)
|
||||
for logInfo := range logCh {
|
||||
if logInfo.Err != nil {
|
||||
fatalIf(probe.NewError(logInfo.Err), "Unable to listen to console logs")
|
||||
}
|
||||
// drop nodeName from output if specified as cli arg
|
||||
if node != "" {
|
||||
logInfo.NodeName = ""
|
||||
}
|
||||
printMsg(logMessage{LogInfo: logInfo})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
// Copyright (c) 2015-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 (
|
||||
"path/filepath"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminDecommissionCancelCmd = cli.Command{
|
||||
Name: "cancel",
|
||||
Usage: "cancel an ongoing decommissioning of a pool",
|
||||
Action: mainAdminDecommissionCancel,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Cancel an ongoing decommissioning of a pool.
|
||||
{{.Prompt}} {{.HelpName}} myminio/ http://server{5...8}/disk{1...4}
|
||||
|
||||
2. List all ongoing decommissioning of pools.
|
||||
{{.Prompt}} {{.HelpName}} myminio/
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminDecommissionCancelSyntax - validate all the passed arguments
|
||||
func checkAdminDecommissionCancelSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) > 2 || len(ctx.Args()) == 0 {
|
||||
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminDecommissionCancel is the handle for "mc admin decommission cancel" command.
|
||||
func mainAdminDecommissionCancel(ctx *cli.Context) error {
|
||||
checkAdminDecommissionCancelSyntax(ctx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
aliasedURL = filepath.Clean(aliasedURL)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
if pool := args.Get(1); pool != "" {
|
||||
e := client.CancelDecommissionPool(globalContext, pool)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to cancel decommissioning, please try again")
|
||||
return nil
|
||||
}
|
||||
|
||||
poolStatuses, e := client.ListPoolsStatus(globalContext)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get status for all pools")
|
||||
|
||||
var newPoolStatuses []madmin.PoolStatus
|
||||
for _, pool := range poolStatuses {
|
||||
if pool.Decommission != nil {
|
||||
if pool.Decommission.StartTime.IsZero() {
|
||||
continue
|
||||
}
|
||||
if pool.Decommission.Complete {
|
||||
continue
|
||||
}
|
||||
}
|
||||
newPoolStatuses = append(newPoolStatuses, pool)
|
||||
}
|
||||
|
||||
dspOrder := []col{colGreen} // Header
|
||||
for i := 0; i < len(newPoolStatuses); i++ {
|
||||
dspOrder = append(dspOrder, colGrey)
|
||||
}
|
||||
var printColors []*color.Color
|
||||
for _, c := range dspOrder {
|
||||
printColors = append(printColors, getPrintCol(c))
|
||||
}
|
||||
|
||||
tbl := console.NewTable(printColors, []bool{false, false, false, false}, 0)
|
||||
|
||||
cellText := make([][]string, len(newPoolStatuses)+1)
|
||||
cellText[0] = []string{
|
||||
"ID",
|
||||
"Pools",
|
||||
"Capacity",
|
||||
"Status",
|
||||
}
|
||||
for idx, pool := range poolStatuses {
|
||||
idx++
|
||||
totalSize := uint64(pool.Decommission.TotalSize)
|
||||
currentSize := uint64(pool.Decommission.CurrentSize)
|
||||
capacity := humanize.IBytes(totalSize-currentSize) + " (used) / " + humanize.IBytes(totalSize) + " (total)"
|
||||
status := ""
|
||||
if pool.Decommission != nil {
|
||||
if pool.Decommission.StartTime.IsZero() {
|
||||
continue
|
||||
}
|
||||
if pool.Decommission.Complete {
|
||||
continue
|
||||
}
|
||||
status = "Draining"
|
||||
}
|
||||
cellText[idx] = []string{
|
||||
humanize.Ordinal(pool.ID + 1),
|
||||
pool.CmdLine,
|
||||
capacity,
|
||||
status,
|
||||
}
|
||||
}
|
||||
return tbl.DisplayTable(cellText)
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"path/filepath"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminDecommissionStartCmd = cli.Command{
|
||||
Name: "start",
|
||||
Usage: "start decommissioning a pool",
|
||||
Action: mainAdminDecommissionStart,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Start decommissioning a pool for removal.
|
||||
{{.Prompt}} {{.HelpName}} myminio/ http://server{5...8}/disk{1...4}
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminDecommissionStartSyntax - validate all the passed arguments
|
||||
func checkAdminDecommissionStartSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// startDecomMessage is container for make bucket success and failure messages.
|
||||
type startDecomMessage struct {
|
||||
Status string `json:"status"`
|
||||
Pool string `json:"pool"`
|
||||
}
|
||||
|
||||
// String colorized construct a string message.
|
||||
func (s startDecomMessage) String() string {
|
||||
return console.Colorize("DecomPool", "Decommission started successfully for `"+s.Pool+"`.")
|
||||
}
|
||||
|
||||
// JSON jsonified decom message.
|
||||
func (s startDecomMessage) JSON() string {
|
||||
startDecomBytes, e := json.MarshalIndent(s, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(startDecomBytes)
|
||||
}
|
||||
|
||||
// mainAdminDecommissionStart is the handle for "mc admin decommission start" command.
|
||||
func mainAdminDecommissionStart(ctx *cli.Context) error {
|
||||
checkAdminDecommissionStartSyntax(ctx)
|
||||
|
||||
// Additional command speific theme customization.
|
||||
console.SetColor("DecomPool", color.New(color.FgGreen, color.Bold))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
aliasedURL = filepath.Clean(aliasedURL)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
e := client.DecommissionPool(globalContext, args.Get(1))
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to start decommission on the specified pool")
|
||||
|
||||
printMsg(startDecomMessage{
|
||||
Status: "success",
|
||||
Pool: args.Get(1),
|
||||
})
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"github.com/dustin/go-humanize"
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminDecommissionStatusCmd = cli.Command{
|
||||
Name: "status",
|
||||
Usage: "show current decommissioning status",
|
||||
Action: mainAdminDecommissionStatus,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Show current decommissioning status.
|
||||
{{.Prompt}} {{.HelpName}} myminio/ http://server{5...8}/disk{1...4}
|
||||
2. List all current decommissioning status of all pools.
|
||||
{{.Prompt}} {{.HelpName}} myminio/
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminDecommissionStatusSyntax - validate all the passed arguments
|
||||
func checkAdminDecommissionStatusSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) > 2 || len(ctx.Args()) == 0 {
|
||||
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminDecommissionStatus is the handle for "mc admin decomission status" command.
|
||||
func mainAdminDecommissionStatus(ctx *cli.Context) error {
|
||||
checkAdminDecommissionStatusSyntax(ctx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
aliasedURL = filepath.Clean(aliasedURL)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
if pool := args.Get(1); pool != "" {
|
||||
poolStatus, e := client.StatusPool(globalContext, pool)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get status per pool")
|
||||
|
||||
if globalJSON {
|
||||
statusJSONBytes, e := json.MarshalIndent(poolStatus, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
console.Println(string(statusJSONBytes))
|
||||
return nil
|
||||
}
|
||||
|
||||
var msg string
|
||||
if poolStatus.Decommission.Complete {
|
||||
msg = color.GreenString(fmt.Sprintf("Decommission of pool %s is complete, you may now remove it from server command line", poolStatus.CmdLine))
|
||||
} else if poolStatus.Decommission.Failed {
|
||||
msg = color.GreenString(fmt.Sprintf("Decommission of pool %s failed, please retry again", poolStatus.CmdLine))
|
||||
} else if poolStatus.Decommission.Canceled {
|
||||
msg = color.GreenString(fmt.Sprintf("Decommission of pool %s was canceled, you may start again", poolStatus.CmdLine))
|
||||
} else if !poolStatus.Decommission.StartTime.IsZero() {
|
||||
usedStart := (poolStatus.Decommission.TotalSize - poolStatus.Decommission.StartSize)
|
||||
usedCurrent := (poolStatus.Decommission.TotalSize - poolStatus.Decommission.CurrentSize)
|
||||
|
||||
if usedStart > usedCurrent {
|
||||
duration := uint64(time.Since(poolStatus.Decommission.StartTime).Seconds())
|
||||
copied := uint64(usedStart - usedCurrent)
|
||||
speed := copied / duration
|
||||
msg = "Decommissioning rate at " + humanize.IBytes(speed) + "/sec " + "[" + humanize.IBytes(
|
||||
uint64(usedCurrent)) + "/" + humanize.IBytes(uint64(poolStatus.Decommission.TotalSize)) + "]"
|
||||
msg += "\nStarted: " + humanize.RelTime(time.Now().UTC(), poolStatus.Decommission.StartTime, "", "ago")
|
||||
} else {
|
||||
msg = "Decommissioning is starting..."
|
||||
}
|
||||
msg = color.GreenString(msg)
|
||||
} else {
|
||||
errorIf(errDummy().Trace(args...), "This pool is currently not scheduled for decomissioning")
|
||||
return nil
|
||||
}
|
||||
fmt.Println(msg)
|
||||
return nil
|
||||
}
|
||||
poolStatuses, e := client.ListPoolsStatus(globalContext)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get status for all pools")
|
||||
|
||||
if globalJSON {
|
||||
statusJSONBytes, e := json.MarshalIndent(poolStatuses, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
console.Println(string(statusJSONBytes))
|
||||
return nil
|
||||
}
|
||||
|
||||
dspOrder := []col{colGreen} // Header
|
||||
for i := 0; i < len(poolStatuses); i++ {
|
||||
dspOrder = append(dspOrder, colGrey)
|
||||
}
|
||||
var printColors []*color.Color
|
||||
for _, c := range dspOrder {
|
||||
printColors = append(printColors, getPrintCol(c))
|
||||
}
|
||||
|
||||
tbl := console.NewTable(printColors, []bool{false, false, false, false}, 0)
|
||||
|
||||
cellText := make([][]string, len(poolStatuses)+1)
|
||||
cellText[0] = []string{
|
||||
"ID",
|
||||
"Pools",
|
||||
"Capacity",
|
||||
"Status",
|
||||
}
|
||||
for idx, pool := range poolStatuses {
|
||||
idx++
|
||||
totalSize := uint64(pool.Decommission.TotalSize)
|
||||
currentSize := uint64(pool.Decommission.CurrentSize)
|
||||
capacity := humanize.IBytes(totalSize-currentSize) + " (used) / " + humanize.IBytes(totalSize) + " (total)"
|
||||
status := "Active"
|
||||
if pool.Decommission != nil {
|
||||
if pool.Decommission.Complete {
|
||||
status = "Complete"
|
||||
} else if pool.Decommission.Failed {
|
||||
status = "Draining(Failed)"
|
||||
} else if pool.Decommission.Canceled {
|
||||
status = "Draining(Canceled)"
|
||||
} else if !pool.Decommission.StartTime.IsZero() {
|
||||
status = "Draining"
|
||||
}
|
||||
}
|
||||
cellText[idx] = []string{
|
||||
humanize.Ordinal(pool.ID + 1),
|
||||
pool.CmdLine,
|
||||
capacity,
|
||||
status,
|
||||
}
|
||||
}
|
||||
return tbl.DisplayTable(cellText)
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2015-2021 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 adminDecommissionSubcommands = []cli.Command{
|
||||
adminDecommissionStartCmd,
|
||||
adminDecommissionStatusCmd,
|
||||
adminDecommissionCancelCmd,
|
||||
}
|
||||
|
||||
var adminDecommissionCmd = cli.Command{
|
||||
Name: "decommission",
|
||||
Aliases: []string{"decom"},
|
||||
Usage: "manage MinIO server pool decommissioning",
|
||||
Action: mainAdminDecommission,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: adminDecommissionSubcommands,
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
// mainAdminDecommission is the handle for "mc admin decommission" command.
|
||||
func mainAdminDecommission(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminDecommissionSubcommands)
|
||||
return nil
|
||||
// Sub-commands like "get", "set" have their own main.
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminGroupAddCmd = cli.Command{
|
||||
Name: "add",
|
||||
Usage: "add users to a new or existing group",
|
||||
Action: mainAdminGroupAdd,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET GROUPNAME MEMBERS...
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Add users 'fivecent' and 'tencent' to the group 'allcents':
|
||||
{{.Prompt}} {{.HelpName}} myminio allcents fivecent tencent
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminGroupAddSyntax - validate all the passed arguments
|
||||
func checkAdminGroupAddSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) < 3 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "add", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// groupMessage container for content message structure
|
||||
type groupMessage struct {
|
||||
op string
|
||||
Status string `json:"status"`
|
||||
GroupName string `json:"groupName,omitempty"`
|
||||
Groups []string `json:"groups,omitempty"`
|
||||
Members []string `json:"members,omitempty"`
|
||||
GroupStatus string `json:"groupStatus,omitempty"`
|
||||
GroupPolicy string `json:"groupPolicy,omitempty"`
|
||||
}
|
||||
|
||||
func (u groupMessage) String() string {
|
||||
switch u.op {
|
||||
case "list":
|
||||
var s []string
|
||||
for _, g := range u.Groups {
|
||||
s = append(s, console.Colorize("GroupMessage", g))
|
||||
}
|
||||
return strings.Join(s, "\n")
|
||||
case "disable":
|
||||
return console.Colorize("GroupMessage", "Disabled group `"+u.GroupName+"` successfully.")
|
||||
case "enable":
|
||||
return console.Colorize("GroupMessage", "Enabled group `"+u.GroupName+"` successfully.")
|
||||
case "add":
|
||||
membersStr := fmt.Sprintf("{%s}", strings.Join(u.Members, ","))
|
||||
return console.Colorize("GroupMessage", "Added members "+membersStr+" to group "+u.GroupName+" successfully.")
|
||||
case "remove":
|
||||
if len(u.Members) > 0 {
|
||||
membersStr := fmt.Sprintf("{%s}", strings.Join(u.Members, ","))
|
||||
return console.Colorize("GroupMessage", "Removed members "+membersStr+" from group "+u.GroupName+" successfully.")
|
||||
}
|
||||
return console.Colorize("GroupMessage", "Removed group "+u.GroupName+" successfully.")
|
||||
case "info":
|
||||
return strings.Join([]string{
|
||||
console.Colorize("GroupMessage", "Group: "+u.GroupName),
|
||||
console.Colorize("GroupMessage", "Status: "+u.GroupStatus),
|
||||
console.Colorize("GroupMessage", "Policy: "+u.GroupPolicy),
|
||||
console.Colorize("GroupMessage", "Members: "+strings.Join(u.Members, ",")),
|
||||
}, "\n")
|
||||
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (u groupMessage) JSON() string {
|
||||
u.Status = "success"
|
||||
jsonMessageBytes, e := json.MarshalIndent(u, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(jsonMessageBytes)
|
||||
}
|
||||
|
||||
// mainAdminGroupAdd is the handle for "mc admin group add" command.
|
||||
func mainAdminGroupAdd(ctx *cli.Context) error {
|
||||
checkAdminGroupAddSyntax(ctx)
|
||||
|
||||
console.SetColor("GroupMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
members := []string{}
|
||||
for i := 2; i < ctx.NArg(); i++ {
|
||||
members = append(members, args.Get(i))
|
||||
}
|
||||
gAddRemove := madmin.GroupAddRemove{
|
||||
Group: args.Get(1),
|
||||
Members: members,
|
||||
IsRemove: false,
|
||||
}
|
||||
fatalIf(probe.NewError(client.UpdateGroupMembers(globalContext, gAddRemove)).Trace(args...), "Unable to add new group")
|
||||
|
||||
printMsg(groupMessage{
|
||||
op: "add",
|
||||
GroupName: args.Get(1),
|
||||
Members: members,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2015-2021 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 adminGroupDisableCmd = cli.Command{
|
||||
Name: "disable",
|
||||
Usage: "disable a group",
|
||||
Action: mainAdminGroupEnableDisable,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET GROUPNAME
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Disable group 'allcents'.
|
||||
{{.Prompt}} {{.HelpName}} myminio allcents
|
||||
`,
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"errors"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminGroupEnableCmd = cli.Command{
|
||||
Name: "enable",
|
||||
Usage: "enable a group",
|
||||
Action: mainAdminGroupEnableDisable,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET GROUPNAME
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Enable group 'allcents'.
|
||||
{{.Prompt}} {{.HelpName}} myminio allcents
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminGroupEnableSyntax - validate all the passed arguments
|
||||
func checkAdminGroupEnableSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminGroupEnableDisable is the handle for "mc admin group enable|disable" command.
|
||||
func mainAdminGroupEnableDisable(ctx *cli.Context) error {
|
||||
checkAdminGroupEnableSyntax(ctx)
|
||||
|
||||
console.SetColor("GroupMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
group := args.Get(1)
|
||||
var err1 error
|
||||
var status madmin.GroupStatus
|
||||
if ctx.Command.Name == "enable" {
|
||||
status = madmin.GroupEnabled
|
||||
} else if ctx.Command.Name == "disable" {
|
||||
status = madmin.GroupDisabled
|
||||
} else {
|
||||
err1 = errors.New("cannot happen")
|
||||
fatalIf(probe.NewError(err1).Trace(args...), "Could not get group enable")
|
||||
}
|
||||
err1 = client.SetGroupStatus(globalContext, group, status)
|
||||
fatalIf(probe.NewError(err1).Trace(args...), "Could not get group enable")
|
||||
|
||||
printMsg(groupMessage{
|
||||
op: ctx.Command.Name,
|
||||
GroupName: group,
|
||||
GroupStatus: string(status),
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
// Copyright (c) 2015-2021 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/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminGroupInfoCmd = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "display group info",
|
||||
Action: mainAdminGroupInfo,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET GROUPNAME
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Get info on group 'allcents'.
|
||||
{{.Prompt}} {{.HelpName}} myminio allcents
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminGroupInfoSyntax - validate all the passed arguments
|
||||
func checkAdminGroupInfoSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "info", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminGroupInfo is the handle for "mc admin group info" command.
|
||||
func mainAdminGroupInfo(ctx *cli.Context) error {
|
||||
checkAdminGroupInfoSyntax(ctx)
|
||||
|
||||
console.SetColor("GroupMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
group := args.Get(1)
|
||||
gd, err1 := client.GetGroupDescription(globalContext, group)
|
||||
fatalIf(probe.NewError(err1).Trace(args...), "Could not get group info")
|
||||
|
||||
printMsg(groupMessage{
|
||||
op: "info",
|
||||
GroupName: group,
|
||||
GroupStatus: gd.Status,
|
||||
GroupPolicy: gd.Policy,
|
||||
Members: gd.Members,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
// Copyright (c) 2015-2021 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/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminGroupListCmd = cli.Command{
|
||||
Name: "list",
|
||||
Usage: "display list of groups",
|
||||
Action: mainAdminGroupList,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. List all groups.
|
||||
{{.Prompt}} {{.HelpName}} myminio
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminGroupListSyntax - validate all the passed arguments
|
||||
func checkAdminGroupListSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "list", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminGroupList is the handle for "mc admin group list" command.
|
||||
func mainAdminGroupList(ctx *cli.Context) error {
|
||||
checkAdminGroupListSyntax(ctx)
|
||||
|
||||
console.SetColor("GroupMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
gs, err1 := client.ListGroups(globalContext)
|
||||
fatalIf(probe.NewError(err1).Trace(args...), "Could not get group list")
|
||||
|
||||
printMsg(groupMessage{
|
||||
op: "list",
|
||||
Groups: gs,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// Copyright (c) 2015-2021 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/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminGroupRemoveCmd = cli.Command{
|
||||
Name: "remove",
|
||||
Usage: "remove group or members from a group",
|
||||
Action: mainAdminGroupRemove,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET GROUPNAME [USERNAMES...]
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Remove members 'tencent' and 'fivecent' from group 'allcents'.
|
||||
{{.Prompt}} {{.HelpName}} myminio allcents tencent fivecent
|
||||
|
||||
2. Remove group 'allcents'.
|
||||
{{.Prompt}} {{.HelpName}} myminio allcents
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminGroupRemoveSyntax - validate all the passed arguments
|
||||
func checkAdminGroupRemoveSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) < 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "remove", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminGroupRemove is the handle for "mc admin group remove" command.
|
||||
func mainAdminGroupRemove(ctx *cli.Context) error {
|
||||
checkAdminGroupRemoveSyntax(ctx)
|
||||
|
||||
console.SetColor("GroupMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
members := []string{}
|
||||
for i := 2; i < ctx.NArg(); i++ {
|
||||
members = append(members, args.Get(i))
|
||||
}
|
||||
gAddRemove := madmin.GroupAddRemove{
|
||||
Group: args.Get(1),
|
||||
Members: members,
|
||||
IsRemove: true,
|
||||
}
|
||||
|
||||
e := client.UpdateGroupMembers(globalContext, gAddRemove)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Could not perform remove operation")
|
||||
|
||||
printMsg(groupMessage{
|
||||
op: "remove",
|
||||
GroupName: args.Get(1),
|
||||
Members: members,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2015-2021 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 adminGroupSubcommands = []cli.Command{
|
||||
adminGroupAddCmd,
|
||||
adminGroupRemoveCmd,
|
||||
adminGroupInfoCmd,
|
||||
adminGroupListCmd,
|
||||
adminGroupEnableCmd,
|
||||
adminGroupDisableCmd,
|
||||
}
|
||||
|
||||
var adminGroupCmd = cli.Command{
|
||||
Name: "group",
|
||||
Usage: "manage groups",
|
||||
Action: mainAdminGroup,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: adminGroupSubcommands,
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
// mainAdminGroup is the handle for "mc admin config" command.
|
||||
func mainAdminGroup(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminGroupSubcommands)
|
||||
return nil
|
||||
// Sub-commands like "get", "set" have their own main.
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
|
||||
"github.com/minio/madmin-go"
|
||||
)
|
||||
|
||||
type hri struct {
|
||||
*madmin.HealResultItem
|
||||
}
|
||||
|
||||
func newHRI(i *madmin.HealResultItem) *hri {
|
||||
return &hri{i}
|
||||
}
|
||||
|
||||
// getObjectHCCChange - returns before and after color change for
|
||||
// objects
|
||||
func (h hri) getObjectHCCChange() (b, a col, err error) {
|
||||
parityShards := h.ParityBlocks
|
||||
dataShards := h.DataBlocks
|
||||
|
||||
onlineBefore, onlineAfter := h.GetOnlineCounts()
|
||||
surplusShardsBeforeHeal := onlineBefore - dataShards
|
||||
surplusShardsAfterHeal := onlineAfter - dataShards
|
||||
|
||||
b, err = getHColCode(surplusShardsBeforeHeal, parityShards)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%w: surplusShardsBeforeHeal: %d, parityShards: %d",
|
||||
err, surplusShardsBeforeHeal, parityShards)
|
||||
return
|
||||
}
|
||||
a, err = getHColCode(surplusShardsAfterHeal, parityShards)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("%w: surplusShardsBeforeHeal: %d, parityShards: %d",
|
||||
err, surplusShardsAfterHeal, parityShards)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// getReplicatedFileHCCChange - fetches health color code for metadata
|
||||
// files that are replicated.
|
||||
func (h hri) getReplicatedFileHCCChange() (b, a col, err error) {
|
||||
getColCode := func(numAvail int) (c col, err error) {
|
||||
// calculate color code for replicated object similar
|
||||
// to erasure coded objects
|
||||
quorum := h.DiskCount/h.SetCount/2 + 1
|
||||
surplus := numAvail/h.SetCount - quorum
|
||||
parity := h.DiskCount/h.SetCount - quorum
|
||||
c, err = getHColCode(surplus, parity)
|
||||
return
|
||||
}
|
||||
|
||||
onlineBefore, onlineAfter := h.GetOnlineCounts()
|
||||
b, err = getColCode(onlineBefore)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
a, err = getColCode(onlineAfter)
|
||||
return
|
||||
}
|
||||
|
||||
func (h hri) makeHealEntityString() string {
|
||||
switch h.Type {
|
||||
case madmin.HealItemObject:
|
||||
return h.Bucket + "/" + h.Object
|
||||
case madmin.HealItemBucket:
|
||||
return h.Bucket
|
||||
case madmin.HealItemMetadata:
|
||||
return "[disk-format]"
|
||||
case madmin.HealItemBucketMetadata:
|
||||
return fmt.Sprintf("[bucket-metadata]%s/%s", h.Bucket, h.Object)
|
||||
}
|
||||
return "** unexpected **"
|
||||
}
|
||||
|
||||
func (h hri) getHRTypeAndName() (typ, name string) {
|
||||
name = fmt.Sprintf("%s/%s", h.Bucket, h.Object)
|
||||
switch h.Type {
|
||||
case madmin.HealItemMetadata:
|
||||
typ = "system"
|
||||
name = h.Detail
|
||||
case madmin.HealItemBucketMetadata:
|
||||
typ = "system"
|
||||
name = "bucket-metadata:" + name
|
||||
case madmin.HealItemBucket:
|
||||
typ = "bucket"
|
||||
case madmin.HealItemObject:
|
||||
typ = "object"
|
||||
default:
|
||||
typ = fmt.Sprintf("!! Unknown heal result record %#v !!", h)
|
||||
name = typ
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (h hri) getHealResultStr() string {
|
||||
typ, name := h.getHRTypeAndName()
|
||||
|
||||
switch h.Type {
|
||||
case madmin.HealItemMetadata, madmin.HealItemBucketMetadata:
|
||||
return typ + ":" + name
|
||||
default:
|
||||
return name
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,444 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/fatih/color"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
const (
|
||||
lineWidth = 80
|
||||
)
|
||||
|
||||
var (
|
||||
hColOrder = []col{colRed, colYellow, colGreen}
|
||||
hColTable = map[int][]int{
|
||||
1: {0, -1, 1},
|
||||
2: {0, 1, 2},
|
||||
3: {1, 2, 3},
|
||||
4: {1, 2, 4},
|
||||
5: {1, 3, 5},
|
||||
6: {2, 4, 6},
|
||||
7: {2, 4, 7},
|
||||
8: {2, 5, 8},
|
||||
}
|
||||
)
|
||||
|
||||
func getHColCode(surplusShards, parityShards int) (c col, err error) {
|
||||
if parityShards < 1 || parityShards > 8 || surplusShards > parityShards {
|
||||
return c, fmt.Errorf("Invalid parity shard count/surplus shard count given")
|
||||
}
|
||||
if surplusShards < 0 {
|
||||
return colGrey, err
|
||||
}
|
||||
colRow := hColTable[parityShards]
|
||||
for index, val := range colRow {
|
||||
if val != -1 && surplusShards <= val {
|
||||
return hColOrder[index], err
|
||||
}
|
||||
}
|
||||
return c, fmt.Errorf("cannot get a heal color code")
|
||||
}
|
||||
|
||||
type uiData struct {
|
||||
Bucket, Prefix string
|
||||
Client *madmin.AdminClient
|
||||
ClientToken string
|
||||
ForceStart bool
|
||||
HealOpts *madmin.HealOpts
|
||||
LastItem *hri
|
||||
|
||||
// Total time since heal start
|
||||
HealDuration time.Duration
|
||||
|
||||
// Accumulated statistics of heal result records
|
||||
BytesScanned int64
|
||||
|
||||
// Counter for objects, and another counter for all kinds of
|
||||
// items
|
||||
ObjectsScanned, ItemsScanned int64
|
||||
|
||||
// Counters for healed objects and all kinds of healed items
|
||||
ObjectsHealed, ItemsHealed int64
|
||||
|
||||
// Map from online drives to number of objects with that many
|
||||
// online drives.
|
||||
ObjectsByOnlineDrives map[int]int64
|
||||
// Map of health color code to number of objects with that
|
||||
// health color code.
|
||||
HealthCols map[col]int64
|
||||
|
||||
// channel to receive a prompt string to indicate activity on
|
||||
// the terminal
|
||||
CurChan (<-chan string)
|
||||
}
|
||||
|
||||
func (ui *uiData) updateStats(i madmin.HealResultItem) error {
|
||||
if i.Type == madmin.HealItemObject {
|
||||
// Objects whose size could not be found have -1 size
|
||||
// returned.
|
||||
if i.ObjectSize >= 0 {
|
||||
ui.BytesScanned += i.ObjectSize
|
||||
}
|
||||
|
||||
ui.ObjectsScanned++
|
||||
}
|
||||
ui.ItemsScanned++
|
||||
|
||||
beforeUp, afterUp := i.GetOnlineCounts()
|
||||
if afterUp > beforeUp {
|
||||
if i.Type == madmin.HealItemObject {
|
||||
ui.ObjectsHealed++
|
||||
}
|
||||
ui.ItemsHealed++
|
||||
}
|
||||
ui.ObjectsByOnlineDrives[afterUp]++
|
||||
|
||||
// Update health color stats:
|
||||
|
||||
// Fetch health color after heal:
|
||||
var err error
|
||||
var afterCol col
|
||||
h := newHRI(&i)
|
||||
switch h.Type {
|
||||
case madmin.HealItemMetadata, madmin.HealItemBucket:
|
||||
_, afterCol, err = h.getReplicatedFileHCCChange()
|
||||
default:
|
||||
_, afterCol, err = h.getObjectHCCChange()
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ui.HealthCols[afterCol]++
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ui *uiData) updateDuration(s *madmin.HealTaskStatus) {
|
||||
ui.HealDuration = UTCNow().Sub(s.StartTime)
|
||||
}
|
||||
|
||||
func (ui *uiData) getProgress() (oCount, objSize, duration string) {
|
||||
oCount = humanize.Comma(ui.ObjectsScanned)
|
||||
|
||||
duration = ui.HealDuration.Round(time.Second).String()
|
||||
|
||||
bytesScanned := float64(ui.BytesScanned)
|
||||
|
||||
// Compute unit for object size
|
||||
magnitudes := []float64{1 << 10, 1 << 20, 1 << 30, 1 << 40, 1 << 50, 1 << 60}
|
||||
units := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"}
|
||||
var i int
|
||||
for i = 0; i < len(magnitudes); i++ {
|
||||
if bytesScanned <= magnitudes[i] {
|
||||
break
|
||||
}
|
||||
}
|
||||
numUnits := int(bytesScanned * (1 << 10) / magnitudes[i])
|
||||
objSize = fmt.Sprintf("%d %s", numUnits, units[i])
|
||||
return
|
||||
}
|
||||
|
||||
func (ui *uiData) getPercentsNBars() (p map[col]float64, b map[col]string) {
|
||||
// barChar, emptyBarChar := "█", "░"
|
||||
barChar, emptyBarChar := "█", " "
|
||||
barLen := 12
|
||||
sum := float64(ui.ItemsScanned)
|
||||
cols := []col{colGrey, colRed, colYellow, colGreen}
|
||||
|
||||
p = make(map[col]float64, len(cols))
|
||||
b = make(map[col]string, len(cols))
|
||||
var filledLen int
|
||||
for _, col := range cols {
|
||||
v := float64(ui.HealthCols[col])
|
||||
if sum == 0 {
|
||||
p[col] = 0
|
||||
filledLen = 0
|
||||
} else {
|
||||
p[col] = v * 100 / sum
|
||||
// round up the filled part
|
||||
filledLen = int(math.Ceil(float64(barLen) * v / sum))
|
||||
}
|
||||
b[col] = strings.Repeat(barChar, filledLen) +
|
||||
strings.Repeat(emptyBarChar, barLen-filledLen)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (ui *uiData) printItemsQuietly(s *madmin.HealTaskStatus) (err error) {
|
||||
lpad := func(s col) string {
|
||||
return fmt.Sprintf("%-6s", string(s))
|
||||
}
|
||||
rpad := func(s col) string {
|
||||
return fmt.Sprintf("%6s", string(s))
|
||||
}
|
||||
printColStr := func(before, after col) {
|
||||
console.PrintC("[" + lpad(before) + " -> " + rpad(after) + "] ")
|
||||
}
|
||||
|
||||
var b, a col
|
||||
for _, item := range s.Items {
|
||||
h := newHRI(&item)
|
||||
switch h.Type {
|
||||
case madmin.HealItemMetadata, madmin.HealItemBucket:
|
||||
b, a, err = h.getReplicatedFileHCCChange()
|
||||
default:
|
||||
b, a, err = h.getObjectHCCChange()
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printColStr(b, a)
|
||||
hrStr := h.getHealResultStr()
|
||||
switch h.Type {
|
||||
case madmin.HealItemMetadata, madmin.HealItemBucketMetadata:
|
||||
console.PrintC(fmt.Sprintln("**", hrStr, "**"))
|
||||
default:
|
||||
console.PrintC(hrStr, "\n")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ui *uiData) printStatsQuietly(s *madmin.HealTaskStatus) {
|
||||
totalObjects, totalSize, totalTime := ui.getProgress()
|
||||
|
||||
healedStr := fmt.Sprintf("Healed:\t%s/%s objects; %s in %s\n",
|
||||
humanize.Comma(ui.ObjectsHealed), totalObjects,
|
||||
totalSize, totalTime)
|
||||
|
||||
console.PrintC(healedStr)
|
||||
}
|
||||
|
||||
func (ui *uiData) printItemsJSON(s *madmin.HealTaskStatus) (err error) {
|
||||
type healRec struct {
|
||||
Status string `json:"status"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Type string `json:"type"`
|
||||
Name string `json:"name"`
|
||||
Before struct {
|
||||
Color string `json:"color"`
|
||||
Offline int `json:"offline"`
|
||||
Online int `json:"online"`
|
||||
Missing int `json:"missing"`
|
||||
Corrupted int `json:"corrupted"`
|
||||
Drives []madmin.HealDriveInfo `json:"drives"`
|
||||
} `json:"before"`
|
||||
After struct {
|
||||
Color string `json:"color"`
|
||||
Offline int `json:"offline"`
|
||||
Online int `json:"online"`
|
||||
Missing int `json:"missing"`
|
||||
Corrupted int `json:"corrupted"`
|
||||
Drives []madmin.HealDriveInfo `json:"drives"`
|
||||
} `json:"after"`
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
makeHR := func(h *hri) (r healRec) {
|
||||
r.Status = "success"
|
||||
r.Type, r.Name = h.getHRTypeAndName()
|
||||
|
||||
var b, a col
|
||||
var err error
|
||||
switch h.Type {
|
||||
case madmin.HealItemMetadata, madmin.HealItemBucket:
|
||||
b, a, err = h.getReplicatedFileHCCChange()
|
||||
default:
|
||||
if h.Type == madmin.HealItemObject {
|
||||
r.Size = h.ObjectSize
|
||||
}
|
||||
b, a, err = h.getObjectHCCChange()
|
||||
}
|
||||
if err != nil {
|
||||
r.Error = err.Error()
|
||||
}
|
||||
r.Before.Color = strings.ToLower(string(b))
|
||||
r.After.Color = strings.ToLower(string(a))
|
||||
r.Before.Online, r.After.Online = h.GetOnlineCounts()
|
||||
r.Before.Missing, r.After.Missing = h.GetMissingCounts()
|
||||
r.Before.Corrupted, r.After.Corrupted = h.GetCorruptedCounts()
|
||||
r.Before.Offline, r.After.Offline = h.GetOfflineCounts()
|
||||
r.Before.Drives = h.Before.Drives
|
||||
r.After.Drives = h.After.Drives
|
||||
return r
|
||||
}
|
||||
|
||||
for _, item := range s.Items {
|
||||
h := newHRI(&item)
|
||||
jsonBytes, err := json.MarshalIndent(makeHR(h), "", " ")
|
||||
fatalIf(probe.NewError(err), "Unable to marshal to JSON.")
|
||||
console.Println(string(jsonBytes))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ui *uiData) printStatsJSON(s *madmin.HealTaskStatus) {
|
||||
var summary struct {
|
||||
Status string `json:"status"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Type string `json:"type"`
|
||||
ObjectsScanned int64 `json:"objects_scanned"`
|
||||
ObjectsHealed int64 `json:"objects_healed"`
|
||||
ItemsScanned int64 `json:"items_scanned"`
|
||||
ItemsHealed int64 `json:"items_healed"`
|
||||
Size int64 `json:"size"`
|
||||
ElapsedTime int64 `json:"duration"`
|
||||
}
|
||||
|
||||
summary.Status = "success"
|
||||
summary.Type = "summary"
|
||||
|
||||
summary.ObjectsScanned = ui.ObjectsScanned
|
||||
summary.ObjectsHealed = ui.ObjectsHealed
|
||||
summary.ItemsScanned = ui.ItemsScanned
|
||||
summary.ItemsHealed = ui.ItemsHealed
|
||||
summary.Size = ui.BytesScanned
|
||||
summary.ElapsedTime = int64(ui.HealDuration.Round(time.Second).Seconds())
|
||||
|
||||
jBytes, err := json.MarshalIndent(summary, "", " ")
|
||||
fatalIf(probe.NewError(err), "Unable to marshal to JSON.")
|
||||
console.Println(string(jBytes))
|
||||
}
|
||||
|
||||
func (ui *uiData) updateUI(s *madmin.HealTaskStatus) (err error) {
|
||||
itemCount := len(s.Items)
|
||||
h := ui.LastItem
|
||||
if itemCount > 0 {
|
||||
item := s.Items[itemCount-1]
|
||||
h = newHRI(&item)
|
||||
ui.LastItem = h
|
||||
}
|
||||
scannedStr := "** waiting for status from server **"
|
||||
if h != nil {
|
||||
scannedStr = lineTrunc(h.makeHealEntityString(), lineWidth-len("Scanned: "))
|
||||
}
|
||||
|
||||
totalObjects, totalSize, totalTime := ui.getProgress()
|
||||
healedStr := fmt.Sprintf("%s/%s objects; %s in %s",
|
||||
humanize.Comma(ui.ObjectsHealed), totalObjects,
|
||||
totalSize, totalTime)
|
||||
|
||||
console.Print(console.Colorize("HealUpdateUI", fmt.Sprintf(" %s", <-ui.CurChan)))
|
||||
console.PrintC(fmt.Sprintf(" %s\n", scannedStr))
|
||||
console.PrintC(fmt.Sprintf(" %s\n", healedStr))
|
||||
|
||||
dspOrder := []col{colGreen, colYellow, colRed, colGrey}
|
||||
printColors := []*color.Color{}
|
||||
for _, c := range dspOrder {
|
||||
printColors = append(printColors, getPrintCol(c))
|
||||
}
|
||||
t := console.NewTable(printColors, []bool{false, true, true}, 4)
|
||||
|
||||
percentMap, barMap := ui.getPercentsNBars()
|
||||
cellText := make([][]string, len(dspOrder))
|
||||
for i := range cellText {
|
||||
cellText[i] = []string{
|
||||
string(dspOrder[i]),
|
||||
fmt.Sprint(humanize.Comma(ui.HealthCols[dspOrder[i]])),
|
||||
fmt.Sprintf("%5.1f%% %s", percentMap[dspOrder[i]], barMap[dspOrder[i]]),
|
||||
}
|
||||
}
|
||||
|
||||
t.DisplayTable(cellText)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (ui *uiData) UpdateDisplay(s *madmin.HealTaskStatus) (err error) {
|
||||
// Update state
|
||||
ui.updateDuration(s)
|
||||
for _, i := range s.Items {
|
||||
ui.updateStats(i)
|
||||
}
|
||||
|
||||
// Update display
|
||||
switch {
|
||||
case globalJSON:
|
||||
err = ui.printItemsJSON(s)
|
||||
case globalQuiet:
|
||||
err = ui.printItemsQuietly(s)
|
||||
default:
|
||||
err = ui.updateUI(s)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (ui *uiData) healResumeMsg(aliasedURL string) string {
|
||||
var flags string
|
||||
if ui.HealOpts.Recursive {
|
||||
flags += "--recursive "
|
||||
}
|
||||
if ui.HealOpts.DryRun {
|
||||
flags += "--dry-run "
|
||||
}
|
||||
return fmt.Sprintf("Healing is backgrounded, to resume watching use `mc admin heal %s %s`", flags, aliasedURL)
|
||||
}
|
||||
|
||||
func (ui *uiData) DisplayAndFollowHealStatus(aliasedURL string) (res madmin.HealTaskStatus, err error) {
|
||||
quitMsg := ui.healResumeMsg(aliasedURL)
|
||||
|
||||
firstIter := true
|
||||
for {
|
||||
select {
|
||||
case <-globalContext.Done():
|
||||
return res, errors.New(quitMsg)
|
||||
default:
|
||||
_, res, err = ui.Client.Heal(globalContext, ui.Bucket, ui.Prefix, *ui.HealOpts,
|
||||
ui.ClientToken, ui.ForceStart, false)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
if firstIter {
|
||||
firstIter = false
|
||||
} else {
|
||||
if !globalQuiet && !globalJSON {
|
||||
console.RewindLines(8)
|
||||
}
|
||||
}
|
||||
err = ui.UpdateDisplay(&res)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
|
||||
if res.Summary == "finished" {
|
||||
if globalJSON {
|
||||
ui.printStatsJSON(&res)
|
||||
} else if globalQuiet {
|
||||
ui.printStatsQuietly(&res)
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
if res.Summary == "stopped" {
|
||||
return res, fmt.Errorf("Heal had an error - %s", res.FailureDetail)
|
||||
}
|
||||
|
||||
time.Sleep(time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,671 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
const (
|
||||
scanNormalMode = "normal"
|
||||
scanDeepMode = "deep"
|
||||
)
|
||||
|
||||
var adminHealFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "scan",
|
||||
Usage: "select the healing scan mode (normal/deep)",
|
||||
Value: scanNormalMode,
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "recursive, r",
|
||||
Usage: "heal recursively",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "dry-run, n",
|
||||
Usage: "only inspect data, but do not mutate",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "force-start, f",
|
||||
Usage: "force start a new heal sequence",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "force-stop, s",
|
||||
Usage: "force stop a running heal sequence",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "remove",
|
||||
Usage: "remove dangling objects in heal sequence",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "storage-class",
|
||||
Usage: "show server/disks failure tolerance with the given storage class",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "verbose, v",
|
||||
Usage: "show verbose information",
|
||||
},
|
||||
}
|
||||
|
||||
var adminHealCmd = cli.Command{
|
||||
Name: "heal",
|
||||
Usage: "heal disks, buckets and objects on MinIO server",
|
||||
Action: mainAdminHeal,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(adminHealFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} [FLAGS] TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Monitor healing status on a running server at alias 'myminio':
|
||||
{{.Prompt}} {{.HelpName}} myminio/
|
||||
`,
|
||||
}
|
||||
|
||||
func checkAdminHealSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "heal", 1) // last argument is exit code
|
||||
}
|
||||
|
||||
// Check for scan argument
|
||||
scanArg := ctx.String("scan")
|
||||
scanArg = strings.ToLower(scanArg)
|
||||
if scanArg != scanNormalMode && scanArg != scanDeepMode {
|
||||
cli.ShowCommandHelpAndExit(ctx, "heal", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// stopHealMessage is container for stop heal success and failure messages.
|
||||
type stopHealMessage struct {
|
||||
Status string `json:"status"`
|
||||
Alias string `json:"alias"`
|
||||
}
|
||||
|
||||
// String colorized stop heal message.
|
||||
func (s stopHealMessage) String() string {
|
||||
return console.Colorize("HealStopped", "Heal stopped successfully at `"+s.Alias+"`.")
|
||||
}
|
||||
|
||||
// JSON jsonified stop heal message.
|
||||
func (s stopHealMessage) JSON() string {
|
||||
stopHealJSONBytes, e := json.MarshalIndent(s, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(stopHealJSONBytes)
|
||||
}
|
||||
|
||||
type setIndex struct {
|
||||
pool, set int
|
||||
}
|
||||
|
||||
type poolInfo struct {
|
||||
tolerance int
|
||||
endpoints []string
|
||||
}
|
||||
|
||||
type diskInfo struct {
|
||||
set setIndex
|
||||
path string
|
||||
state string
|
||||
|
||||
healStarted, healLastUpdate time.Time
|
||||
|
||||
usedSpace, totalSpace uint64
|
||||
}
|
||||
|
||||
type setInfo struct {
|
||||
maxUsedSpace uint64
|
||||
totalDisks int
|
||||
incapableDisks int
|
||||
}
|
||||
|
||||
type serverInfo struct {
|
||||
pool int
|
||||
disks []diskInfo
|
||||
}
|
||||
|
||||
func (s serverInfo) onlineDisksForSet(index setIndex) (setFound bool, count int) {
|
||||
for _, disk := range s.disks {
|
||||
if disk.set != index {
|
||||
continue
|
||||
}
|
||||
setFound = true
|
||||
if disk.state == "ok" && disk.healStarted.IsZero() {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Get all disks from set statuses
|
||||
func getAllDisks(sets []madmin.SetStatus) []madmin.Disk {
|
||||
var disks []madmin.Disk
|
||||
for _, set := range sets {
|
||||
disks = append(disks, set.Disks...)
|
||||
}
|
||||
return disks
|
||||
}
|
||||
|
||||
// Get all pools id from all disks
|
||||
func getPoolsIndexes(disks []madmin.Disk) []int {
|
||||
m := make(map[int]struct{})
|
||||
for _, d := range disks {
|
||||
m[d.PoolIndex] = struct{}{}
|
||||
}
|
||||
var pools []int
|
||||
for pool := range m {
|
||||
pools = append(pools, pool)
|
||||
}
|
||||
sort.Ints(pools)
|
||||
return pools
|
||||
}
|
||||
|
||||
// Generate sets info from disks
|
||||
func generateSetsStatus(disks []madmin.Disk) map[setIndex]setInfo {
|
||||
m := make(map[setIndex]setInfo)
|
||||
for _, d := range disks {
|
||||
idx := setIndex{pool: d.PoolIndex, set: d.SetIndex}
|
||||
setSt, ok := m[idx]
|
||||
if !ok {
|
||||
setSt = setInfo{}
|
||||
}
|
||||
setSt.totalDisks++
|
||||
if d.UsedSpace > setSt.maxUsedSpace {
|
||||
setSt.maxUsedSpace = d.UsedSpace
|
||||
}
|
||||
if d.State != "ok" || d.Healing {
|
||||
setSt.incapableDisks++
|
||||
}
|
||||
m[idx] = setSt
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
// Return a map of server endpoints and the corresponding status
|
||||
func generateServersStatus(disks []madmin.Disk) map[string]serverInfo {
|
||||
m := make(map[string]serverInfo)
|
||||
for _, d := range disks {
|
||||
u, err := url.Parse(d.Endpoint)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
endpoint := u.Host
|
||||
if endpoint == "" {
|
||||
endpoint = "local-pool" + humanize.Ordinal(d.PoolIndex+1)
|
||||
}
|
||||
serverSt, ok := m[endpoint]
|
||||
if !ok {
|
||||
serverSt = serverInfo{
|
||||
pool: d.PoolIndex,
|
||||
}
|
||||
}
|
||||
setIndex := setIndex{pool: d.PoolIndex, set: d.SetIndex}
|
||||
di := diskInfo{
|
||||
set: setIndex,
|
||||
path: u.Path,
|
||||
state: d.State,
|
||||
usedSpace: d.UsedSpace,
|
||||
totalSpace: d.TotalSpace,
|
||||
}
|
||||
|
||||
if d.HealInfo != nil {
|
||||
di.healStarted = d.HealInfo.Started
|
||||
di.healLastUpdate = d.HealInfo.LastUpdate
|
||||
}
|
||||
|
||||
serverSt.disks = append(serverSt.disks, di)
|
||||
m[endpoint] = serverSt
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
// Return the list of endpoints of a given pool index
|
||||
func computePoolEndpoints(pool int, serversStatus map[string]serverInfo) []string {
|
||||
var endpoints []string
|
||||
for endpoint, server := range serversStatus {
|
||||
if server.pool != pool {
|
||||
continue
|
||||
}
|
||||
endpoints = append(endpoints, endpoint)
|
||||
}
|
||||
return endpoints
|
||||
}
|
||||
|
||||
// Compute the tolerance of each node in a given pool
|
||||
func computePoolTolerance(pool, parity int, setsStatus map[setIndex]setInfo, serversStatus map[string]serverInfo) int {
|
||||
var (
|
||||
onlineDisksPerSet = make(map[setIndex]int)
|
||||
tolerancePerSet = make(map[setIndex]int)
|
||||
)
|
||||
|
||||
for set, setStatus := range setsStatus {
|
||||
if set.pool != pool {
|
||||
continue
|
||||
}
|
||||
|
||||
onlineDisksPerSet[set] = setStatus.totalDisks - setStatus.incapableDisks
|
||||
tolerancePerSet[set] = 0
|
||||
|
||||
for _, server := range serversStatus {
|
||||
if server.pool != pool {
|
||||
continue
|
||||
}
|
||||
|
||||
canShutdown := true
|
||||
setFound, count := server.onlineDisksForSet(set)
|
||||
if !setFound {
|
||||
continue
|
||||
}
|
||||
minDisks := setStatus.totalDisks - parity
|
||||
if onlineDisksPerSet[set]-count < minDisks {
|
||||
canShutdown = false
|
||||
}
|
||||
if canShutdown {
|
||||
tolerancePerSet[set]++
|
||||
onlineDisksPerSet[set] -= count
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
minServerTolerance := len(serversStatus)
|
||||
for _, tolerance := range tolerancePerSet {
|
||||
if tolerance < minServerTolerance {
|
||||
minServerTolerance = tolerance
|
||||
}
|
||||
}
|
||||
|
||||
return minServerTolerance
|
||||
}
|
||||
|
||||
// Extract offline nodes from offline full path endpoints
|
||||
func getOfflineNodes(endpoints []string) map[string]struct{} {
|
||||
offlineNodes := make(map[string]struct{})
|
||||
for _, endpoint := range endpoints {
|
||||
offlineNodes[endpoint] = struct{}{}
|
||||
}
|
||||
return offlineNodes
|
||||
}
|
||||
|
||||
// verboseBackgroundHealStatusMessage is container for stop heal success and failure messages.
|
||||
type verboseBackgroundHealStatusMessage struct {
|
||||
Status string `json:"status"`
|
||||
HealInfo madmin.BgHealState
|
||||
|
||||
// Specify storage class to show servers/disks tolerance
|
||||
ToleranceForSC string `json:"-"`
|
||||
}
|
||||
|
||||
// String colorized to show background heal status message.
|
||||
func (s verboseBackgroundHealStatusMessage) String() string {
|
||||
var msg strings.Builder
|
||||
|
||||
parity, showTolerance := s.HealInfo.SCParity[s.ToleranceForSC]
|
||||
offlineEndpoints := getOfflineNodes(s.HealInfo.OfflineEndpoints)
|
||||
allDisks := getAllDisks(s.HealInfo.Sets)
|
||||
pools := getPoolsIndexes(allDisks)
|
||||
setsStatus := generateSetsStatus(allDisks)
|
||||
serversStatus := generateServersStatus(allDisks)
|
||||
|
||||
poolsInfo := make(map[int]poolInfo)
|
||||
for _, pool := range pools {
|
||||
tolerance := computePoolTolerance(pool, parity, setsStatus, serversStatus)
|
||||
endpoints := computePoolEndpoints(pool, serversStatus)
|
||||
poolsInfo[pool] = poolInfo{tolerance: tolerance, endpoints: endpoints}
|
||||
}
|
||||
|
||||
distributed := len(serversStatus) > 1
|
||||
|
||||
plural := ""
|
||||
if distributed {
|
||||
plural = "s"
|
||||
}
|
||||
fmt.Fprintf(&msg, "Server%s status:\n", plural)
|
||||
fmt.Fprintf(&msg, "==============\n")
|
||||
|
||||
for _, pool := range pools {
|
||||
fmt.Fprintf(&msg, "Pool %s:\n", humanize.Ordinal(pool+1))
|
||||
|
||||
// Sort servers in this pool by name
|
||||
orderedEndpoints := make([]string, len(poolsInfo[pool].endpoints))
|
||||
copy(orderedEndpoints, poolsInfo[pool].endpoints)
|
||||
sort.Strings(orderedEndpoints)
|
||||
|
||||
for _, endpoint := range orderedEndpoints {
|
||||
// Print offline status if node is offline
|
||||
_, ok := offlineEndpoints[endpoint]
|
||||
if ok {
|
||||
stateText := console.Colorize("NodeFailed", "OFFLINE")
|
||||
fmt.Fprintf(&msg, fmt.Sprintf(" %s: %s\n", endpoint, stateText))
|
||||
continue
|
||||
}
|
||||
serverStatus := serversStatus[endpoint]
|
||||
switch {
|
||||
case showTolerance:
|
||||
serverHeader := " %s: (Tolerance: %d server(s))\n"
|
||||
fmt.Fprintf(&msg, fmt.Sprintf(serverHeader, endpoint, poolsInfo[serverStatus.pool].tolerance))
|
||||
default:
|
||||
serverHeader := " %s:\n"
|
||||
fmt.Fprintf(&msg, fmt.Sprintf(serverHeader, endpoint))
|
||||
}
|
||||
|
||||
for _, d := range serverStatus.disks {
|
||||
if d.set.pool != pool {
|
||||
continue
|
||||
}
|
||||
stateText := ""
|
||||
switch {
|
||||
case d.state == "ok" && !d.healStarted.IsZero():
|
||||
stateText = console.Colorize("DiskHealing", "HEALING")
|
||||
case d.state == "ok":
|
||||
stateText = console.Colorize("DiskOK", "OK")
|
||||
default:
|
||||
stateText = console.Colorize("DiskFailed", d.state)
|
||||
}
|
||||
fmt.Fprintf(&msg, " + %s : %s\n", d.path, stateText)
|
||||
if !d.healStarted.IsZero() {
|
||||
now := time.Now().UTC()
|
||||
scanSpeed := float64(d.usedSpace) / float64(now.Sub(d.healStarted))
|
||||
remainingTime := time.Duration(float64(setsStatus[d.set].maxUsedSpace-d.usedSpace) / scanSpeed)
|
||||
estimationText := humanize.RelTime(now, now.Add(remainingTime), "", "")
|
||||
fmt.Fprintf(&msg, " |__ Estimated: %s\n", estimationText)
|
||||
}
|
||||
fmt.Fprintf(&msg, " |__ Capacity: %s/%s\n", humanize.IBytes(d.usedSpace), humanize.IBytes(d.totalSpace))
|
||||
if showTolerance {
|
||||
fmt.Fprintf(&msg, " |__ Tolerance: %d disk(s)\n", parity-setsStatus[d.set].incapableDisks)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(&msg, "\n")
|
||||
}
|
||||
}
|
||||
|
||||
if showTolerance {
|
||||
fmt.Fprintf(&msg, "\n")
|
||||
fmt.Fprintf(&msg, "Server Failure Tolerance:\n")
|
||||
fmt.Fprintf(&msg, "========================\n")
|
||||
for i, pool := range poolsInfo {
|
||||
fmt.Fprintf(&msg, "Pool %s:\n", humanize.Ordinal(i+1))
|
||||
fmt.Fprintf(&msg, " Tolerance : %d server(s)\n", pool.tolerance)
|
||||
fmt.Fprintf(&msg, " Nodes :")
|
||||
for _, endpoint := range pool.endpoints {
|
||||
fmt.Fprintf(&msg, " %s", endpoint)
|
||||
}
|
||||
fmt.Fprintf(&msg, "\n")
|
||||
}
|
||||
}
|
||||
|
||||
summary := shortBackgroundHealStatusMessage{HealInfo: s.HealInfo}
|
||||
|
||||
fmt.Fprintf(&msg, "\n")
|
||||
fmt.Fprintf(&msg, "Summary:\n")
|
||||
fmt.Fprintf(&msg, "=======\n")
|
||||
fmt.Fprintf(&msg, summary.String())
|
||||
fmt.Fprintf(&msg, "\n")
|
||||
|
||||
return msg.String()
|
||||
}
|
||||
|
||||
// JSON jsonified stop heal message.
|
||||
func (s verboseBackgroundHealStatusMessage) JSON() string {
|
||||
healJSONBytes, e := json.MarshalIndent(s, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(healJSONBytes)
|
||||
}
|
||||
|
||||
// shortBackgroundHealStatusMessage is container for stop heal success and failure messages.
|
||||
type shortBackgroundHealStatusMessage struct {
|
||||
Status string `json:"status"`
|
||||
HealInfo madmin.BgHealState
|
||||
}
|
||||
|
||||
// String colorized to show background heal status message.
|
||||
func (s shortBackgroundHealStatusMessage) String() string {
|
||||
healPrettyMsg := ""
|
||||
var (
|
||||
totalItems uint64
|
||||
totalBytes uint64
|
||||
itemsHealed uint64
|
||||
bytesHealed uint64
|
||||
startedAt time.Time
|
||||
|
||||
// The addition of Elapsed time of each parallel healing operation
|
||||
// this is needed to calculate the rate of healing
|
||||
accumulatedElapsedTime time.Duration
|
||||
|
||||
// ETA of healing - it is the latest ETA of all disks currently healing
|
||||
healingRemaining time.Duration
|
||||
)
|
||||
|
||||
dedup := make(map[setIndex]struct{})
|
||||
|
||||
for _, set := range s.HealInfo.Sets {
|
||||
setsStatus := generateSetsStatus(set.Disks)
|
||||
for _, disk := range set.Disks {
|
||||
if disk.HealInfo != nil {
|
||||
// Avoid counting two disks beloning to the same pool/set
|
||||
diskSet := setIndex{pool: disk.PoolIndex, set: disk.SetIndex}
|
||||
_, found := dedup[diskSet]
|
||||
if found {
|
||||
continue
|
||||
}
|
||||
dedup[diskSet] = struct{}{}
|
||||
|
||||
// Approximate values
|
||||
totalItems += disk.HealInfo.ObjectsTotalCount
|
||||
totalBytes += disk.HealInfo.ObjectsTotalSize
|
||||
itemsHealed += disk.HealInfo.ItemsHealed
|
||||
bytesHealed += disk.HealInfo.BytesDone
|
||||
|
||||
if !disk.HealInfo.Started.IsZero() {
|
||||
if !disk.HealInfo.Started.Before(startedAt) {
|
||||
startedAt = disk.HealInfo.Started
|
||||
}
|
||||
|
||||
if !disk.HealInfo.LastUpdate.IsZero() {
|
||||
accumulatedElapsedTime += disk.HealInfo.LastUpdate.Sub(disk.HealInfo.Started)
|
||||
}
|
||||
|
||||
scanSpeed := float64(disk.UsedSpace) / float64(time.Now().Sub(disk.HealInfo.Started))
|
||||
remainingTime := time.Duration(float64(setsStatus[diskSet].maxUsedSpace-disk.UsedSpace) / scanSpeed)
|
||||
if remainingTime > healingRemaining {
|
||||
healingRemaining = remainingTime
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if startedAt.IsZero() && itemsHealed == 0 {
|
||||
healPrettyMsg += "No active healing in progress."
|
||||
return healPrettyMsg
|
||||
}
|
||||
|
||||
if totalItems > 0 && totalBytes > 0 {
|
||||
// Objects healed information
|
||||
itemsPct := 100 * float64(itemsHealed) / float64(totalItems)
|
||||
bytesPct := 100 * float64(bytesHealed) / float64(totalBytes)
|
||||
|
||||
healPrettyMsg += fmt.Sprintf("Objects Healed: %s/%s (%s), %s/%s (%s)\n",
|
||||
humanize.Comma(int64(itemsHealed)), humanize.Comma(int64(totalItems)), humanize.CommafWithDigits(itemsPct, 1)+"%%",
|
||||
humanize.Bytes(bytesHealed), humanize.Bytes(totalBytes), humanize.CommafWithDigits(bytesPct, 1)+"%%")
|
||||
} else {
|
||||
healPrettyMsg += fmt.Sprintf("Objects Healed: %s, %s\n", humanize.Comma(int64(itemsHealed)), humanize.Bytes(bytesHealed))
|
||||
}
|
||||
|
||||
if accumulatedElapsedTime > 0 {
|
||||
bytesHealedPerSec := float64(uint64(time.Second)*bytesHealed) / float64(accumulatedElapsedTime)
|
||||
itemsHealedPerSec := float64(uint64(time.Second)*itemsHealed) / float64(accumulatedElapsedTime)
|
||||
healPrettyMsg += fmt.Sprintf("Heal rate: %d obj/s, %s/s\n", int64(itemsHealedPerSec), humanize.IBytes(uint64(bytesHealedPerSec)))
|
||||
}
|
||||
|
||||
// Estimation completion
|
||||
now := time.Now()
|
||||
healPrettyMsg += fmt.Sprintf("Estimated Completion: %s\n", humanize.RelTime(now, now.Add(healingRemaining), "", ""))
|
||||
|
||||
return healPrettyMsg
|
||||
}
|
||||
|
||||
// JSON jsonified stop heal message.
|
||||
func (s shortBackgroundHealStatusMessage) JSON() string {
|
||||
healJSONBytes, e := json.MarshalIndent(s, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(healJSONBytes)
|
||||
}
|
||||
|
||||
func transformScanArg(scanArg string) madmin.HealScanMode {
|
||||
switch scanArg {
|
||||
case "deep":
|
||||
return madmin.HealDeepScan
|
||||
}
|
||||
return madmin.HealNormalScan
|
||||
}
|
||||
|
||||
// mainAdminHeal - the entry function of heal command
|
||||
func mainAdminHeal(ctx *cli.Context) error {
|
||||
// Check for command syntax
|
||||
checkAdminHealSyntax(ctx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
console.SetColor("Heal", color.New(color.FgGreen, color.Bold))
|
||||
console.SetColor("Dot", color.New(color.FgGreen, color.Bold))
|
||||
console.SetColor("HealBackgroundTitle", color.New(color.FgGreen, color.Bold))
|
||||
console.SetColor("HealBackground", color.New(color.Bold))
|
||||
console.SetColor("HealUpdateUI", color.New(color.FgYellow, color.Bold))
|
||||
console.SetColor("HealStopped", color.New(color.FgGreen, color.Bold))
|
||||
|
||||
console.SetColor("DiskHealing", color.New(color.FgYellow, color.Bold))
|
||||
console.SetColor("DiskOK", color.New(color.FgGreen, color.Bold))
|
||||
console.SetColor("DiskFailed", color.New(color.FgRed, color.Bold))
|
||||
console.SetColor("NodeFailed", color.New(color.FgRed, color.Bold))
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
adminClnt, err := newAdminClient(aliasedURL)
|
||||
if err != nil {
|
||||
fatalIf(err.Trace(aliasedURL), "Unable to initialize admin client.")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Compute bucket and object from the aliased URL
|
||||
aliasedURL = filepath.ToSlash(aliasedURL)
|
||||
splits := splitStr(aliasedURL, "/", 3)
|
||||
bucket, prefix := splits[1], splits[2]
|
||||
|
||||
clnt, err := newClient(aliasedURL)
|
||||
if err != nil {
|
||||
fatalIf(err.Trace(clnt.GetURL().String()), "Unable to create client for URL ", aliasedURL)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Return the background heal status when the user
|
||||
// doesn't pass a bucket or --recursive flag.
|
||||
if bucket == "" && !ctx.Bool("recursive") {
|
||||
bgHealStatus, berr := adminClnt.BackgroundHealStatus(globalContext)
|
||||
fatalIf(probe.NewError(berr), "Failed to get the status of the background heal.")
|
||||
if ctx.Bool("verbose") {
|
||||
printMsg(verboseBackgroundHealStatusMessage{
|
||||
Status: "success",
|
||||
HealInfo: bgHealStatus,
|
||||
ToleranceForSC: strings.ToUpper(ctx.String("storage-class")),
|
||||
})
|
||||
} else {
|
||||
printMsg(shortBackgroundHealStatusMessage{
|
||||
Status: "success",
|
||||
HealInfo: bgHealStatus,
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
for content := range clnt.List(globalContext, ListOptions{Recursive: false, ShowDir: DirNone}) {
|
||||
if content.Err != nil {
|
||||
fatalIf(content.Err.Trace(clnt.GetURL().String()), "Unable to heal bucket `"+bucket+"`.")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
opts := madmin.HealOpts{
|
||||
ScanMode: transformScanArg(ctx.String("scan")),
|
||||
Remove: ctx.Bool("remove"),
|
||||
Recursive: ctx.Bool("recursive"),
|
||||
DryRun: ctx.Bool("dry-run"),
|
||||
}
|
||||
|
||||
forceStart := ctx.Bool("force-start")
|
||||
forceStop := ctx.Bool("force-stop")
|
||||
if forceStop {
|
||||
_, _, herr := adminClnt.Heal(globalContext, bucket, prefix, opts, "", forceStart, forceStop)
|
||||
fatalIf(probe.NewError(herr), "Failed to stop heal sequence.")
|
||||
printMsg(stopHealMessage{Status: "success", Alias: aliasedURL})
|
||||
return nil
|
||||
}
|
||||
|
||||
healStart, _, herr := adminClnt.Heal(globalContext, bucket, prefix, opts, "", forceStart, false)
|
||||
fatalIf(probe.NewError(herr), "Failed to start heal sequence.")
|
||||
|
||||
ui := uiData{
|
||||
Bucket: bucket,
|
||||
Prefix: prefix,
|
||||
Client: adminClnt,
|
||||
ClientToken: healStart.ClientToken,
|
||||
ForceStart: forceStart,
|
||||
HealOpts: &opts,
|
||||
ObjectsByOnlineDrives: make(map[int]int64),
|
||||
HealthCols: make(map[col]int64),
|
||||
CurChan: cursorAnimate(),
|
||||
}
|
||||
|
||||
res, e := ui.DisplayAndFollowHealStatus(aliasedURL)
|
||||
if e != nil {
|
||||
if res.FailureDetail != "" {
|
||||
data, _ := json.MarshalIndent(res, "", " ")
|
||||
traceStr := string(data)
|
||||
fatalIf(probe.NewError(e).Trace(aliasedURL, traceStr), "Unable to display heal status.")
|
||||
} else {
|
||||
fatalIf(probe.NewError(e).Trace(aliasedURL), "Unable to display heal status.")
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
humanize "github.com/dustin/go-humanize"
|
||||
"github.com/dustin/go-humanize/english"
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminInfoCmd = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "display MinIO server information",
|
||||
Action: mainAdminInfo,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Get server information of the 'play' MinIO server.
|
||||
{{.Prompt}} {{.HelpName}} play/
|
||||
`,
|
||||
}
|
||||
|
||||
// Wrap "Info" message together with fields "Status" and "Error"
|
||||
type clusterStruct struct {
|
||||
Status string `json:"status"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Info madmin.InfoMessage `json:"info,omitempty"`
|
||||
}
|
||||
|
||||
// String provides colorized info messages depending on the type of a server
|
||||
// FS server non-FS server
|
||||
// ============================== ===================================
|
||||
// ● <ip>:<port> ● <ip>:<port>
|
||||
// Uptime: xxx Uptime: xxx
|
||||
// Version: xxx Version: xxx
|
||||
// Network: X/Y OK Network: X/Y OK
|
||||
//
|
||||
// U Used, B Buckets, O Objects Drives: N/N OK
|
||||
//
|
||||
// U Used, B Buckets, O Objects
|
||||
// N drives online, K drives offline
|
||||
//
|
||||
func (u clusterStruct) String() (msg string) {
|
||||
// Check cluster level "Status" field for error
|
||||
if u.Status == "error" {
|
||||
fatal(probe.NewError(errors.New(u.Error)), "Unable to get service status")
|
||||
}
|
||||
|
||||
// If nothing has been collected, error out
|
||||
if u.Info.Servers == nil {
|
||||
fatal(probe.NewError(errors.New("Unable to get service status")), "")
|
||||
}
|
||||
|
||||
// Initialization
|
||||
var totalOnlineDisksCluster int
|
||||
var totalOfflineDisksCluster int
|
||||
|
||||
// Color palette initialization
|
||||
console.SetColor("Info", color.New(color.FgGreen, color.Bold))
|
||||
console.SetColor("InfoFail", color.New(color.FgRed, color.Bold))
|
||||
console.SetColor("InfoWarning", color.New(color.FgYellow, color.Bold))
|
||||
|
||||
// MinIO server type default
|
||||
backendType := madmin.Unknown
|
||||
|
||||
// Set the type of MinIO server ("FS", "Erasure", "Unknown")
|
||||
switch v := u.Info.Backend.(type) {
|
||||
case madmin.FSBackend:
|
||||
backendType = madmin.FS
|
||||
case madmin.ErasureBackend:
|
||||
backendType = madmin.Erasure
|
||||
case map[string]interface{}:
|
||||
vt, ok := v["backendType"]
|
||||
if ok {
|
||||
backendTypeS, _ := vt.(string)
|
||||
switch backendTypeS {
|
||||
case "Erasure":
|
||||
backendType = madmin.Erasure
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
coloredDot := console.Colorize("Info", dot)
|
||||
if madmin.ItemState(u.Info.Mode) == madmin.ItemInitializing {
|
||||
coloredDot = console.Colorize("InfoWarning", dot)
|
||||
}
|
||||
|
||||
sort.Slice(u.Info.Servers, func(i, j int) bool {
|
||||
return u.Info.Servers[i].Endpoint < u.Info.Servers[j].Endpoint
|
||||
})
|
||||
|
||||
poolIdx := -1
|
||||
// Loop through each server and put together info for each one
|
||||
for _, srv := range u.Info.Servers {
|
||||
// Check if MinIO server is offline ("Mode" field),
|
||||
// If offline, error out
|
||||
if srv.State == "offline" {
|
||||
// "PrintB" is color blue in console library package
|
||||
msg += fmt.Sprintf("%s %s\n", console.Colorize("InfoFail", dot), console.Colorize("PrintB", srv.Endpoint))
|
||||
msg += fmt.Sprintf(" Uptime: %s\n", console.Colorize("InfoFail", "offline"))
|
||||
|
||||
if backendType == madmin.Erasure {
|
||||
// Info about drives on a server, only available for non-FS types
|
||||
var OffDisks int
|
||||
var OnDisks int
|
||||
var dispNoOfDisks string
|
||||
for _, disk := range srv.Disks {
|
||||
switch disk.State {
|
||||
case madmin.DriveStateOk, madmin.DriveStateUnformatted:
|
||||
OnDisks++
|
||||
default:
|
||||
OffDisks++
|
||||
}
|
||||
}
|
||||
|
||||
totalDisksPerServer := OnDisks + OffDisks
|
||||
totalOnlineDisksCluster += OnDisks
|
||||
totalOfflineDisksCluster += OffDisks
|
||||
|
||||
dispNoOfDisks = strconv.Itoa(OnDisks) + "/" + strconv.Itoa(totalDisksPerServer)
|
||||
msg += fmt.Sprintf(" Drives: %s %s\n", dispNoOfDisks, console.Colorize("InfoFail", "OK "))
|
||||
}
|
||||
|
||||
msg += "\n"
|
||||
|
||||
// Continue to the next server
|
||||
continue
|
||||
}
|
||||
|
||||
// Print server title
|
||||
msg += fmt.Sprintf("%s %s\n", coloredDot, console.Colorize("PrintB", srv.Endpoint))
|
||||
|
||||
// Uptime
|
||||
msg += fmt.Sprintf(" Uptime: %s\n", console.Colorize("Info",
|
||||
humanize.RelTime(time.Now(), time.Now().Add(time.Duration(srv.Uptime)*time.Second), "", "")))
|
||||
|
||||
// Version
|
||||
version := srv.Version
|
||||
if srv.Version == "DEVELOPMENT.GOGET" {
|
||||
version = "<development>"
|
||||
}
|
||||
msg += fmt.Sprintf(" Version: %s\n", version)
|
||||
// Network info, only available for non-FS types
|
||||
connectionAlive := 0
|
||||
totalNodes := len(srv.Network)
|
||||
if srv.Network != nil && backendType == madmin.Erasure {
|
||||
for _, v := range srv.Network {
|
||||
if v == "online" {
|
||||
connectionAlive++
|
||||
}
|
||||
}
|
||||
clr := "Info"
|
||||
if connectionAlive != totalNodes {
|
||||
clr = "InfoWarning"
|
||||
}
|
||||
displayNwInfo := strconv.Itoa(connectionAlive) + "/" + strconv.Itoa(totalNodes)
|
||||
msg += fmt.Sprintf(" Network: %s %s\n", displayNwInfo, console.Colorize(clr, "OK "))
|
||||
}
|
||||
|
||||
if backendType == madmin.Erasure {
|
||||
// Info about drives on a server, only available for non-FS types
|
||||
var OffDisks int
|
||||
var OnDisks int
|
||||
var dispNoOfDisks string
|
||||
for _, disk := range srv.Disks {
|
||||
if poolIdx == -1 {
|
||||
poolIdx = disk.PoolIndex
|
||||
}
|
||||
switch disk.State {
|
||||
case madmin.DriveStateOk, madmin.DriveStateUnformatted:
|
||||
OnDisks++
|
||||
default:
|
||||
OffDisks++
|
||||
}
|
||||
}
|
||||
|
||||
totalDisksPerServer := OnDisks + OffDisks
|
||||
totalOnlineDisksCluster += OnDisks
|
||||
totalOfflineDisksCluster += OffDisks
|
||||
clr := "Info"
|
||||
if OnDisks != totalDisksPerServer {
|
||||
clr = "InfoWarning"
|
||||
}
|
||||
dispNoOfDisks = strconv.Itoa(OnDisks) + "/" + strconv.Itoa(totalDisksPerServer)
|
||||
msg += fmt.Sprintf(" Drives: %s %s\n", dispNoOfDisks, console.Colorize(clr, "OK "))
|
||||
}
|
||||
|
||||
if poolIdx != -1 {
|
||||
msg += fmt.Sprintf(" Pool: %s\n", console.Colorize("Info", humanize.Ordinal(poolIdx+1)))
|
||||
}
|
||||
msg += "\n"
|
||||
|
||||
poolIdx = -1
|
||||
}
|
||||
|
||||
// Summary on used space, total no of buckets and
|
||||
// total no of objects at the Cluster level
|
||||
usedTotal := humanize.IBytes(u.Info.Usage.Size)
|
||||
if u.Info.Buckets.Count > 0 {
|
||||
msg += fmt.Sprintf("%s Used, %s, %s", usedTotal,
|
||||
english.Plural(int(u.Info.Buckets.Count), "Bucket", ""),
|
||||
english.Plural(int(u.Info.Objects.Count), "Object", ""))
|
||||
if u.Info.Versions.Count > 0 {
|
||||
msg += ", " + english.Plural(int(u.Info.Versions.Count), "Version", "")
|
||||
}
|
||||
msg += "\n"
|
||||
}
|
||||
if backendType == madmin.Erasure {
|
||||
// Summary on total no of online and total
|
||||
// number of offline disks at the Cluster level
|
||||
bkInfo, ok := u.Info.Backend.(madmin.ErasureBackend)
|
||||
if ok {
|
||||
msg += fmt.Sprintf("%s online, %s offline\n",
|
||||
english.Plural(bkInfo.OnlineDisks, "drive", ""),
|
||||
english.Plural(bkInfo.OfflineDisks, "drive", ""))
|
||||
} else {
|
||||
msg += fmt.Sprintf("%s online, %s offline\n",
|
||||
english.Plural(totalOnlineDisksCluster, "drive", ""),
|
||||
english.Plural(totalOfflineDisksCluster, "drive", ""))
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the last new line if any
|
||||
// since this is a String() function
|
||||
msg = strings.TrimSuffix(msg, "\n")
|
||||
return
|
||||
}
|
||||
|
||||
// JSON jsonifies service status message.
|
||||
func (u clusterStruct) JSON() string {
|
||||
statusJSONBytes, e := json.MarshalIndent(u, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(statusJSONBytes)
|
||||
}
|
||||
|
||||
// checkAdminInfoSyntax - validate arguments passed by a user
|
||||
func checkAdminInfoSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) == 0 || len(ctx.Args()) > 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "info", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func mainAdminInfo(ctx *cli.Context) error {
|
||||
checkAdminInfoSyntax(ctx)
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
var clusterInfo clusterStruct
|
||||
// Fetch info of all servers (cluster or single server)
|
||||
admInfo, e := client.ServerInfo(globalContext)
|
||||
if e != nil {
|
||||
clusterInfo.Status = "error"
|
||||
clusterInfo.Error = e.Error()
|
||||
} else {
|
||||
clusterInfo.Status = "success"
|
||||
clusterInfo.Error = ""
|
||||
}
|
||||
clusterInfo.Info = admInfo
|
||||
printMsg(clusterInfo)
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2015-2021 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"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminInspectCmd = cli.Command{
|
||||
Name: "inspect",
|
||||
Usage: "inspect files on MinIO server",
|
||||
Action: mainAdminInspect,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
HideHelpCommand: true,
|
||||
Hidden: true,
|
||||
CustomHelpTemplate: "Please use 'mc support inspect'",
|
||||
}
|
||||
|
||||
// mainAdminHeal - the entry function of heal command
|
||||
func mainAdminInspect(ctx *cli.Context) error {
|
||||
console.Infoln("Please use 'mc support inspect'")
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
)
|
||||
|
||||
var adminKMSCreateKeyCmd = cli.Command{
|
||||
Name: "create",
|
||||
Usage: "creates a new master key at the KMS",
|
||||
Action: mainAdminKMSCreateKey,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET [KEY_NAME]
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Create a new master key named 'my-key' default master key.
|
||||
$ {{.HelpName}} play my-key
|
||||
`,
|
||||
}
|
||||
|
||||
// adminKMSCreateKeyCmd is the handler for the "mc admin kms key create" command.
|
||||
func mainAdminKMSCreateKey(ctx *cli.Context) error {
|
||||
if len(ctx.Args()) != 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "create", 1) // last argument is exit code
|
||||
}
|
||||
|
||||
client, err := newAdminClient(ctx.Args().Get(0))
|
||||
fatalIf(err, "Cannot get a configured admin connection.")
|
||||
|
||||
keyID := ctx.Args().Get(1)
|
||||
e := client.CreateKey(globalContext, keyID)
|
||||
fatalIf(probe.NewError(e), "Failed to create master key")
|
||||
|
||||
if terminal.IsTerminal(int(os.Stdout.Fd())) {
|
||||
console.Println(color.GreenString(fmt.Sprintf("Created master key `%s` successfully", keyID)))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminKMSKeyStatusCmd = cli.Command{
|
||||
Name: "status",
|
||||
Usage: "request status information for a KMS master key",
|
||||
Action: mainAdminKMSKeyStatus,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET [KEY_NAME]
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Get default master key and its status from a MinIO server/cluster.
|
||||
$ {{.HelpName}} play
|
||||
2. Get the status of one particular master key from a MinIO server/cluster.
|
||||
$ {{.HelpName}} play my-master-key
|
||||
`,
|
||||
}
|
||||
|
||||
// adminKMSKeyCmd is the handle for the "mc admin kms key" command.
|
||||
func mainAdminKMSKeyStatus(ctx *cli.Context) error {
|
||||
if len(ctx.Args()) == 0 || len(ctx.Args()) > 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "status", 1) // last argument is exit code
|
||||
}
|
||||
|
||||
console.SetColor("StatusSuccess", color.New(color.FgGreen, color.Bold))
|
||||
console.SetColor("StatusError", color.New(color.FgRed, color.Bold))
|
||||
|
||||
client, err := newAdminClient(ctx.Args().Get(0))
|
||||
fatalIf(err, "Unable to get a configured admin connection.")
|
||||
|
||||
var keyID string
|
||||
if len(ctx.Args()) == 2 {
|
||||
keyID = ctx.Args().Get(1)
|
||||
}
|
||||
status, e := client.GetKeyStatus(globalContext, keyID)
|
||||
fatalIf(probe.NewError(e), "Failed to get status information")
|
||||
|
||||
printMsg(kmsKeyStatusMsg{
|
||||
KeyID: status.KeyID,
|
||||
Encryption: status.EncryptionErr == "",
|
||||
Decryption: status.DecryptionErr == "",
|
||||
EncryptionErr: status.EncryptionErr,
|
||||
DecryptionErr: status.DecryptionErr,
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
||||
type kmsKeyStatusMsg struct {
|
||||
KeyID string `json:"keyId"`
|
||||
Encryption bool `json:"encryption"`
|
||||
Decryption bool `json:"decryption"`
|
||||
EncryptionErr string `json:"encryptionError,omitempty"`
|
||||
DecryptionErr string `json:"decryptionError,omitempty"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
func (s kmsKeyStatusMsg) JSON() string {
|
||||
s.Status = "success"
|
||||
if !s.Encryption && !s.Decryption {
|
||||
s.Status = "error"
|
||||
}
|
||||
kmsBytes, e := json.MarshalIndent(s, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(kmsBytes)
|
||||
}
|
||||
|
||||
func (s kmsKeyStatusMsg) String() string {
|
||||
msg := fmt.Sprintf("Key: %s\n", s.KeyID)
|
||||
if s.Encryption {
|
||||
msg += " - Encryption " + console.Colorize("StatusSuccess", "✔") + "\n"
|
||||
} else {
|
||||
msg += fmt.Sprintf(" - Encryption %s (%s)\n", console.Colorize("StatusError", "✗"), s.EncryptionErr)
|
||||
}
|
||||
|
||||
if s.Decryption {
|
||||
msg += " - Decryption " + console.Colorize("StatusSuccess", "✔") + "\n"
|
||||
} else {
|
||||
msg += fmt.Sprintf(" - Decryption %s (%s)\n", console.Colorize("StatusError", "✗"), s.DecryptionErr)
|
||||
}
|
||||
return msg
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) 2015-2021 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 adminKMSKeySubcommands = []cli.Command{
|
||||
adminKMSCreateKeyCmd,
|
||||
adminKMSKeyStatusCmd,
|
||||
}
|
||||
|
||||
var adminKMSKeyCmd = cli.Command{
|
||||
Name: "key",
|
||||
Usage: "manage KMS master keys: Request key status information",
|
||||
Action: mainAdminKMSKey,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: adminKMSKeySubcommands,
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
// mainAdminKMSKey is the handle for the "mc admin kms key" command.
|
||||
func mainAdminKMSKey(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminKMSKeySubcommands)
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2015-2021 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 adminKMSSubcommands = []cli.Command{
|
||||
adminKMSKeyCmd,
|
||||
}
|
||||
|
||||
var adminKMSCmd = cli.Command{
|
||||
Name: "kms",
|
||||
Usage: "perform KMS management operations",
|
||||
Action: mainAdminKMS,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: adminKMSSubcommands,
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
// mainAdminKMS is the handle for the "mc admin kms" command.
|
||||
func mainAdminKMS(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminKMSSubcommands)
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
// Copyright (c) 2015-2021 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 adminFlags = []cli.Flag{}
|
||||
|
||||
const (
|
||||
// dot represents a list item, for eg. server status - online (green) or offline (red)
|
||||
dot = "●"
|
||||
// check represents successful operation
|
||||
check = "✔"
|
||||
)
|
||||
|
||||
var adminCmdSubcommands = []cli.Command{
|
||||
adminServiceCmd,
|
||||
adminServerUpdateCmd,
|
||||
adminInfoCmd,
|
||||
adminInspectCmd,
|
||||
adminUserCmd,
|
||||
adminGroupCmd,
|
||||
adminPolicyCmd,
|
||||
adminReplicateCmd,
|
||||
adminConfigCmd,
|
||||
adminDecommissionCmd,
|
||||
adminHealCmd,
|
||||
adminPrometheusCmd,
|
||||
adminKMSCmd,
|
||||
adminHealthCmd(),
|
||||
adminSubnetCmd,
|
||||
adminBucketCmd,
|
||||
adminTierCmd,
|
||||
adminSpeedtestCmd,
|
||||
adminProfileCmd,
|
||||
adminTopCmd,
|
||||
adminTraceCmd,
|
||||
adminConsoleCmd,
|
||||
adminClusterCmd,
|
||||
}
|
||||
|
||||
var adminCmd = cli.Command{
|
||||
Name: "admin",
|
||||
Usage: "manage MinIO servers",
|
||||
Action: mainAdmin,
|
||||
Subcommands: adminCmdSubcommands,
|
||||
HideHelpCommand: true,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(adminFlags, globalFlags...),
|
||||
}
|
||||
|
||||
const dateTimeFormatFilename = "2006-01-02T15-04-05.999999-07-00"
|
||||
|
||||
// mainAdmin is the handle for "mc admin" command.
|
||||
func mainAdmin(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminCmdSubcommands)
|
||||
return nil
|
||||
// Sub-commands like "service", "heal", "top" have their own main.
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminPolicyAddCmd = cli.Command{
|
||||
Name: "add",
|
||||
Usage: "add new policy",
|
||||
Action: mainAdminPolicyAdd,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET POLICYNAME POLICYFILE
|
||||
|
||||
POLICYNAME:
|
||||
Name of the canned policy on MinIO server.
|
||||
|
||||
POLICYFILE:
|
||||
Name of the policy file associated with the policy name.
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Add a new canned policy 'writeonly'.
|
||||
{{.Prompt}} {{.HelpName}} myminio writeonly /tmp/writeonly.json
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminPolicyAddSyntax - validate all the passed arguments
|
||||
func checkAdminPolicyAddSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 3 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "add", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// userPolicyMessage container for content message structure
|
||||
type userPolicyMessage struct {
|
||||
op string
|
||||
Status string `json:"status"`
|
||||
Policy string `json:"policy,omitempty"`
|
||||
PolicyInfo madmin.PolicyInfo `json:"policyInfo,omitempty"`
|
||||
UserOrGroup string `json:"userOrGroup,omitempty"`
|
||||
IsGroup bool `json:"isGroup"`
|
||||
}
|
||||
|
||||
func (u userPolicyMessage) accountType() string {
|
||||
switch u.op {
|
||||
case "set", "unset", "update":
|
||||
if u.IsGroup {
|
||||
return "group"
|
||||
}
|
||||
return "user"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (u userPolicyMessage) String() string {
|
||||
switch u.op {
|
||||
case "info":
|
||||
buf, e := json.MarshalIndent(u.PolicyInfo, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal to JSON.")
|
||||
return string(buf)
|
||||
case "list":
|
||||
policyFieldMaxLen := 20
|
||||
// Create a new pretty table with cols configuration
|
||||
return newPrettyTable(" ",
|
||||
Field{"Policy", policyFieldMaxLen},
|
||||
).buildRow(u.Policy)
|
||||
case "remove":
|
||||
return console.Colorize("PolicyMessage", "Removed policy `"+u.Policy+"` successfully.")
|
||||
case "add":
|
||||
return console.Colorize("PolicyMessage", "Added policy `"+u.Policy+"` successfully.")
|
||||
case "set", "unset":
|
||||
return console.Colorize("PolicyMessage",
|
||||
fmt.Sprintf("Policy `%s` is %s on %s `%s`", u.Policy, u.op, u.accountType(), u.UserOrGroup))
|
||||
case "update":
|
||||
return console.Colorize("PolicyMessage",
|
||||
fmt.Sprintf("Policy `%s` is added to %s `%s`", u.Policy, u.accountType(), u.UserOrGroup))
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
func (u userPolicyMessage) JSON() string {
|
||||
u.Status = "success"
|
||||
jsonMessageBytes, e := json.MarshalIndent(u, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
|
||||
return string(jsonMessageBytes)
|
||||
}
|
||||
|
||||
// mainAdminPolicyAdd is the handle for "mc admin policy add" command.
|
||||
func mainAdminPolicyAdd(ctx *cli.Context) error {
|
||||
checkAdminPolicyAddSyntax(ctx)
|
||||
|
||||
console.SetColor("PolicyMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
policy, e := ioutil.ReadFile(args.Get(2))
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get policy")
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
fatalIf(probe.NewError(client.AddCannedPolicy(globalContext, args.Get(1), policy)).Trace(args...), "Unable to add new policy")
|
||||
|
||||
printMsg(userPolicyMessage{
|
||||
op: "add",
|
||||
Policy: args.Get(1),
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"os"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var policyInfoFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "policy-file, f",
|
||||
Usage: "additionally (over-)write policy JSON to given file",
|
||||
},
|
||||
}
|
||||
|
||||
var adminPolicyInfoCmd = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "show info on a policy",
|
||||
Action: mainAdminPolicyInfo,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(policyInfoFlags, globalFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET POLICYNAME [OPTIONS...]
|
||||
|
||||
POLICYNAME:
|
||||
Name of the policy on the MinIO server.
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Show information on a given policy.
|
||||
{{.Prompt}} {{.HelpName}} myminio writeonly
|
||||
|
||||
2. Show information on a given policy and write the policy JSON content to /tmp/policy.json.
|
||||
{{.Prompt}} {{.HelpName}} myminio writeonly --policy-file /tmp/policy.json
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminPolicyInfoSyntax - validate all the passed arguments
|
||||
func checkAdminPolicyInfoSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "info", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func getPolicyInfo(client *madmin.AdminClient, policyName string) (*madmin.PolicyInfo, error) {
|
||||
pinfo, e := client.InfoCannedPolicyV2(globalContext, policyName)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
|
||||
if pinfo.PolicyName == "" {
|
||||
// Likely server only supports the older version.
|
||||
pinfo.Policy, e = client.InfoCannedPolicy(globalContext, policyName)
|
||||
if e != nil {
|
||||
return nil, e
|
||||
}
|
||||
pinfo.PolicyName = policyName
|
||||
}
|
||||
return pinfo, nil
|
||||
}
|
||||
|
||||
// mainAdminPolicyInfo is the handler for "mc admin policy info" command.
|
||||
func mainAdminPolicyInfo(ctx *cli.Context) error {
|
||||
checkAdminPolicyInfoSyntax(ctx)
|
||||
|
||||
console.SetColor("PolicyMessage", color.New(color.FgGreen))
|
||||
console.SetColor("Policy", color.New(color.FgBlue))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
policyName := args.Get(1)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection")
|
||||
|
||||
pinfo, e := getPolicyInfo(client, policyName)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to fetch policy")
|
||||
|
||||
policyFile := ctx.String("policy-file")
|
||||
if policyFile != "" {
|
||||
f, err := os.Create(policyFile)
|
||||
if err != nil {
|
||||
fatalIf(probe.NewError(err).Trace(args...), "Could not open given policy file")
|
||||
}
|
||||
_, err = f.Write(pinfo.Policy)
|
||||
if err != nil {
|
||||
fatalIf(probe.NewError(err).Trace(args...), "Could not write to given policy file")
|
||||
}
|
||||
}
|
||||
|
||||
printMsg(userPolicyMessage{
|
||||
op: "info",
|
||||
Policy: policyName,
|
||||
PolicyInfo: *pinfo,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// Copyright (c) 2015-2021 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/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminPolicyListCmd = cli.Command{
|
||||
Name: "list",
|
||||
Usage: "list all policies",
|
||||
Action: mainAdminPolicyList,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. List all policies on MinIO server.
|
||||
{{.Prompt}} {{.HelpName}} myminio
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminPolicyListSyntax - validate all the passed arguments
|
||||
func checkAdminPolicyListSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "list", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminPolicyList is the handle for "mc admin policy add" command.
|
||||
func mainAdminPolicyList(ctx *cli.Context) error {
|
||||
checkAdminPolicyListSyntax(ctx)
|
||||
|
||||
console.SetColor("PolicyMessage", color.New(color.FgGreen))
|
||||
console.SetColor("Policy", color.New(color.FgBlue))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
policies, e := client.ListCannedPolicies(globalContext)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to list policy")
|
||||
|
||||
for k := range policies {
|
||||
printMsg(userPolicyMessage{
|
||||
op: "list",
|
||||
Policy: k,
|
||||
})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// Copyright (c) 2015-2021 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/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminPolicyRemoveCmd = cli.Command{
|
||||
Name: "remove",
|
||||
Usage: "remove policy",
|
||||
Action: mainAdminPolicyRemove,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET POLICYNAME
|
||||
|
||||
POLICYNAME:
|
||||
Name of the canned policy on MinIO server.
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Remove 'writeonly' policy on MinIO server.
|
||||
{{.Prompt}} {{.HelpName}} myminio writeonly
|
||||
`,
|
||||
}
|
||||
|
||||
// checkAdminPolicyRemoveSyntax - validate all the passed arguments
|
||||
func checkAdminPolicyRemoveSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "remove", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
// mainAdminPolicyRemove is the handle for "mc admin policy remove" command.
|
||||
func mainAdminPolicyRemove(ctx *cli.Context) error {
|
||||
checkAdminPolicyRemoveSyntax(ctx)
|
||||
|
||||
console.SetColor("PolicyMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
fatalIf(probe.NewError(client.RemoveCannedPolicy(globalContext, args.Get(1))).Trace(args...), "Unable to remove policy")
|
||||
|
||||
printMsg(userPolicyMessage{
|
||||
op: "remove",
|
||||
Policy: args.Get(1),
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminPolicySetCmd = cli.Command{
|
||||
Name: "set",
|
||||
Usage: "set IAM policy on a user or group",
|
||||
Action: mainAdminPolicySet,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET POLICYNAME [ user=username1 | group=groupname1 ]
|
||||
|
||||
POLICYNAME:
|
||||
Name of the policy on the MinIO server. To set multiple policies, separate names with a comma (,).
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Set the "readwrite" policy for user "james".
|
||||
{{.Prompt}} {{.HelpName}} myminio readwrite user=james
|
||||
|
||||
2. Set the "readonly" policy for group "auditors".
|
||||
{{.Prompt}} {{.HelpName}} myminio readonly group=auditors
|
||||
|
||||
3. Set the "readonly" and the "diagnostics" policies for user "alice"
|
||||
{{.Prompt}} {{.HelpName}} myminio readonly,diagnostics user=alice
|
||||
`,
|
||||
}
|
||||
|
||||
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 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "set", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func parseEntityArg(arg string) (userOrGroup string, isGroup bool, err error) {
|
||||
parts := strings.SplitN(arg, "=", 2)
|
||||
switch {
|
||||
case len(parts) != 2 || parts[1] == "":
|
||||
err = errBadUserGroupArg
|
||||
case strings.ToLower(parts[0]) == "user":
|
||||
userOrGroup = parts[1]
|
||||
isGroup = false
|
||||
case strings.ToLower(parts[0]) == "group":
|
||||
userOrGroup = parts[1]
|
||||
isGroup = true
|
||||
default:
|
||||
err = errBadUserGroupArg
|
||||
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// mainAdminPolicySet is the handler for "mc admin policy set" command.
|
||||
func mainAdminPolicySet(ctx *cli.Context) error {
|
||||
checkAdminPolicySetSyntax(ctx)
|
||||
|
||||
console.SetColor("PolicyMessage", color.New(color.FgGreen))
|
||||
console.SetColor("Policy", color.New(color.FgBlue))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
policyName := strings.TrimSpace(args.Get(1))
|
||||
entityArg := args.Get(2)
|
||||
|
||||
userOrGroup, isGroup, e1 := parseEntityArg(entityArg)
|
||||
fatalIf(probe.NewError(e1).Trace(args...), "Bad last argument")
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
e := client.SetPolicy(globalContext, policyName, userOrGroup, isGroup)
|
||||
if e == nil {
|
||||
printMsg(userPolicyMessage{
|
||||
op: "set",
|
||||
Policy: policyName,
|
||||
UserOrGroup: userOrGroup,
|
||||
IsGroup: isGroup,
|
||||
})
|
||||
} else {
|
||||
fatalIf(probe.NewError(e), "Unable to set the policy")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminPolicyUnsetCmd = cli.Command{
|
||||
Name: "unset",
|
||||
Usage: "unset an IAM policy for a user or group",
|
||||
Action: mainAdminPolicyUnset,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET POLICYNAME [ user=username1 | group=groupname1 ]
|
||||
|
||||
POLICYNAME:
|
||||
Name of the policy on the MinIO server.
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Unset the "diagnostics" policy for user "james".
|
||||
{{.Prompt}} {{.HelpName}} myminio diagnostics user=james
|
||||
|
||||
2. Set the "diagnostics" policy for group "auditors".
|
||||
{{.Prompt}} {{.HelpName}} myminio diagnostics group=auditors
|
||||
`,
|
||||
}
|
||||
|
||||
func checkAdminPolicyUnsetSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 3 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "unset", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func removeCannedPolicies(existingPolicies, policiesToRemove string) (string, error) {
|
||||
policiesToRemove = strings.TrimSpace(policiesToRemove)
|
||||
if policiesToRemove == "" {
|
||||
return "", errors.New("empty policy name is not supported")
|
||||
}
|
||||
filteredPolicies := strings.Split(existingPolicies, ",")
|
||||
for _, p1 := range strings.Split(policiesToRemove, ",") {
|
||||
found := false
|
||||
for i, p2 := range filteredPolicies {
|
||||
if p1 == p2 {
|
||||
found = true
|
||||
filteredPolicies = append(filteredPolicies[:i], filteredPolicies[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
return "", fmt.Errorf("policy `%s` not found", p1)
|
||||
}
|
||||
|
||||
}
|
||||
return strings.Join(filteredPolicies, ","), nil
|
||||
}
|
||||
|
||||
// mainAdminPolicyUnset is the handler for "mc admin policy unset" command.
|
||||
func mainAdminPolicyUnset(ctx *cli.Context) error {
|
||||
checkAdminPolicyUnsetSyntax(ctx)
|
||||
|
||||
console.SetColor("PolicyMessage", color.New(color.FgGreen))
|
||||
console.SetColor("Policy", color.New(color.FgBlue))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
policiesToUnset := args.Get(1)
|
||||
entityArg := args.Get(2)
|
||||
|
||||
userOrGroup, isGroup, e1 := parseEntityArg(entityArg)
|
||||
fatalIf(probe.NewError(e1).Trace(args...), "Bad last argument")
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
var existingPolicies string
|
||||
|
||||
if !isGroup {
|
||||
userInfo, e := client.GetUserInfo(globalContext, userOrGroup)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get user policy info")
|
||||
existingPolicies = userInfo.PolicyName
|
||||
} else {
|
||||
groupInfo, e := client.GetGroupDescription(globalContext, userOrGroup)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get group policy info")
|
||||
existingPolicies = groupInfo.Policy
|
||||
}
|
||||
|
||||
newPolicies, e := removeCannedPolicies(existingPolicies, policiesToUnset)
|
||||
if e != nil {
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to unset the policy")
|
||||
}
|
||||
|
||||
e = client.SetPolicy(globalContext, newPolicies, userOrGroup, isGroup)
|
||||
if e == nil {
|
||||
printMsg(userPolicyMessage{
|
||||
op: "unset",
|
||||
Policy: policiesToUnset,
|
||||
UserOrGroup: userOrGroup,
|
||||
IsGroup: isGroup,
|
||||
})
|
||||
} else {
|
||||
fatalIf(probe.NewError(e), "Unable to unset the policy")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminPolicyUpdateCmd = cli.Command{
|
||||
Name: "update",
|
||||
Usage: "attach a new IAM policy to user or group",
|
||||
Action: mainAdminPolicyUpdate,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET POLICYNAME [ user=username1 | group=groupname1 ]
|
||||
|
||||
POLICYNAME:
|
||||
Name of the policy on the MinIO server.
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Add the "diagnostics" policy for user "james".
|
||||
{{.Prompt}} {{.HelpName}} myminio diagnostics user=james
|
||||
|
||||
2. Add the "diagnostics" policy for group "auditors".
|
||||
{{.Prompt}} {{.HelpName}} myminio diagnostics group=auditors
|
||||
`,
|
||||
}
|
||||
|
||||
func checkAdminPolicyUpdateSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 3 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "update", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func updateCannedPolicies(existingPolicies, policiesToAdd string) (string, error) {
|
||||
policiesToAdd = strings.TrimSpace(policiesToAdd)
|
||||
if policiesToAdd == "" {
|
||||
return "", errors.New("empty policy name is unsupported")
|
||||
}
|
||||
var updatedPolicies []string
|
||||
if existingPolicies != "" {
|
||||
updatedPolicies = strings.Split(existingPolicies, ",")
|
||||
}
|
||||
|
||||
for _, p1 := range strings.Split(policiesToAdd, ",") {
|
||||
found := false
|
||||
p1 = strings.TrimSpace(p1)
|
||||
for _, p2 := range updatedPolicies {
|
||||
if p1 == p2 {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if found {
|
||||
return "", fmt.Errorf("policy `%s` already exists", p1)
|
||||
}
|
||||
updatedPolicies = append(updatedPolicies, p1)
|
||||
}
|
||||
|
||||
return strings.Join(updatedPolicies, ","), nil
|
||||
}
|
||||
|
||||
// mainAdminPolicyUpdate is the handler for "mc admin policy update" command.
|
||||
func mainAdminPolicyUpdate(ctx *cli.Context) error {
|
||||
checkAdminPolicyUpdateSyntax(ctx)
|
||||
|
||||
console.SetColor("PolicyMessage", color.New(color.FgGreen))
|
||||
console.SetColor("Policy", color.New(color.FgBlue))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
policiesToAdd := args.Get(1)
|
||||
entityArg := args.Get(2)
|
||||
|
||||
userOrGroup, isGroup, e1 := parseEntityArg(entityArg)
|
||||
fatalIf(probe.NewError(e1).Trace(args...), "Bad last argument")
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
var existingPolicies string
|
||||
|
||||
if !isGroup {
|
||||
userInfo, e := client.GetUserInfo(globalContext, userOrGroup)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get user policy info")
|
||||
existingPolicies = userInfo.PolicyName
|
||||
} else {
|
||||
groupInfo, e := client.GetGroupDescription(globalContext, userOrGroup)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get group policy info")
|
||||
existingPolicies = groupInfo.Policy
|
||||
}
|
||||
|
||||
updatedPolicies, e := updateCannedPolicies(existingPolicies, policiesToAdd)
|
||||
if e != nil {
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to update the policy")
|
||||
}
|
||||
|
||||
e = client.SetPolicy(globalContext, updatedPolicies, userOrGroup, isGroup)
|
||||
if e == nil {
|
||||
printMsg(userPolicyMessage{
|
||||
op: "update",
|
||||
Policy: policiesToAdd,
|
||||
UserOrGroup: userOrGroup,
|
||||
IsGroup: isGroup,
|
||||
})
|
||||
} else {
|
||||
fatalIf(probe.NewError(e), "Unable to unset the policy")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright (c) 2015-2021 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 adminPolicySubcommands = []cli.Command{
|
||||
adminPolicyAddCmd,
|
||||
adminPolicyRemoveCmd,
|
||||
adminPolicyListCmd,
|
||||
adminPolicyInfoCmd,
|
||||
adminPolicySetCmd,
|
||||
adminPolicyUnsetCmd,
|
||||
adminPolicyUpdateCmd,
|
||||
}
|
||||
|
||||
var adminPolicyCmd = cli.Command{
|
||||
Name: "policy",
|
||||
Usage: "manage policies defined in the MinIO server",
|
||||
Action: mainAdminPolicy,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: adminPolicySubcommands,
|
||||
HideHelpCommand: true,
|
||||
}
|
||||
|
||||
// mainAdminPolicy is the handle for "mc admin policy" command.
|
||||
func mainAdminPolicy(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminPolicySubcommands)
|
||||
return nil
|
||||
// Sub-commands like "get", "set" have their own main.
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2015-2021 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"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminProfileStartCmd = cli.Command{
|
||||
Name: "start",
|
||||
Usage: "start recording profile data",
|
||||
Action: mainAdminProfileStart,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
HideHelpCommand: true,
|
||||
Hidden: true,
|
||||
CustomHelpTemplate: "Please use 'mc support profile start'",
|
||||
}
|
||||
|
||||
// mainAdminProfileStart - the entry function of profile command
|
||||
func mainAdminProfileStart(ctx *cli.Context) error {
|
||||
console.Infoln("Please use 'mc support profile start'")
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) 2015-2021 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"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminProfileStopCmd = cli.Command{
|
||||
Name: "stop",
|
||||
Usage: "stop and download profile data",
|
||||
Action: mainAdminProfileStop,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
HideHelpCommand: true,
|
||||
Hidden: true,
|
||||
CustomHelpTemplate: "Please use 'mc support profile stop'",
|
||||
}
|
||||
|
||||
// mainAdminProfileStop - the entry function of profile stop command
|
||||
func mainAdminProfileStop(ctx *cli.Context) error {
|
||||
console.Infoln("Please use 'mc support profile stop'")
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2015-2021 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"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminProfileSubcommands = []cli.Command{
|
||||
adminProfileStartCmd,
|
||||
adminProfileStopCmd,
|
||||
}
|
||||
|
||||
var adminProfileCmd = cli.Command{
|
||||
Name: "profile",
|
||||
Usage: "generate profile data for debugging purposes",
|
||||
Action: mainAdminProfile,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
Subcommands: adminProfileSubcommands,
|
||||
HideHelpCommand: true,
|
||||
Hidden: true,
|
||||
}
|
||||
|
||||
// mainAdminProfile is the handle for "mc admin profile" command.
|
||||
func mainAdminProfile(ctx *cli.Context) error {
|
||||
console.Infoln("Please use 'mc support profile'")
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
|
||||
json "github.com/minio/colorjson"
|
||||
yaml "gopkg.in/yaml.v2"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultJobName = "minio-job"
|
||||
defaultMetricsPath = "/minio/v2/metrics/cluster"
|
||||
)
|
||||
|
||||
var prometheusFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "public",
|
||||
Usage: "disable bearer token generation for scrape_configs",
|
||||
},
|
||||
}
|
||||
|
||||
var adminPrometheusGenerateCmd = cli.Command{
|
||||
Name: "generate",
|
||||
Usage: "generates prometheus config",
|
||||
Action: mainAdminPrometheusGenerate,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(prometheusFlags, globalFlags...),
|
||||
HideHelpCommand: true,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. Generate a default prometheus config.
|
||||
{{.Prompt}} {{.HelpName}} myminio
|
||||
|
||||
`,
|
||||
}
|
||||
|
||||
// PrometheusConfig - container to hold the top level scrape config.
|
||||
type PrometheusConfig struct {
|
||||
ScrapeConfigs []ScrapeConfig `yaml:"scrape_configs,omitempty"`
|
||||
}
|
||||
|
||||
// String colorized prometheus config yaml.
|
||||
func (c PrometheusConfig) String() string {
|
||||
b, err := yaml.Marshal(c)
|
||||
if err != nil {
|
||||
return fmt.Sprintf("error creating config string: %s", err)
|
||||
}
|
||||
return console.Colorize("yaml", string(b))
|
||||
}
|
||||
|
||||
// JSON jsonified prometheus config.
|
||||
func (c PrometheusConfig) JSON() string {
|
||||
jsonMessageBytes, e := json.MarshalIndent(c.ScrapeConfigs[0], "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
return string(jsonMessageBytes)
|
||||
}
|
||||
|
||||
// StatConfig - container to hold the targets config.
|
||||
type StatConfig struct {
|
||||
Targets []string `yaml:",flow" json:"targets"`
|
||||
}
|
||||
|
||||
// String colorized stat config yaml.
|
||||
func (t StatConfig) String() string {
|
||||
b, err := yaml.Marshal(t)
|
||||
if err != nil {
|
||||
return fmt.Sprintf("error creating config string: %s", err)
|
||||
}
|
||||
return console.Colorize("yaml", string(b))
|
||||
}
|
||||
|
||||
// JSON jsonified stat config.
|
||||
func (t StatConfig) JSON() string {
|
||||
jsonMessageBytes, e := json.MarshalIndent(t.Targets, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
return string(jsonMessageBytes)
|
||||
}
|
||||
|
||||
// ScrapeConfig configures a scraping unit for Prometheus.
|
||||
type ScrapeConfig struct {
|
||||
JobName string `yaml:"job_name" json:"jobName"`
|
||||
BearerToken string `yaml:"bearer_token,omitempty" json:"bearerToken,omitempty"`
|
||||
MetricsPath string `yaml:"metrics_path,omitempty" json:"metricsPath"`
|
||||
Scheme string `yaml:"scheme,omitempty" json:"scheme"`
|
||||
StaticConfigs []StatConfig `yaml:"static_configs,omitempty" json:"staticConfigs"`
|
||||
}
|
||||
|
||||
const (
|
||||
defaultPrometheusJWTExpiry = 100 * 365 * 24 * time.Hour
|
||||
)
|
||||
|
||||
var defaultConfig = PrometheusConfig{
|
||||
ScrapeConfigs: []ScrapeConfig{
|
||||
{
|
||||
JobName: defaultJobName,
|
||||
MetricsPath: defaultMetricsPath,
|
||||
StaticConfigs: []StatConfig{
|
||||
{
|
||||
Targets: []string{""},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// checkAdminPrometheusSyntax - validate all the passed arguments
|
||||
func checkAdminPrometheusSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) != 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "generate", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func generatePrometheusConfig(ctx *cli.Context) error {
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
alias := cleanAlias(args.Get(0))
|
||||
|
||||
if !isValidAlias(alias) {
|
||||
fatalIf(errInvalidAlias(alias), "Invalid alias.")
|
||||
}
|
||||
|
||||
hostConfig := mustGetHostConfig(alias)
|
||||
if hostConfig == nil {
|
||||
fatalIf(errInvalidAliasedURL(alias), "No such alias `"+alias+"` found.")
|
||||
return nil
|
||||
}
|
||||
|
||||
u, e := url.Parse(hostConfig.URL)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
if !ctx.Bool("public") {
|
||||
token, e := getPrometheusToken(hostConfig)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
// Setting the values
|
||||
defaultConfig.ScrapeConfigs[0].BearerToken = token
|
||||
}
|
||||
defaultConfig.ScrapeConfigs[0].Scheme = u.Scheme
|
||||
defaultConfig.ScrapeConfigs[0].StaticConfigs[0].Targets[0] = u.Host
|
||||
|
||||
printMsg(defaultConfig)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 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)
|
||||
|
||||
if err := generatePrometheusConfig(ctx); err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
// Copyright (c) 2015-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 (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
prom2json "github.com/prometheus/prom2json"
|
||||
)
|
||||
|
||||
var adminPrometheusMetricsCmd = cli.Command{
|
||||
Name: "metrics",
|
||||
Usage: "print cluster wide prometheus metrics",
|
||||
OnUsageError: onUsageError,
|
||||
Action: mainSupportMetrics,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
EXAMPLES:
|
||||
1. List of metrics reported cluster wide.
|
||||
{{.Prompt}} {{.HelpName}} play
|
||||
`,
|
||||
}
|
||||
|
||||
const (
|
||||
metricsRespBodyLimit = 10 << 20 // 10 MiB
|
||||
metricsEndPoint = "/minio/v2/metrics/cluster"
|
||||
)
|
||||
|
||||
// checkSupportMetricsSyntax - validate arguments passed by a user
|
||||
func checkSupportMetricsSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args()) == 0 || len(ctx.Args()) > 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "metrics", 1) // last argument is exit code
|
||||
}
|
||||
}
|
||||
|
||||
func printPrometheusMetrics(ctx *cli.Context) error {
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
alias := cleanAlias(args.Get(0))
|
||||
|
||||
if !isValidAlias(alias) {
|
||||
fatalIf(errInvalidAlias(alias), "Invalid alias.")
|
||||
}
|
||||
hostConfig := mustGetHostConfig(alias)
|
||||
if hostConfig == nil {
|
||||
fatalIf(errInvalidAliasedURL(alias), "No such alias `"+alias+"` found.")
|
||||
return nil
|
||||
}
|
||||
|
||||
token, e := getPrometheusToken(hostConfig)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
req, e := http.NewRequest(http.MethodGet, hostConfig.URL+metricsEndPoint, nil)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
req.Header.Add("Authorization", "Bearer "+token)
|
||||
client := httpClient(10 * time.Second)
|
||||
resp, e := client.Do(req)
|
||||
if e != nil {
|
||||
return e
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == http.StatusOK {
|
||||
printMsg(prometheusMetricsReader{Reader: io.LimitReader(resp.Body, metricsRespBodyLimit)})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// JSON returns jsonified message
|
||||
func (pm prometheusMetricsReader) JSON() string {
|
||||
mfChan := make(chan *dto.MetricFamily)
|
||||
go func() {
|
||||
if err := prom2json.ParseReader(pm.Reader, mfChan); err != nil {
|
||||
fatalIf(probe.NewError(err), "error reading metrics:")
|
||||
}
|
||||
}()
|
||||
result := []*prom2json.Family{}
|
||||
for mf := range mfChan {
|
||||
result = append(result, prom2json.NewFamily(mf))
|
||||
}
|
||||
jsonMessageBytes, e := json.MarshalIndent(result, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
return string(jsonMessageBytes)
|
||||
}
|
||||
|
||||
// String - returns the string representation of the prometheus metrics
|
||||
func (pm prometheusMetricsReader) String() string {
|
||||
respBytes, e := ioutil.ReadAll(pm.Reader)
|
||||
if e != nil {
|
||||
fatalIf(probe.NewError(e), "error reading metrics:")
|
||||
}
|
||||
return string(respBytes)
|
||||
}
|
||||
|
||||
// prometheusMetricsReader mirrors the MetricFamily proto message.
|
||||
type prometheusMetricsReader struct {
|
||||
Reader io.Reader
|
||||
}
|
||||
|
||||
func mainSupportMetrics(ctx *cli.Context) error {
|
||||
checkSupportMetricsSyntax(ctx)
|
||||
if err := printPrometheusMetrics(ctx); err != nil {
|
||||
fatalIf(probe.NewError(err), "Error in listing prometheus metrics")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// Copyright (c) 2015-2021 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 adminPrometheusSubcommands = []cli.Command{
|
||||
adminPrometheusGenerateCmd,
|
||||
adminPrometheusMetricsCmd,
|
||||
}
|
||||
|
||||
var adminPrometheusCmd = cli.Command{
|
||||
Name: "prometheus",
|
||||
Usage: "manages prometheus config",
|
||||
Action: mainAdminPrometheus,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
HideHelpCommand: true,
|
||||
Subcommands: adminPrometheusSubcommands,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
`,
|
||||
}
|
||||
|
||||
// mainAdminPrometheus is the handle for "mc admin prometheus" command.
|
||||
func mainAdminPrometheus(ctx *cli.Context) error {
|
||||
commandNotFound(ctx, adminPrometheusSubcommands)
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminReplicateAddCmd = cli.Command{
|
||||
Name: "add",
|
||||
Usage: "add one or more sites for replication",
|
||||
Action: mainAdminReplicateAdd,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} ALIAS1 ALIAS2 [ALIAS3...]
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
|
||||
EXAMPLES:
|
||||
1. Add a site for cluster-level replication:
|
||||
{{.Prompt}} {{.HelpName}} minio1 minio2
|
||||
`,
|
||||
}
|
||||
|
||||
type successMessage madmin.ReplicateAddStatus
|
||||
|
||||
func (m successMessage) JSON() string {
|
||||
bs, e := json.MarshalIndent(madmin.ReplicateAddStatus(m), "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
return string(bs)
|
||||
}
|
||||
|
||||
func (m successMessage) String() string {
|
||||
v := madmin.ReplicateAddStatus(m)
|
||||
messages := []string{v.Status}
|
||||
|
||||
if v.ErrDetail != "" {
|
||||
messages = append(messages, v.ErrDetail)
|
||||
}
|
||||
if v.InitialSyncErrorMessage != "" {
|
||||
messages = append(messages, v.InitialSyncErrorMessage)
|
||||
}
|
||||
return console.Colorize("UserMessage", strings.Join(messages, "\n"))
|
||||
}
|
||||
|
||||
func mainAdminReplicateAdd(ctx *cli.Context) error {
|
||||
{
|
||||
// Check argument count
|
||||
argsNr := len(ctx.Args())
|
||||
if argsNr < 2 {
|
||||
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
|
||||
"Need at least two arguments to add command.")
|
||||
}
|
||||
}
|
||||
|
||||
console.SetColor("UserMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
ps := make([]madmin.PeerSite, 0, len(ctx.Args()))
|
||||
for _, clusterName := range ctx.Args() {
|
||||
admClient, err := newAdminClient(clusterName)
|
||||
fatalIf(err, "unable to initialize admin connection")
|
||||
|
||||
ak, sk := admClient.GetAccessAndSecretKey()
|
||||
ps = append(ps, madmin.PeerSite{
|
||||
Name: clusterName,
|
||||
Endpoint: admClient.GetEndpointURL().String(),
|
||||
AccessKey: ak,
|
||||
SecretKey: sk,
|
||||
})
|
||||
}
|
||||
|
||||
res, e := client.SiteReplicationAdd(globalContext, ps)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to add sites for replication")
|
||||
|
||||
printMsg(successMessage(res))
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminReplicateEditFlags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "deployment-id",
|
||||
Usage: "deployment id of the site, should be a unique value",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "endpoint",
|
||||
Usage: "endpoint for the site",
|
||||
},
|
||||
}
|
||||
|
||||
var adminReplicateEditCmd = cli.Command{
|
||||
Name: "edit",
|
||||
Usage: "edit endpoint of site participating in cluster replication",
|
||||
Action: mainAdminReplicateEdit,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(globalFlags, adminReplicateEditFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} ALIAS --deployment-id [DEPLOYMENT-ID] --endpoint [NEW-ENDPOINT]
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
|
||||
EXAMPLES:
|
||||
1. Edit a site endpoint participating in cluster-level replication:
|
||||
{{.Prompt}} {{.HelpName}} myminio --deployment-id c1758167-4426-454f-9aae-5c3dfdf6df64 --endpoint https://minio2:9000
|
||||
`,
|
||||
}
|
||||
|
||||
type editSuccessMessage madmin.ReplicateEditStatus
|
||||
|
||||
func (m editSuccessMessage) JSON() string {
|
||||
bs, e := json.MarshalIndent(madmin.ReplicateEditStatus(m), "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
return string(bs)
|
||||
}
|
||||
|
||||
func (m editSuccessMessage) String() string {
|
||||
v := madmin.ReplicateEditStatus(m)
|
||||
messages := []string{v.Status}
|
||||
|
||||
if v.ErrDetail != "" {
|
||||
messages = append(messages, v.ErrDetail)
|
||||
}
|
||||
return console.Colorize("UserMessage", strings.Join(messages, "\n"))
|
||||
}
|
||||
|
||||
func checkAdminReplicateEditSyntax(ctx *cli.Context) {
|
||||
// Check argument count
|
||||
argsNr := len(ctx.Args())
|
||||
if argsNr < 1 {
|
||||
cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code
|
||||
}
|
||||
if argsNr != 1 {
|
||||
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
|
||||
"Invalid arguments specified for edit command.")
|
||||
}
|
||||
}
|
||||
|
||||
func mainAdminReplicateEdit(ctx *cli.Context) error {
|
||||
checkAdminReplicateEditSyntax(ctx)
|
||||
console.SetColor("UserMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
if !ctx.IsSet("deployment-id") {
|
||||
fatalIf(errInvalidArgument(), "--deployment-id is a required flag")
|
||||
}
|
||||
if !ctx.IsSet("endpoint") {
|
||||
fatalIf(errInvalidArgument(), "--endpoint is a required flag")
|
||||
}
|
||||
parsedURL := ctx.String("endpoint")
|
||||
u, e := url.Parse(parsedURL)
|
||||
if e != nil {
|
||||
fatalIf(errInvalidArgument().Trace(parsedURL), "Unsupported URL format %v", e)
|
||||
}
|
||||
res, e := client.SiteReplicationEdit(globalContext, madmin.PeerInfo{
|
||||
DeploymentID: ctx.String("deployment-id"),
|
||||
Endpoint: u.String(),
|
||||
})
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to edit cluster replication site endpoint")
|
||||
|
||||
printMsg(editSuccessMessage(res))
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
// Copyright (c) 2015-2021 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 (
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminReplicateInfoCmd = cli.Command{
|
||||
Name: "info",
|
||||
Usage: "get site replication information",
|
||||
Action: mainAdminReplicationInfo,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: globalFlags,
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} ALIAS1
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
|
||||
EXAMPLES:
|
||||
1. Get Site Replication information:
|
||||
{{.Prompt}} {{.HelpName}} minio1
|
||||
`,
|
||||
}
|
||||
|
||||
type srInfo madmin.SiteReplicationInfo
|
||||
|
||||
func (i srInfo) JSON() string {
|
||||
bs, e := json.MarshalIndent(madmin.SiteReplicationInfo(i), "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
return string(bs)
|
||||
}
|
||||
|
||||
func (i srInfo) String() string {
|
||||
var messages []string
|
||||
info := madmin.SiteReplicationInfo(i)
|
||||
if info.Enabled {
|
||||
messages = []string{
|
||||
"SiteReplication enabled for:\n",
|
||||
}
|
||||
r := console.Colorize("THeaders", newPrettyTable(" | ",
|
||||
Field{"Deployment ID", 36},
|
||||
|
||||
Field{"Name", 15},
|
||||
Field{"Endpoint", 50},
|
||||
).buildRow("Deployment ID", "Site Name", "Endpoint"))
|
||||
messages = append(messages, r)
|
||||
for _, peer := range info.Sites {
|
||||
r := console.Colorize("TDetail", newPrettyTable(" | ",
|
||||
Field{"Deployment ID", 36},
|
||||
|
||||
Field{"Name", 15},
|
||||
Field{"Endpoint", 50},
|
||||
).buildRow(peer.DeploymentID, peer.Name, peer.Endpoint))
|
||||
messages = append(messages, r)
|
||||
}
|
||||
} else {
|
||||
messages = []string{"SiteReplication is not enabled"}
|
||||
}
|
||||
|
||||
return console.Colorize("UserMessage", strings.Join(messages, "\n"))
|
||||
}
|
||||
|
||||
func mainAdminReplicationInfo(ctx *cli.Context) error {
|
||||
{
|
||||
// Check argument count
|
||||
argsNr := len(ctx.Args())
|
||||
if argsNr != 1 {
|
||||
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
|
||||
"Need exactly one alias argument.")
|
||||
}
|
||||
}
|
||||
|
||||
console.SetColor("UserMessage", color.New(color.FgGreen))
|
||||
console.SetColor("THeaders", color.New(color.Bold, color.FgHiWhite))
|
||||
console.SetColor("TDetail", color.New(color.Bold, color.FgCyan))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
info, e := client.SiteReplicationInfo(globalContext)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to get cluster replication information")
|
||||
|
||||
printMsg(srInfo(info))
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// Copyright (c) 2015-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 (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/minio/cli"
|
||||
json "github.com/minio/colorjson"
|
||||
"github.com/minio/madmin-go"
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/pkg/console"
|
||||
)
|
||||
|
||||
var adminReplicateRemoveFlags = []cli.Flag{
|
||||
cli.BoolFlag{
|
||||
Name: "all",
|
||||
Usage: "remove site replication from all participating sites",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "force",
|
||||
Usage: "force removal of site(s) from site replication configuration",
|
||||
},
|
||||
}
|
||||
|
||||
var adminReplicateRemoveCmd = cli.Command{
|
||||
Name: "remove",
|
||||
Usage: "remove one or more sites from site replication",
|
||||
Action: mainAdminReplicationRemoveStatus,
|
||||
OnUsageError: onUsageError,
|
||||
Before: setGlobalsFromContext,
|
||||
Flags: append(globalFlags, adminReplicateRemoveFlags...),
|
||||
CustomHelpTemplate: `NAME:
|
||||
{{.HelpName}} - {{.Usage}}
|
||||
|
||||
USAGE:
|
||||
{{.HelpName}} TARGET
|
||||
|
||||
FLAGS:
|
||||
{{range .VisibleFlags}}{{.}}
|
||||
{{end}}
|
||||
|
||||
EXAMPLES:
|
||||
1. Remove site replication for all sites:
|
||||
{{.Prompt}} {{.HelpName}} minio2 --all --force
|
||||
|
||||
2. Remove site replication for site with site names alpha, baker from active cluster minio2:
|
||||
{{.Prompt}} {{.HelpName}} minio2 alpha baker --force
|
||||
`,
|
||||
}
|
||||
|
||||
type srRemoveStatus struct {
|
||||
madmin.ReplicateRemoveStatus
|
||||
sites []string
|
||||
RemoveAll bool
|
||||
}
|
||||
|
||||
func (i srRemoveStatus) JSON() string {
|
||||
ds, e := json.MarshalIndent(i.ReplicateRemoveStatus, "", " ")
|
||||
fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
|
||||
return string(ds)
|
||||
}
|
||||
|
||||
func (i srRemoveStatus) String() string {
|
||||
if i.RemoveAll {
|
||||
return console.Colorize("UserMessage", fmt.Sprintf("All site(s) were removed successfully"))
|
||||
}
|
||||
return console.Colorize("UserMessage", fmt.Sprintf("Following site(s) %s were removed successfully", strings.Join(i.sites, ", ")))
|
||||
}
|
||||
|
||||
func checkAdminReplicateRemoveSyntax(ctx *cli.Context) {
|
||||
// Check argument count
|
||||
argsNr := len(ctx.Args())
|
||||
if ctx.IsSet("all") && argsNr > 1 {
|
||||
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
|
||||
"")
|
||||
}
|
||||
if argsNr < 2 && !ctx.IsSet("all") {
|
||||
fatalIf(errInvalidArgument().Trace(ctx.Args().Tail()...),
|
||||
"Need at least two arguments to remove command.")
|
||||
}
|
||||
if !ctx.IsSet("force") {
|
||||
fatalIf(errDummy().Trace(),
|
||||
"Site removal requires --force flag. This operation is *IRREVERSIBLE*. Please review carefully before performing this *DANGEROUS* operation.")
|
||||
}
|
||||
}
|
||||
|
||||
func mainAdminReplicationRemoveStatus(ctx *cli.Context) error {
|
||||
checkAdminReplicateRemoveSyntax(ctx)
|
||||
console.SetColor("UserMessage", color.New(color.FgGreen))
|
||||
|
||||
// Get the alias parameter from cli
|
||||
args := ctx.Args()
|
||||
aliasedURL := args.Get(0)
|
||||
var rreq madmin.SRRemoveReq
|
||||
rreq.SiteNames = append(rreq.SiteNames, args.Tail()...)
|
||||
rreq.RemoveAll = ctx.Bool("all")
|
||||
// Create a new MinIO Admin Client
|
||||
client, err := newAdminClient(aliasedURL)
|
||||
fatalIf(err, "Unable to initialize admin connection.")
|
||||
|
||||
st, e := client.SiteReplicationRemove(globalContext, rreq)
|
||||
fatalIf(probe.NewError(e).Trace(args...), "Unable to remove cluster replication")
|
||||
|
||||
printMsg(srRemoveStatus{
|
||||
ReplicateRemoveStatus: st,
|
||||
sites: args.Tail(),
|
||||
RemoveAll: rreq.RemoveAll,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user