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-12 18:27:10 -05:00
|
|
|
/*
|
2019-09-09 19:12:29 -04:00
|
|
|
* MinIO Cloud Storage, (C) 2016-2019 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-12 18:27:10 -05: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-18 19:23:42 -04: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-12 18:27:10 -05:00
|
|
|
|
|
|
|
import (
|
2018-07-09 21:50:31 -04:00
|
|
|
"context"
|
2019-10-08 01:47:56 -04:00
|
|
|
"strings"
|
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-12 18:27:10 -05:00
|
|
|
"sync"
|
|
|
|
|
2019-10-04 13:35:33 -04:00
|
|
|
"github.com/minio/minio/cmd/config"
|
|
|
|
"github.com/minio/minio/cmd/config/cache"
|
|
|
|
"github.com/minio/minio/cmd/config/compress"
|
2019-10-30 03:04:39 -04:00
|
|
|
"github.com/minio/minio/cmd/config/etcd"
|
2019-10-23 01:59:13 -04:00
|
|
|
xldap "github.com/minio/minio/cmd/config/identity/ldap"
|
|
|
|
"github.com/minio/minio/cmd/config/identity/openid"
|
2019-10-09 02:11:15 -04:00
|
|
|
"github.com/minio/minio/cmd/config/notify"
|
2019-10-23 01:59:13 -04:00
|
|
|
"github.com/minio/minio/cmd/config/policy/opa"
|
2019-10-07 01:50:24 -04:00
|
|
|
"github.com/minio/minio/cmd/config/storageclass"
|
2018-08-17 15:52:14 -04:00
|
|
|
"github.com/minio/minio/cmd/crypto"
|
2019-02-06 15:07:03 -05:00
|
|
|
xhttp "github.com/minio/minio/cmd/http"
|
2018-04-19 20:24:43 -04:00
|
|
|
"github.com/minio/minio/cmd/logger"
|
2019-10-08 01:47:56 -04:00
|
|
|
"github.com/minio/minio/cmd/logger/target/http"
|
2019-10-30 03:04:39 -04:00
|
|
|
"github.com/minio/minio/pkg/dns"
|
2019-10-04 13:35:33 -04:00
|
|
|
"github.com/minio/minio/pkg/env"
|
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-12 18:27:10 -05:00
|
|
|
)
|
|
|
|
|
2017-03-31 01:26:24 -04:00
|
|
|
var (
|
2017-11-29 16:12:47 -05:00
|
|
|
// globalServerConfig server config.
|
2019-10-23 01:59:13 -04:00
|
|
|
globalServerConfig config.Config
|
2017-11-29 16:12:47 -05:00
|
|
|
globalServerConfigMu sync.RWMutex
|
2017-03-31 01:26:24 -04:00
|
|
|
)
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
func validateConfig(s config.Config) error {
|
2019-10-31 02:39:09 -04:00
|
|
|
// Disable merging env values with config for validation.
|
|
|
|
env.SetEnvOff()
|
|
|
|
|
2019-11-09 12:27:23 -05:00
|
|
|
// Enable env values to validate KMS.
|
2019-10-31 02:39:09 -04:00
|
|
|
defer env.SetEnvOn()
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if _, err := config.LookupCreds(s[config.CredentialsSubSys][config.Default]); err != nil {
|
|
|
|
return err
|
2018-08-19 16:57:18 -04:00
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if _, err := config.LookupRegion(s[config.RegionSubSys][config.Default]); err != nil {
|
|
|
|
return err
|
2019-10-07 01:50:24 -04:00
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if _, err := config.LookupWorm(s[config.WormSubSys][config.Default]); err != nil {
|
|
|
|
return err
|
2018-08-15 00:41:47 -04:00
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if globalIsXL {
|
|
|
|
if _, err := storageclass.LookupConfig(s[config.StorageClassSubSys][config.Default],
|
|
|
|
globalXLSetDriveCount); err != nil {
|
|
|
|
return err
|
2018-08-19 16:57:18 -04:00
|
|
|
}
|
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if _, err := cache.LookupConfig(s[config.CacheSubSys][config.Default]); err != nil {
|
|
|
|
return err
|
2018-08-19 16:57:18 -04:00
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if _, err := compress.LookupConfig(s[config.CompressionSubSys][config.Default]); err != nil {
|
|
|
|
return err
|
2018-07-18 14:22:29 -04:00
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
etcdCfg, err := etcd.LookupConfig(s[config.EtcdSubSys][config.Default], globalRootCAs)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if etcdCfg.Enabled {
|
|
|
|
etcdClnt, err := etcd.New(etcdCfg)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
etcdClnt.Close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
kmsCfg, err := crypto.LookupConfig(s[config.KmsVaultSubSys][config.Default])
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if kmsCfg.Vault.Enabled {
|
|
|
|
// Set env to enable master key validation.
|
|
|
|
// this is needed only for KMS.
|
|
|
|
env.SetEnvOn()
|
|
|
|
|
|
|
|
if _, err = crypto.NewKMS(kmsCfg); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if _, err := openid.LookupConfig(s[config.IdentityOpenIDSubSys][config.Default],
|
|
|
|
NewCustomHTTPTransport(), xhttp.DrainBody); err != nil {
|
|
|
|
return err
|
2018-07-18 14:22:29 -04:00
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if _, err := xldap.Lookup(s[config.IdentityLDAPSubSys][config.Default],
|
|
|
|
globalRootCAs); err != nil {
|
|
|
|
return err
|
2018-07-18 14:22:29 -04:00
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if _, err := opa.LookupConfig(s[config.PolicyOPASubSys][config.Default],
|
|
|
|
NewCustomHTTPTransport(), xhttp.DrainBody); err != nil {
|
|
|
|
return err
|
2018-07-18 14:22:29 -04:00
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if _, err := logger.LookupConfig(s); err != nil {
|
|
|
|
return err
|
2018-07-18 14:22:29 -04:00
|
|
|
}
|
2019-11-09 12:27:23 -05:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
return notify.TestNotificationTargets(s, GlobalServiceDoneCh, globalRootCAs)
|
|
|
|
}
|
2018-07-18 14:22:29 -04:00
|
|
|
|
2019-10-31 02:39:09 -04:00
|
|
|
func lookupConfigs(s config.Config) (err error) {
|
2019-10-23 01:59:13 -04:00
|
|
|
if !globalActiveCred.IsValid() {
|
2019-10-30 03:04:39 -04:00
|
|
|
// Env doesn't seem to be set, we fallback to lookup creds from the config.
|
2019-10-23 01:59:13 -04:00
|
|
|
globalActiveCred, err = config.LookupCreds(s[config.CredentialsSubSys][config.Default])
|
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Invalid credentials configuration: %s", err)
|
2018-07-18 14:22:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-30 03:04:39 -04:00
|
|
|
etcdCfg, err := etcd.LookupConfig(s[config.EtcdSubSys][config.Default], globalRootCAs)
|
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to initialize etcd config: %s", err)
|
2019-10-30 03:04:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
globalEtcdClient, err = etcd.New(etcdCfg)
|
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to initialize etcd config: %s", err)
|
2019-10-30 03:04:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if len(globalDomainNames) != 0 && !globalDomainIPs.IsEmpty() && globalEtcdClient != nil {
|
|
|
|
globalDNSConfig, err = dns.NewCoreDNS(globalEtcdClient,
|
|
|
|
dns.DomainNames(globalDomainNames),
|
|
|
|
dns.DomainIPs(globalDomainIPs),
|
|
|
|
dns.DomainPort(globalMinioPort),
|
|
|
|
dns.CoreDNSPath(etcdCfg.CoreDNSPath),
|
|
|
|
)
|
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to initialize DNS config for %s: %s", globalDomainNames, err)
|
2019-10-30 03:04:39 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
globalServerRegion, err = config.LookupRegion(s[config.RegionSubSys][config.Default])
|
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Invalid region configuration: %s", err)
|
2018-08-15 00:41:47 -04:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
globalWORMEnabled, err = config.LookupWorm(s[config.WormSubSys][config.Default])
|
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Invalid worm configuration: %s", err)
|
|
|
|
|
2018-08-15 00:41:47 -04:00
|
|
|
}
|
|
|
|
|
2019-10-07 01:50:24 -04:00
|
|
|
if globalIsXL {
|
2019-10-23 01:59:13 -04:00
|
|
|
globalStorageClass, err = storageclass.LookupConfig(s[config.StorageClassSubSys][config.Default],
|
|
|
|
globalXLSetDriveCount)
|
2019-10-07 01:50:24 -04:00
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to initialize storage class config: %s", err)
|
2019-10-07 01:50:24 -04:00
|
|
|
}
|
2018-08-15 00:41:47 -04:00
|
|
|
}
|
2018-04-05 11:18:42 -04:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
globalCacheConfig, err = cache.LookupConfig(s[config.CacheSubSys][config.Default])
|
2019-10-04 13:35:33 -04:00
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to setup cache: %s", err)
|
2018-08-15 00:41:47 -04:00
|
|
|
}
|
2018-08-17 15:52:14 -04:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if globalCacheConfig.Enabled {
|
2019-10-04 13:35:33 -04:00
|
|
|
if cacheEncKey := env.Get(cache.EnvCacheEncryptionMasterKey, ""); cacheEncKey != "" {
|
2019-10-08 01:47:56 -04:00
|
|
|
globalCacheKMS, err = crypto.ParseMasterKey(cacheEncKey)
|
2019-10-04 13:35:33 -04:00
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to setup encryption cache: %s", err)
|
2019-10-04 13:35:33 -04:00
|
|
|
}
|
|
|
|
}
|
2018-08-17 15:52:14 -04:00
|
|
|
}
|
2018-09-27 23:36:17 -04:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
kmsCfg, err := crypto.LookupConfig(s[config.KmsVaultSubSys][config.Default])
|
2019-10-08 01:47:56 -04:00
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to setup KMS config: %s", err)
|
2019-10-08 01:47:56 -04:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
GlobalKMS, err = crypto.NewKMS(kmsCfg)
|
2019-10-08 01:47:56 -04:00
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to setup KMS with current KMS config: %s", err)
|
2019-10-08 01:47:56 -04:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
// Enable auto-encryption if enabled
|
|
|
|
globalAutoEncryption = kmsCfg.AutoEncryption
|
2018-10-12 14:32:18 -04:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
globalCompressConfig, err = compress.LookupConfig(s[config.CompressionSubSys][config.Default])
|
2019-10-04 13:35:33 -04:00
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to setup Compression: %s", err)
|
2019-10-04 13:35:33 -04:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
globalOpenIDConfig, err = openid.LookupConfig(s[config.IdentityOpenIDSubSys][config.Default],
|
|
|
|
NewCustomHTTPTransport(), xhttp.DrainBody)
|
2019-10-07 01:50:24 -04:00
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to initialize OpenID: %s", err)
|
2019-10-07 01:50:24 -04:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
opaCfg, err := opa.LookupConfig(s[config.PolicyOPASubSys][config.Default],
|
|
|
|
NewCustomHTTPTransport(), xhttp.DrainBody)
|
2019-10-07 01:50:24 -04:00
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to initialize OPA: %s", err)
|
2018-10-12 14:32:18 -04:00
|
|
|
}
|
2019-09-09 19:12:29 -04:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
globalOpenIDValidators = getOpenIDValidators(globalOpenIDConfig)
|
|
|
|
globalPolicyOPA = opa.New(opaCfg)
|
2019-10-07 01:50:24 -04:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
globalLDAPConfig, err = xldap.Lookup(s[config.IdentityLDAPSubSys][config.Default],
|
|
|
|
globalRootCAs)
|
2019-09-09 19:12:29 -04:00
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to parse LDAP configuration: %s", err)
|
2019-09-09 19:12:29 -04:00
|
|
|
}
|
2019-10-08 01:47:56 -04:00
|
|
|
|
|
|
|
// Load logger targets based on user's configuration
|
|
|
|
loggerUserAgent := getUserAgent(getMinioMode())
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
loggerCfg, err := logger.LookupConfig(s)
|
2019-10-08 01:47:56 -04:00
|
|
|
if err != nil {
|
2019-10-31 02:39:09 -04:00
|
|
|
return config.Errorf("Unable to initialize logger: %s", err)
|
2019-10-08 01:47:56 -04:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
for _, l := range loggerCfg.HTTP {
|
2019-10-08 01:47:56 -04:00
|
|
|
if l.Enabled {
|
|
|
|
// Enable http logging
|
2019-10-11 21:50:54 -04:00
|
|
|
logger.AddTarget(http.New(l.Endpoint, loggerUserAgent, string(logger.All), NewCustomHTTPTransport()))
|
2019-10-08 01:47:56 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
for _, l := range loggerCfg.Audit {
|
2019-10-08 01:47:56 -04:00
|
|
|
if l.Enabled {
|
|
|
|
// Enable http audit logging
|
2019-10-11 21:50:54 -04:00
|
|
|
logger.AddAuditTarget(http.New(l.Endpoint, loggerUserAgent, string(logger.All), NewCustomHTTPTransport()))
|
2019-10-08 01:47:56 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
// Enable console logging
|
|
|
|
logger.AddTarget(globalConsoleSys.Console())
|
2019-10-31 02:39:09 -04:00
|
|
|
|
|
|
|
return nil
|
2017-03-31 01:26:24 -04:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
var helpMap = map[string]config.HelpKV{
|
|
|
|
config.RegionSubSys: config.RegionHelp,
|
|
|
|
config.WormSubSys: config.WormHelp,
|
2019-10-30 03:04:39 -04:00
|
|
|
config.EtcdSubSys: etcd.Help,
|
2019-10-23 01:59:13 -04:00
|
|
|
config.CacheSubSys: cache.Help,
|
|
|
|
config.CompressionSubSys: compress.Help,
|
|
|
|
config.StorageClassSubSys: storageclass.Help,
|
|
|
|
config.IdentityOpenIDSubSys: openid.Help,
|
|
|
|
config.IdentityLDAPSubSys: xldap.Help,
|
|
|
|
config.PolicyOPASubSys: opa.Help,
|
|
|
|
config.KmsVaultSubSys: crypto.Help,
|
|
|
|
config.LoggerHTTPSubSys: logger.Help,
|
|
|
|
config.LoggerHTTPAuditSubSys: logger.HelpAudit,
|
|
|
|
config.NotifyAMQPSubSys: notify.HelpAMQP,
|
|
|
|
config.NotifyKafkaSubSys: notify.HelpKafka,
|
|
|
|
config.NotifyMQTTSubSys: notify.HelpMQTT,
|
|
|
|
config.NotifyNATSSubSys: notify.HelpNATS,
|
|
|
|
config.NotifyNSQSubSys: notify.HelpNSQ,
|
|
|
|
config.NotifyMySQLSubSys: notify.HelpMySQL,
|
|
|
|
config.NotifyPostgresSubSys: notify.HelpPostgres,
|
|
|
|
config.NotifyRedisSubSys: notify.HelpRedis,
|
|
|
|
config.NotifyWebhookSubSys: notify.HelpWebhook,
|
|
|
|
config.NotifyESSubSys: notify.HelpES,
|
|
|
|
}
|
2018-09-06 11:03:18 -04:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
// GetHelp - returns help for sub-sys, a key for a sub-system or all the help.
|
2019-10-30 03:04:39 -04:00
|
|
|
func GetHelp(subSys, key string, envOnly bool) (config.HelpKV, error) {
|
2019-10-23 01:59:13 -04:00
|
|
|
if len(subSys) == 0 {
|
|
|
|
return nil, config.Error("no help available for empty sub-system inputs")
|
2018-09-06 11:03:18 -04:00
|
|
|
}
|
2019-10-30 03:04:39 -04:00
|
|
|
subSystemValue := strings.SplitN(subSys, config.SubSystemSeparator, 2)
|
|
|
|
if len(subSystemValue) == 0 {
|
2019-10-31 02:39:09 -04:00
|
|
|
return nil, config.Errorf("invalid number of arguments %s", subSys)
|
2019-10-30 03:04:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if !config.SubSystems.Contains(subSystemValue[0]) {
|
2019-10-31 02:39:09 -04:00
|
|
|
return nil, config.Errorf("unknown sub-system %s", subSys)
|
2018-09-06 11:03:18 -04:00
|
|
|
}
|
2019-10-30 03:04:39 -04:00
|
|
|
|
|
|
|
help := helpMap[subSystemValue[0]]
|
2019-10-23 01:59:13 -04:00
|
|
|
if key != "" {
|
|
|
|
value, ok := help[key]
|
|
|
|
if !ok {
|
2019-10-31 02:39:09 -04:00
|
|
|
return nil, config.Errorf("unknown key %s for sub-system %s", key, subSys)
|
2018-11-07 13:23:13 -05:00
|
|
|
}
|
2019-10-30 03:04:39 -04:00
|
|
|
help = config.HelpKV{
|
|
|
|
key: value,
|
|
|
|
}
|
2018-11-07 13:23:13 -05:00
|
|
|
}
|
|
|
|
|
2019-10-30 03:04:39 -04:00
|
|
|
envHelp := config.HelpKV{}
|
|
|
|
if envOnly {
|
|
|
|
for k, v := range help {
|
|
|
|
envK := config.EnvPrefix + strings.Join([]string{
|
|
|
|
strings.ToTitle(subSys), strings.ToTitle(k),
|
|
|
|
}, config.EnvWordDelimiter)
|
|
|
|
envHelp[envK] = v
|
|
|
|
}
|
|
|
|
help = envHelp
|
2018-09-06 11:03:18 -04:00
|
|
|
}
|
2019-10-30 03:04:39 -04:00
|
|
|
|
|
|
|
return help, nil
|
2019-10-23 01:59:13 -04:00
|
|
|
}
|
2018-09-06 11:03:18 -04:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
func configDefaultKVS() map[string]config.KVS {
|
|
|
|
m := make(map[string]config.KVS)
|
|
|
|
for k, tgt := range newServerConfig() {
|
|
|
|
m[k] = tgt[config.Default]
|
2018-09-06 11:03:18 -04:00
|
|
|
}
|
2019-10-23 01:59:13 -04:00
|
|
|
return m
|
2018-09-06 11:03:18 -04:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
func newServerConfig() config.Config {
|
|
|
|
srvCfg := config.New()
|
|
|
|
for k := range srvCfg {
|
|
|
|
// Initialize with default KVS
|
|
|
|
switch k {
|
2019-10-30 03:04:39 -04:00
|
|
|
case config.EtcdSubSys:
|
|
|
|
srvCfg[k][config.Default] = etcd.DefaultKVS
|
2019-10-23 01:59:13 -04:00
|
|
|
case config.CacheSubSys:
|
|
|
|
srvCfg[k][config.Default] = cache.DefaultKVS
|
|
|
|
case config.CompressionSubSys:
|
|
|
|
srvCfg[k][config.Default] = compress.DefaultKVS
|
|
|
|
case config.StorageClassSubSys:
|
|
|
|
srvCfg[k][config.Default] = storageclass.DefaultKVS
|
|
|
|
case config.IdentityLDAPSubSys:
|
|
|
|
srvCfg[k][config.Default] = xldap.DefaultKVS
|
|
|
|
case config.IdentityOpenIDSubSys:
|
|
|
|
srvCfg[k][config.Default] = openid.DefaultKVS
|
|
|
|
case config.PolicyOPASubSys:
|
|
|
|
srvCfg[k][config.Default] = opa.DefaultKVS
|
|
|
|
case config.WormSubSys:
|
|
|
|
srvCfg[k][config.Default] = config.DefaultWormKVS
|
|
|
|
case config.RegionSubSys:
|
|
|
|
srvCfg[k][config.Default] = config.DefaultRegionKVS
|
|
|
|
case config.CredentialsSubSys:
|
|
|
|
srvCfg[k][config.Default] = config.DefaultCredentialKVS
|
|
|
|
case config.KmsVaultSubSys:
|
|
|
|
srvCfg[k][config.Default] = crypto.DefaultKVS
|
|
|
|
case config.LoggerHTTPSubSys:
|
|
|
|
srvCfg[k][config.Default] = logger.DefaultKVS
|
|
|
|
case config.LoggerHTTPAuditSubSys:
|
|
|
|
srvCfg[k][config.Default] = logger.DefaultAuditKVS
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for k, v := range notify.DefaultNotificationKVS {
|
|
|
|
srvCfg[k][config.Default] = v
|
2017-02-27 17:59:53 -05:00
|
|
|
}
|
2017-03-01 12:17:04 -05:00
|
|
|
return srvCfg
|
|
|
|
}
|
|
|
|
|
2018-10-09 17:00:01 -04:00
|
|
|
// newSrvConfig - initialize a new server config, saves env parameters if
|
2018-08-15 00:41:47 -04:00
|
|
|
// found, otherwise use default parameters
|
2018-10-09 17:00:01 -04:00
|
|
|
func newSrvConfig(objAPI ObjectLayer) error {
|
2018-08-15 00:41:47 -04:00
|
|
|
// Initialize server config.
|
|
|
|
srvCfg := newServerConfig()
|
|
|
|
|
|
|
|
// Override any values from ENVs.
|
2019-10-31 02:39:09 -04:00
|
|
|
if err := lookupConfigs(srvCfg); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-29 17:38:26 -04:00
|
|
|
|
2017-02-07 15:51:43 -05:00
|
|
|
// hold the mutex lock before a new config is assigned.
|
2017-11-29 16:12:47 -05:00
|
|
|
globalServerConfigMu.Lock()
|
|
|
|
globalServerConfig = srvCfg
|
|
|
|
globalServerConfigMu.Unlock()
|
2017-02-07 15:51:43 -05:00
|
|
|
|
|
|
|
// Save config into file.
|
2019-10-23 01:59:13 -04:00
|
|
|
return saveServerConfig(context.Background(), objAPI, globalServerConfig, nil)
|
2017-02-07 15:51:43 -05:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
func getValidConfig(objAPI ObjectLayer) (config.Config, error) {
|
2018-08-15 00:41:47 -04:00
|
|
|
srvCfg, err := readServerConfig(context.Background(), objAPI)
|
2018-02-02 21:18:52 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-10-30 03:04:39 -04:00
|
|
|
defaultKVS := configDefaultKVS()
|
|
|
|
for _, k := range config.SubSystems.ToSlice() {
|
|
|
|
_, ok := srvCfg[k][config.Default]
|
|
|
|
if !ok {
|
|
|
|
// Populate default configs for any new
|
|
|
|
// sub-systems added automatically.
|
|
|
|
srvCfg[k][config.Default] = defaultKVS[k]
|
|
|
|
}
|
|
|
|
}
|
2019-10-23 01:59:13 -04: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-12 18:27:10 -05:00
|
|
|
}
|
|
|
|
|
2019-10-30 03:04:39 -04:00
|
|
|
// loadConfig - loads a new config from disk, overrides params
|
|
|
|
// from env if found and valid
|
2018-08-15 00:41:47 -04:00
|
|
|
func loadConfig(objAPI ObjectLayer) error {
|
|
|
|
srvCfg, err := getValidConfig(objAPI)
|
2017-03-31 01:26:24 -04:00
|
|
|
if err != nil {
|
2019-10-30 03:04:39 -04:00
|
|
|
return err
|
2017-03-16 14:06:17 -04:00
|
|
|
}
|
2016-12-07 06:41:54 -05:00
|
|
|
|
2018-08-15 00:41:47 -04:00
|
|
|
// Override any values from ENVs.
|
2019-10-31 02:39:09 -04:00
|
|
|
if err = lookupConfigs(srvCfg); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2018-03-29 17:38:26 -04:00
|
|
|
|
2017-03-31 01:26:24 -04:00
|
|
|
// hold the mutex lock before a new config is assigned.
|
2017-11-29 16:12:47 -05:00
|
|
|
globalServerConfigMu.Lock()
|
|
|
|
globalServerConfig = srvCfg
|
|
|
|
globalServerConfigMu.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-12 18:27:10 -05:00
|
|
|
|
2017-03-31 01:26:24 -04: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-12 18:27:10 -05:00
|
|
|
}
|
2018-03-15 16:03:41 -04:00
|
|
|
|
2019-10-01 18:07:20 -04:00
|
|
|
// getOpenIDValidators - returns ValidatorList which contains
|
2018-10-09 17:00:01 -04:00
|
|
|
// enabled providers in server config.
|
|
|
|
// A new authentication provider is added like below
|
2019-10-01 18:07:20 -04:00
|
|
|
// * Add a new provider in pkg/iam/openid package.
|
2019-10-23 01:59:13 -04:00
|
|
|
func getOpenIDValidators(cfg openid.Config) *openid.Validators {
|
2019-10-01 18:07:20 -04:00
|
|
|
validators := openid.NewValidators()
|
2018-10-09 17:00:01 -04:00
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
if cfg.JWKS.URL != nil {
|
|
|
|
validators.Add(openid.NewJWT(cfg))
|
2018-10-09 17:00:01 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return validators
|
|
|
|
}
|