config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
/*
|
2017-01-18 21:24:34 +01:00
|
|
|
|
* Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-08-19 01:23:42 +02:00
|
|
|
|
package cmd
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
|
|
|
|
|
import (
|
2017-03-01 18:17:04 +01:00
|
|
|
|
"errors"
|
2017-03-16 19:06:17 +01:00
|
|
|
|
"fmt"
|
2017-03-16 00:30:34 +01:00
|
|
|
|
"io/ioutil"
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
"sync"
|
|
|
|
|
|
2017-10-31 19:54:32 +01:00
|
|
|
|
"github.com/minio/minio/pkg/auth"
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
"github.com/minio/minio/pkg/quick"
|
2017-03-16 00:30:34 +01:00
|
|
|
|
"github.com/tidwall/gjson"
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
)
|
|
|
|
|
|
2017-03-27 20:27:25 +02:00
|
|
|
|
// Config version
|
2017-11-15 01:56:24 +01:00
|
|
|
|
const v20 = "20"
|
2017-03-27 20:27:25 +02:00
|
|
|
|
|
2017-03-31 07:26:24 +02:00
|
|
|
|
var (
|
|
|
|
|
// serverConfig server config.
|
2017-11-15 01:56:24 +01:00
|
|
|
|
serverConfig *serverConfigV20
|
2017-03-31 07:26:24 +02:00
|
|
|
|
serverConfigMu sync.RWMutex
|
|
|
|
|
)
|
|
|
|
|
|
2017-11-15 01:56:24 +01:00
|
|
|
|
// serverConfigV20 server configuration version '20' which is like
|
|
|
|
|
// version '19' except it adds support for VirtualHostDomain
|
|
|
|
|
type serverConfigV20 struct {
|
2017-03-31 07:26:24 +02:00
|
|
|
|
sync.RWMutex
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
Version string `json:"version"`
|
|
|
|
|
|
|
|
|
|
// S3 API configuration.
|
2017-10-31 19:54:32 +01:00
|
|
|
|
Credential auth.Credentials `json:"credential"`
|
|
|
|
|
Region string `json:"region"`
|
|
|
|
|
Browser BrowserFlag `json:"browser"`
|
2017-11-15 01:56:24 +01:00
|
|
|
|
Domain string `json:"domain"`
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
|
|
|
|
|
// Additional error logging configuration.
|
2017-03-24 00:36:00 +01:00
|
|
|
|
Logger *loggers `json:"logger"`
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
|
2016-08-05 07:01:58 +02:00
|
|
|
|
// Notification queue configuration.
|
2017-02-10 00:20:54 +01:00
|
|
|
|
Notify *notifier `json:"notify"`
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-31 07:26:24 +02:00
|
|
|
|
// GetVersion get current config version.
|
2017-11-15 01:56:24 +01:00
|
|
|
|
func (s *serverConfigV20) GetVersion() string {
|
2017-03-31 07:26:24 +02:00
|
|
|
|
s.RLock()
|
|
|
|
|
defer s.RUnlock()
|
|
|
|
|
|
|
|
|
|
return s.Version
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-08 21:14:32 +02:00
|
|
|
|
// SetRegion set a new region.
|
2017-11-15 01:56:24 +01:00
|
|
|
|
func (s *serverConfigV20) SetRegion(region string) {
|
2017-03-31 07:26:24 +02:00
|
|
|
|
s.Lock()
|
|
|
|
|
defer s.Unlock()
|
|
|
|
|
|
2017-08-08 21:14:32 +02:00
|
|
|
|
// Save new region.
|
2017-03-31 07:26:24 +02:00
|
|
|
|
s.Region = region
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetRegion get current region.
|
2017-11-15 01:56:24 +01:00
|
|
|
|
func (s *serverConfigV20) GetRegion() string {
|
2017-03-31 07:26:24 +02:00
|
|
|
|
s.RLock()
|
|
|
|
|
defer s.RUnlock()
|
|
|
|
|
|
|
|
|
|
return s.Region
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-08 21:14:32 +02:00
|
|
|
|
// SetCredentials set new credentials. SetCredential returns the previous credential.
|
2017-11-15 01:56:24 +01:00
|
|
|
|
func (s *serverConfigV20) SetCredential(creds auth.Credentials) (prevCred auth.Credentials) {
|
2017-03-31 07:26:24 +02:00
|
|
|
|
s.Lock()
|
|
|
|
|
defer s.Unlock()
|
|
|
|
|
|
2017-08-08 21:14:32 +02:00
|
|
|
|
// Save previous credential.
|
|
|
|
|
prevCred = s.Credential
|
|
|
|
|
|
2017-03-31 07:26:24 +02:00
|
|
|
|
// Set updated credential.
|
|
|
|
|
s.Credential = creds
|
2017-08-08 21:14:32 +02:00
|
|
|
|
|
|
|
|
|
// Return previous credential.
|
|
|
|
|
return prevCred
|
2017-03-31 07:26:24 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetCredentials get current credentials.
|
2017-11-15 01:56:24 +01:00
|
|
|
|
func (s *serverConfigV20) GetCredential() auth.Credentials {
|
2017-03-31 07:26:24 +02:00
|
|
|
|
s.RLock()
|
|
|
|
|
defer s.RUnlock()
|
|
|
|
|
|
|
|
|
|
return s.Credential
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetBrowser set if browser is enabled.
|
2017-11-15 01:56:24 +01:00
|
|
|
|
func (s *serverConfigV20) SetBrowser(b bool) {
|
2017-03-31 07:26:24 +02:00
|
|
|
|
s.Lock()
|
|
|
|
|
defer s.Unlock()
|
|
|
|
|
|
|
|
|
|
// Set the new value.
|
|
|
|
|
s.Browser = BrowserFlag(b)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GetCredentials get current credentials.
|
2017-11-15 01:56:24 +01:00
|
|
|
|
func (s *serverConfigV20) GetBrowser() bool {
|
2017-03-31 07:26:24 +02:00
|
|
|
|
s.RLock()
|
|
|
|
|
defer s.RUnlock()
|
|
|
|
|
|
|
|
|
|
return bool(s.Browser)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Save config.
|
2017-11-15 01:56:24 +01:00
|
|
|
|
func (s *serverConfigV20) Save() error {
|
2017-03-31 07:26:24 +02:00
|
|
|
|
s.RLock()
|
|
|
|
|
defer s.RUnlock()
|
|
|
|
|
|
|
|
|
|
// Save config file.
|
|
|
|
|
return quick.Save(getConfigFile(), s)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-15 01:56:24 +01:00
|
|
|
|
func newServerConfigV20() *serverConfigV20 {
|
|
|
|
|
srvCfg := &serverConfigV20{
|
|
|
|
|
Version: v20,
|
2017-10-31 19:54:32 +01:00
|
|
|
|
Credential: auth.MustGetNewCredentials(),
|
2017-03-26 21:00:27 +02:00
|
|
|
|
Region: globalMinioDefaultRegion,
|
|
|
|
|
Browser: true,
|
|
|
|
|
Logger: &loggers{},
|
|
|
|
|
Notify: ¬ifier{},
|
2017-02-27 23:59:53 +01:00
|
|
|
|
}
|
2017-03-26 21:00:27 +02:00
|
|
|
|
|
2017-02-07 21:51:43 +01:00
|
|
|
|
// Enable console logger by default on a fresh run.
|
2017-03-24 00:36:00 +01:00
|
|
|
|
srvCfg.Logger.Console = NewConsoleLogger()
|
2017-02-07 21:51:43 +01:00
|
|
|
|
|
|
|
|
|
// Make sure to initialize notification configs.
|
|
|
|
|
srvCfg.Notify.AMQP = make(map[string]amqpNotify)
|
|
|
|
|
srvCfg.Notify.AMQP["1"] = amqpNotify{}
|
2017-06-15 02:27:03 +02:00
|
|
|
|
srvCfg.Notify.MQTT = make(map[string]mqttNotify)
|
|
|
|
|
srvCfg.Notify.MQTT["1"] = mqttNotify{}
|
2017-02-07 21:51:43 +01:00
|
|
|
|
srvCfg.Notify.ElasticSearch = make(map[string]elasticSearchNotify)
|
|
|
|
|
srvCfg.Notify.ElasticSearch["1"] = elasticSearchNotify{}
|
|
|
|
|
srvCfg.Notify.Redis = make(map[string]redisNotify)
|
|
|
|
|
srvCfg.Notify.Redis["1"] = redisNotify{}
|
|
|
|
|
srvCfg.Notify.NATS = make(map[string]natsNotify)
|
|
|
|
|
srvCfg.Notify.NATS["1"] = natsNotify{}
|
|
|
|
|
srvCfg.Notify.PostgreSQL = make(map[string]postgreSQLNotify)
|
|
|
|
|
srvCfg.Notify.PostgreSQL["1"] = postgreSQLNotify{}
|
2017-03-17 17:29:17 +01:00
|
|
|
|
srvCfg.Notify.MySQL = make(map[string]mySQLNotify)
|
|
|
|
|
srvCfg.Notify.MySQL["1"] = mySQLNotify{}
|
2017-02-07 21:51:43 +01:00
|
|
|
|
srvCfg.Notify.Kafka = make(map[string]kafkaNotify)
|
|
|
|
|
srvCfg.Notify.Kafka["1"] = kafkaNotify{}
|
|
|
|
|
srvCfg.Notify.Webhook = make(map[string]webhookNotify)
|
|
|
|
|
srvCfg.Notify.Webhook["1"] = webhookNotify{}
|
|
|
|
|
|
2017-03-01 18:17:04 +01:00
|
|
|
|
return srvCfg
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// newConfig - initialize a new server config, saves env parameters if
|
|
|
|
|
// found, otherwise use default parameters
|
2017-03-30 20:21:19 +02:00
|
|
|
|
func newConfig() error {
|
2017-03-01 18:17:04 +01:00
|
|
|
|
// Initialize server config.
|
2017-11-15 01:56:24 +01:00
|
|
|
|
srvCfg := newServerConfigV20()
|
2017-03-01 18:17:04 +01:00
|
|
|
|
|
2017-03-31 07:26:24 +02:00
|
|
|
|
// If env is set override the credentials from config file.
|
2017-03-01 18:17:04 +01:00
|
|
|
|
if globalIsEnvCreds {
|
2017-03-30 20:21:19 +02:00
|
|
|
|
srvCfg.SetCredential(globalActiveCred)
|
2017-03-01 18:17:04 +01:00
|
|
|
|
}
|
2017-03-31 12:34:26 +02:00
|
|
|
|
|
2017-03-01 18:17:04 +01:00
|
|
|
|
if globalIsEnvBrowser {
|
2017-03-30 20:21:19 +02:00
|
|
|
|
srvCfg.SetBrowser(globalIsBrowserEnabled)
|
2017-03-01 18:17:04 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-09 19:44:10 +02:00
|
|
|
|
if globalIsEnvRegion {
|
|
|
|
|
srvCfg.SetRegion(globalServerRegion)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-15 01:56:24 +01:00
|
|
|
|
if globalIsEnvDomainName {
|
|
|
|
|
srvCfg.Domain = globalDomainName
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-07 21:51:43 +01:00
|
|
|
|
// hold the mutex lock before a new config is assigned.
|
|
|
|
|
// Save the new config globally.
|
|
|
|
|
// unlock the mutex.
|
|
|
|
|
serverConfigMu.Lock()
|
|
|
|
|
serverConfig = srvCfg
|
|
|
|
|
serverConfigMu.Unlock()
|
|
|
|
|
|
|
|
|
|
// Save config into file.
|
|
|
|
|
return serverConfig.Save()
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-16 00:30:34 +01:00
|
|
|
|
// doCheckDupJSONKeys recursively detects duplicate json keys
|
|
|
|
|
func doCheckDupJSONKeys(key, value gjson.Result) error {
|
|
|
|
|
// Key occurrences map of the current scope to count
|
|
|
|
|
// if there is any duplicated json key.
|
|
|
|
|
keysOcc := make(map[string]int)
|
|
|
|
|
|
|
|
|
|
// Holds the found error
|
|
|
|
|
var checkErr error
|
|
|
|
|
|
|
|
|
|
// Iterate over keys in the current json scope
|
|
|
|
|
value.ForEach(func(k, v gjson.Result) bool {
|
|
|
|
|
// If current key is not null, check if its
|
|
|
|
|
// value contains some duplicated keys.
|
|
|
|
|
if k.Type != gjson.Null {
|
|
|
|
|
keysOcc[k.String()]++
|
|
|
|
|
checkErr = doCheckDupJSONKeys(k, v)
|
|
|
|
|
}
|
|
|
|
|
return checkErr == nil
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// Check found err
|
|
|
|
|
if checkErr != nil {
|
|
|
|
|
return errors.New(key.String() + " => " + checkErr.Error())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check for duplicated keys
|
|
|
|
|
for k, v := range keysOcc {
|
|
|
|
|
if v > 1 {
|
|
|
|
|
return errors.New(key.String() + " => `" + k + "` entry is duplicated")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check recursively if a key is duplicated in the same json scope
|
|
|
|
|
// e.g.:
|
|
|
|
|
// `{ "key" : { "key" ..` is accepted
|
|
|
|
|
// `{ "key" : { "subkey" : "val1", "subkey": "val2" ..` throws subkey duplicated error
|
|
|
|
|
func checkDupJSONKeys(json string) error {
|
|
|
|
|
// Parse config with gjson library
|
|
|
|
|
config := gjson.Parse(json)
|
|
|
|
|
|
|
|
|
|
// Create a fake rootKey since root json doesn't seem to have representation
|
|
|
|
|
// in gjson library.
|
|
|
|
|
rootKey := gjson.Result{Type: gjson.String, Str: minioConfigFile}
|
|
|
|
|
|
|
|
|
|
// Check if loaded json contains any duplicated keys
|
|
|
|
|
return doCheckDupJSONKeys(rootKey, config)
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-31 07:26:24 +02:00
|
|
|
|
// getValidConfig - returns valid server configuration
|
2017-11-15 01:56:24 +01:00
|
|
|
|
func getValidConfig() (*serverConfigV20, error) {
|
|
|
|
|
srvCfg := &serverConfigV20{
|
2017-03-26 21:00:27 +02:00
|
|
|
|
Region: globalMinioDefaultRegion,
|
|
|
|
|
Browser: true,
|
|
|
|
|
}
|
2017-03-16 00:30:34 +01:00
|
|
|
|
|
2017-03-26 21:00:27 +02:00
|
|
|
|
configFile := getConfigFile()
|
2017-03-22 18:23:25 +01:00
|
|
|
|
if _, err := quick.Load(configFile, srvCfg); err != nil {
|
2017-03-31 07:26:24 +02:00
|
|
|
|
return nil, err
|
2017-03-16 00:30:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-15 01:56:24 +01:00
|
|
|
|
if srvCfg.Version != v20 {
|
|
|
|
|
return nil, fmt.Errorf("configuration version mismatch. Expected: ‘%s’, Got: ‘%s’", v20, srvCfg.Version)
|
2017-03-16 00:30:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load config file json and check for duplication json keys
|
|
|
|
|
jsonBytes, err := ioutil.ReadFile(configFile)
|
|
|
|
|
if err != nil {
|
2017-03-31 07:26:24 +02:00
|
|
|
|
return nil, err
|
2017-03-16 00:30:34 +01:00
|
|
|
|
}
|
2017-03-31 07:26:24 +02:00
|
|
|
|
if err = checkDupJSONKeys(string(jsonBytes)); err != nil {
|
|
|
|
|
return nil, err
|
2017-03-16 00:30:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 00:11:58 +01:00
|
|
|
|
// Validate credential fields only when
|
|
|
|
|
// they are not set via the environment
|
2017-03-31 07:26:24 +02:00
|
|
|
|
|
|
|
|
|
// Error out if global is env credential is not set and config has invalid credential
|
|
|
|
|
if !globalIsEnvCreds && !srvCfg.Credential.IsValid() {
|
|
|
|
|
return nil, errors.New("invalid credential in config file " + configFile)
|
2017-03-16 00:30:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate logger field
|
2017-03-31 07:26:24 +02:00
|
|
|
|
if err = srvCfg.Logger.Validate(); err != nil {
|
|
|
|
|
return nil, err
|
2017-03-16 00:30:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Validate notify field
|
2017-03-31 07:26:24 +02:00
|
|
|
|
if err = srvCfg.Notify.Validate(); err != nil {
|
|
|
|
|
return nil, err
|
2017-03-16 00:30:34 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-31 07:26:24 +02:00
|
|
|
|
return srvCfg, nil
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-31 07:26:24 +02:00
|
|
|
|
// loadConfig - loads a new config from disk, overrides params from env
|
|
|
|
|
// if found and valid
|
|
|
|
|
func loadConfig() error {
|
|
|
|
|
srvCfg, err := getValidConfig()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
2017-03-16 19:06:17 +01:00
|
|
|
|
}
|
2016-12-07 12:41:54 +01:00
|
|
|
|
|
2017-03-31 07:26:24 +02:00
|
|
|
|
// If env is set override the credentials from config file.
|
|
|
|
|
if globalIsEnvCreds {
|
|
|
|
|
srvCfg.SetCredential(globalActiveCred)
|
|
|
|
|
}
|
2017-04-09 19:44:10 +02:00
|
|
|
|
|
2017-03-31 07:26:24 +02:00
|
|
|
|
if globalIsEnvBrowser {
|
|
|
|
|
srvCfg.SetBrowser(globalIsBrowserEnabled)
|
|
|
|
|
}
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
|
2017-04-09 19:44:10 +02:00
|
|
|
|
if globalIsEnvRegion {
|
|
|
|
|
srvCfg.SetRegion(globalServerRegion)
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-15 01:56:24 +01:00
|
|
|
|
if globalIsEnvDomainName {
|
|
|
|
|
srvCfg.Domain = globalDomainName
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-31 07:26:24 +02:00
|
|
|
|
// hold the mutex lock before a new config is assigned.
|
2017-02-27 23:59:53 +01:00
|
|
|
|
serverConfigMu.Lock()
|
2017-03-31 07:26:24 +02:00
|
|
|
|
serverConfig = srvCfg
|
|
|
|
|
if !globalIsEnvCreds {
|
|
|
|
|
globalActiveCred = serverConfig.GetCredential()
|
|
|
|
|
}
|
|
|
|
|
if !globalIsEnvBrowser {
|
|
|
|
|
globalIsBrowserEnabled = serverConfig.GetBrowser()
|
|
|
|
|
}
|
2017-04-09 19:44:10 +02:00
|
|
|
|
if !globalIsEnvRegion {
|
|
|
|
|
globalServerRegion = serverConfig.GetRegion()
|
|
|
|
|
}
|
2017-11-15 01:56:24 +01:00
|
|
|
|
if !globalIsEnvDomainName {
|
|
|
|
|
globalDomainName = serverConfig.Domain
|
|
|
|
|
}
|
2017-03-31 07:26:24 +02:00
|
|
|
|
serverConfigMu.Unlock()
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
|
2017-03-31 07:26:24 +02:00
|
|
|
|
return nil
|
config/main: Re-write config files - add to new config v3
- New config format.
```
{
"version": "3",
"address": ":9000",
"backend": {
"type": "fs",
"disk": "/path"
},
"credential": {
"accessKey": "WLGDGYAQYIGI833EV05A",
"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
},
"region": "us-east-1",
"logger": {
"file": {
"enable": false,
"fileName": "",
"level": "error"
},
"syslog": {
"enable": false,
"address": "",
"level": "debug"
},
"console": {
"enable": true,
"level": "fatal"
}
}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
2016-02-13 00:27:10 +01:00
|
|
|
|
}
|