/
config-old.go
334 lines (290 loc) · 8.53 KB
/
config-old.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
// 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
/////////////////// Config V1 ///////////////////
type hostConfigV1 struct {
AccessKeyID string
SecretAccessKey string
}
type configV1 struct {
Version string
Aliases map[string]string
Hosts map[string]hostConfigV1
}
// newConfigV1() - get new config version 1.0.0
func newConfigV1() *configV1 {
conf := new(configV1)
conf.Version = "1.0.0"
// make sure to allocate map's otherwise Golang
// exits silently without providing any errors
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]hostConfigV1)
return conf
}
/////////////////// Config V101 ///////////////////
type hostConfigV101 hostConfigV1
type configV101 struct {
Version string
Aliases map[string]string
Hosts map[string]hostConfigV101
}
// newConfigV101() - get new config version 1.0.1
func newConfigV101() *configV101 {
conf := new(configV101)
conf.Version = "1.0.1"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]hostConfigV101)
return conf
}
/////////////////// Config V2 ///////////////////
type hostConfigV2 hostConfigV1
type configV2 struct {
Version string
Aliases map[string]string
Hosts map[string]hostConfigV2
}
// newConfigV2() - get new config version 2
func newConfigV2() *configV2 {
conf := new(configV2)
conf.Version = "2"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]hostConfigV2)
return conf
}
/////////////////// Config V3 ///////////////////
type hostConfigV3 struct {
AccessKeyID string `json:"access-key-id"`
SecretAccessKey string `json:"secret-access-key"`
}
type configV3 struct {
Version string `json:"version"`
Aliases map[string]string `json:"alias"`
Hosts map[string]hostConfigV3 `json:"hosts"`
}
// newConfigV3 - get new config version 3.
func newConfigV3() *configV3 {
conf := new(configV3)
conf.Version = "3"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]hostConfigV3)
return conf
}
/////////////////// Config V4 ///////////////////
type hostConfigV4 struct {
AccessKeyID string `json:"accessKeyId"`
SecretAccessKey string `json:"secretAccessKey"`
Signature string `json:"signature"`
}
type configV4 struct {
Version string `json:"version"`
Aliases map[string]string `json:"alias"`
Hosts map[string]hostConfigV4 `json:"hosts"`
}
func newConfigV4() *configV4 {
conf := new(configV4)
conf.Version = "4"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]hostConfigV4)
return conf
}
/////////////////// Config V5 ///////////////////
type hostConfigV5 struct {
AccessKeyID string `json:"accessKeyId"`
SecretAccessKey string `json:"secretAccessKey"`
API string `json:"api"`
}
type configV5 struct {
Version string `json:"version"`
Aliases map[string]string `json:"alias"`
Hosts map[string]hostConfigV5 `json:"hosts"`
}
func newConfigV5() *configV5 {
conf := new(configV5)
conf.Version = "5"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]hostConfigV5)
return conf
}
/////////////////// Config V6 ///////////////////
type hostConfigV6 struct {
AccessKeyID string `json:"accessKeyId"`
SecretAccessKey string `json:"secretAccessKey"`
API string `json:"api"`
}
type configV6 struct {
Version string `json:"version"`
Aliases map[string]string `json:"alias"`
Hosts map[string]hostConfigV6 `json:"hosts"`
}
// newConfigV6 - new config version '6'.
func newConfigV6() *configV6 {
conf := new(configV6)
conf.Version = "6"
conf.Aliases = make(map[string]string)
conf.Hosts = make(map[string]hostConfigV6)
return conf
}
/////////////////// Config V6 ///////////////////
// hostConfig configuration of a host - version '7'.
type hostConfigV7 struct {
URL string `json:"url"`
AccessKey string `json:"accessKey"`
SecretKey string `json:"secretKey"`
API string `json:"api"`
}
// configV7 config version.
type configV7 struct {
Version string `json:"version"`
Hosts map[string]hostConfigV7 `json:"hosts"`
}
// newConfigV7 - new config version '7'.
func newConfigV7() *configV7 {
cfg := new(configV7)
cfg.Version = "7"
cfg.Hosts = make(map[string]hostConfigV7)
return cfg
}
func (c *configV7) loadDefaults() {
// MinIO server running locally.
c.setHost("local", hostConfigV7{
URL: "http://localhost:9000",
AccessKey: "",
SecretKey: "",
API: "S3v4",
})
// Amazon S3 cloud storage service.
c.setHost("s3", hostConfigV7{
URL: "https://s3.amazonaws.com",
AccessKey: defaultAccessKey,
SecretKey: defaultSecretKey,
API: "S3v4",
})
// Google cloud storage service.
c.setHost("gcs", hostConfigV7{
URL: "https://storage.googleapis.com",
AccessKey: defaultAccessKey,
SecretKey: defaultSecretKey,
API: "S3v2",
})
// MinIO anonymous server for demo.
c.setHost("play", hostConfigV7{
URL: "https://play.min.io",
AccessKey: "",
SecretKey: "",
API: "S3v4",
})
// MinIO demo server with public secret and access keys.
c.setHost("player", hostConfigV7{
URL: "https://play.min.io:9002",
AccessKey: "Q3AM3UQ867SPQQA43P2F",
SecretKey: "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
API: "S3v4",
})
// MinIO public download service.
c.setHost("dl", hostConfigV7{
URL: "https://dl.min.io:9000",
AccessKey: "",
SecretKey: "",
API: "S3v4",
})
}
// SetHost sets host config if not empty.
func (c *configV7) setHost(alias string, cfg hostConfigV7) {
if _, ok := c.Hosts[alias]; !ok {
c.Hosts[alias] = cfg
}
}
/////////////////// Config V8 ///////////////////
// configV8 config version.
// hostConfig configuration of a host.
type hostConfigV8 struct {
URL string `json:"url"`
AccessKey string `json:"accessKey"`
SecretKey string `json:"secretKey"`
API string `json:"api"`
}
type configV8 struct {
Version string `json:"version"`
Hosts map[string]hostConfigV8 `json:"hosts"`
}
// newConfigV8 - new config version.
func newConfigV8() *configV8 {
cfg := new(configV8)
cfg.Version = globalMCConfigVersion
cfg.Hosts = make(map[string]hostConfigV8)
return cfg
}
// SetHost sets host config if not empty.
func (c *configV8) setHost(alias string, cfg hostConfigV8) {
if _, ok := c.Hosts[alias]; !ok {
c.Hosts[alias] = cfg
}
}
// load default values for missing entries.
func (c *configV8) loadDefaults() {
// MinIO server running locally.
c.setHost("local", hostConfigV8{
URL: "http://localhost:9000",
AccessKey: "",
SecretKey: "",
API: "S3v4",
})
// Amazon S3 cloud storage service.
c.setHost("s3", hostConfigV8{
URL: "https://s3.amazonaws.com",
AccessKey: defaultAccessKey,
SecretKey: defaultSecretKey,
API: "S3v4",
})
// Google cloud storage service.
c.setHost("gcs", hostConfigV8{
URL: "https://storage.googleapis.com",
AccessKey: defaultAccessKey,
SecretKey: defaultSecretKey,
API: "S3v2",
})
// MinIO anonymous server for demo.
c.setHost("play", hostConfigV8{
URL: "https://play.min.io",
AccessKey: "Q3AM3UQ867SPQQA43P2F",
SecretKey: "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG",
API: "S3v4",
})
}
/////////////////// Config V9 ///////////////////
// hostConfig configuration of a host.
type hostConfigV9 struct {
URL string `json:"url"`
AccessKey string `json:"accessKey"`
SecretKey string `json:"secretKey"`
SessionToken string `json:"sessionToken,omitempty"`
API string `json:"api"`
Lookup string `json:"lookup"`
}
// configV8 config version.
type configV9 struct {
Version string `json:"version"`
Hosts map[string]hostConfigV9 `json:"hosts"`
}
func newConfigV9() *configV9 {
cfg := new(configV9)
cfg.Version = "9"
cfg.Hosts = make(map[string]hostConfigV9)
return cfg
}
/////////////////// Config V10 ///////////////////
// RESERVED FOR FUTURE