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-11-25 19:33:34 -05:00
|
|
|
xetcd "github.com/minio/minio/cmd/config/etcd"
|
|
|
|
"github.com/minio/minio/cmd/config/etcd/dns"
|
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-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
|
|
|
)
|
|
|
|
|
2019-11-27 12:36:08 -05:00
|
|
|
func init() {
|
|
|
|
var kvs = map[string]config.KVS{
|
|
|
|
config.EtcdSubSys: etcd.DefaultKVS,
|
|
|
|
config.CacheSubSys: cache.DefaultKVS,
|
|
|
|
config.CompressionSubSys: compress.DefaultKVS,
|
|
|
|
config.StorageClassSubSys: storageclass.DefaultKVS,
|
|
|
|
config.IdentityLDAPSubSys: xldap.DefaultKVS,
|
|
|
|
config.IdentityOpenIDSubSys: openid.DefaultKVS,
|
|
|
|
config.PolicyOPASubSys: opa.DefaultKVS,
|
|
|
|
config.RegionSubSys: config.DefaultRegionKVS,
|
|
|
|
config.CredentialsSubSys: config.DefaultCredentialKVS,
|
|
|
|
config.KmsVaultSubSys: crypto.DefaultKVS,
|
|
|
|
config.LoggerWebhookSubSys: logger.DefaultKVS,
|
|
|
|
config.AuditWebhookSubSys: logger.DefaultAuditKVS,
|
|
|
|
}
|
|
|
|
for k, v := range notify.DefaultNotificationKVS {
|
|
|
|
kvs[k] = v
|
|
|
|
}
|
|
|
|
config.RegisterDefaultKVS(kvs)
|
|
|
|
|
|
|
|
// Captures help for each sub-system
|
|
|
|
var helpSubSys = config.HelpKVS{
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.RegionSubSys,
|
|
|
|
Description: "Configure to describe the physical location of the server",
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.StorageClassSubSys,
|
|
|
|
Description: "Configure to control data and parity per object",
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.CacheSubSys,
|
|
|
|
Description: "Configure to enable edge caching",
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.CompressionSubSys,
|
|
|
|
Description: "Configure to enable streaming on disk compression",
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.EtcdSubSys,
|
|
|
|
Description: "Configure to enable 'etcd' configuration",
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.IdentityOpenIDSubSys,
|
|
|
|
Description: "Configure to enable OpenID SSO support",
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.IdentityLDAPSubSys,
|
|
|
|
Description: "Configure to enable LDAP SSO support",
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.PolicyOPASubSys,
|
|
|
|
Description: "Configure to enable external OPA policy support",
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.KmsVaultSubSys,
|
|
|
|
Description: "Configure to enable Vault based external KMS",
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.LoggerWebhookSubSys,
|
|
|
|
Description: "Configure to enable Webhook based logger",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.AuditWebhookSubSys,
|
|
|
|
Description: "Configure to enable Webhook based audit logger",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.NotifyWebhookSubSys,
|
|
|
|
Description: "Configure to publish events to Webhook target",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.NotifyAMQPSubSys,
|
|
|
|
Description: "Configure to publish events to AMQP target",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.NotifyKafkaSubSys,
|
|
|
|
Description: "Configure to publish events to Kafka target",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.NotifyMQTTSubSys,
|
|
|
|
Description: "Configure to publish events to MQTT target",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.NotifyNATSSubSys,
|
|
|
|
Description: "Configure to publish events to NATS target",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.NotifyNSQSubSys,
|
|
|
|
Description: "Configure to publish events to NSQ target",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.NotifyMySQLSubSys,
|
|
|
|
Description: "Configure to publish events to MySQL target",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.NotifyPostgresSubSys,
|
|
|
|
Description: "Configure to publish events to Postgres target",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.NotifyRedisSubSys,
|
|
|
|
Description: "Configure to publish events to Redis target",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
config.HelpKV{
|
|
|
|
Key: config.NotifyESSubSys,
|
|
|
|
Description: "Configure to publish events to Elasticsearch target",
|
|
|
|
MultipleTargets: true,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
var helpMap = map[string]config.HelpKVS{
|
|
|
|
"": helpSubSys, // Help for all sub-systems.
|
|
|
|
config.RegionSubSys: config.RegionHelp,
|
|
|
|
config.EtcdSubSys: etcd.Help,
|
|
|
|
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.LoggerWebhookSubSys: logger.Help,
|
|
|
|
config.AuditWebhookSubSys: 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,
|
|
|
|
}
|
|
|
|
|
|
|
|
config.RegisterHelpSubSys(helpMap)
|
|
|
|
}
|
|
|
|
|
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 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-11-25 19:33:34 -05:00
|
|
|
etcdCfg, err := xetcd.LookupConfig(s[config.EtcdSubSys][config.Default], globalRootCAs)
|
2019-10-30 03:04:39 -04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-11-25 19:33:34 -05:00
|
|
|
globalEtcdClient, err = xetcd.New(etcdCfg)
|
2019-10-30 03:04:39 -04:00
|
|
|
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 {
|
2019-11-25 19:33:34 -05:00
|
|
|
globalDNSConfig, err = dns.NewCoreDNS(etcdCfg.Config,
|
2019-10-30 03:04:39 -04:00
|
|
|
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-11-20 18:10:24 -05:00
|
|
|
globalWORMEnabled, err = config.LookupWorm()
|
2019-10-23 01:59:13 -04:00
|
|
|
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-11-19 16:48:13 -05:00
|
|
|
// Help - return sub-system level help
|
|
|
|
type Help struct {
|
|
|
|
SubSys string `json:"subSys"`
|
|
|
|
Description string `json:"description"`
|
|
|
|
MultipleTargets bool `json:"multipleTargets"`
|
|
|
|
KeysHelp config.HelpKVS `json:"keysHelp"`
|
|
|
|
}
|
|
|
|
|
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-11-19 16:48:13 -05:00
|
|
|
func GetHelp(subSys, key string, envOnly bool) (Help, error) {
|
2019-10-23 01:59:13 -04:00
|
|
|
if len(subSys) == 0 {
|
2019-11-27 12:36:08 -05:00
|
|
|
return Help{KeysHelp: config.HelpSubSysMap[subSys]}, nil
|
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-11-19 16:48:13 -05:00
|
|
|
return Help{}, config.Errorf("invalid number of arguments %s", subSys)
|
2019-10-30 03:04:39 -04:00
|
|
|
}
|
|
|
|
|
2019-11-27 12:36:08 -05:00
|
|
|
subSys = subSystemValue[0]
|
|
|
|
|
|
|
|
subSysHelp, ok := config.HelpSubSysMap[""].Lookup(subSys)
|
|
|
|
if !ok {
|
2019-11-19 16:48:13 -05:00
|
|
|
return Help{}, config.Errorf("unknown sub-system %s", subSys)
|
2018-09-06 11:03:18 -04:00
|
|
|
}
|
2019-10-30 03:04:39 -04:00
|
|
|
|
2019-11-27 12:36:08 -05:00
|
|
|
h, ok := config.HelpSubSysMap[subSys]
|
|
|
|
if !ok {
|
|
|
|
return Help{}, config.Errorf("unknown sub-system %s", subSys)
|
|
|
|
}
|
2019-10-23 01:59:13 -04:00
|
|
|
if key != "" {
|
2019-11-19 16:48:13 -05:00
|
|
|
value, ok := h.Lookup(key)
|
2019-10-23 01:59:13 -04:00
|
|
|
if !ok {
|
2019-11-19 16:48:13 -05:00
|
|
|
return Help{}, config.Errorf("unknown key %s for sub-system %s", key, subSys)
|
2019-10-30 03:04:39 -04:00
|
|
|
}
|
2019-11-19 16:48:13 -05:00
|
|
|
h = config.HelpKVS{value}
|
2018-11-07 13:23:13 -05:00
|
|
|
}
|
|
|
|
|
2019-11-19 16:48:13 -05:00
|
|
|
envHelp := config.HelpKVS{}
|
2019-10-30 03:04:39 -04:00
|
|
|
if envOnly {
|
2019-11-19 16:48:13 -05:00
|
|
|
for _, hkv := range h {
|
2019-10-30 03:04:39 -04:00
|
|
|
envK := config.EnvPrefix + strings.Join([]string{
|
2019-11-19 16:48:13 -05:00
|
|
|
strings.ToTitle(subSys), strings.ToTitle(hkv.Key),
|
2019-10-30 03:04:39 -04:00
|
|
|
}, config.EnvWordDelimiter)
|
2019-11-19 16:48:13 -05:00
|
|
|
envHelp = append(envHelp, config.HelpKV{
|
|
|
|
Key: envK,
|
|
|
|
Description: hkv.Description,
|
|
|
|
Optional: hkv.Optional,
|
|
|
|
Type: hkv.Type,
|
|
|
|
})
|
2019-10-30 03:04:39 -04:00
|
|
|
}
|
2019-11-19 16:48:13 -05:00
|
|
|
h = envHelp
|
|
|
|
}
|
|
|
|
|
|
|
|
return Help{
|
|
|
|
SubSys: subSys,
|
|
|
|
Description: subSysHelp.Description,
|
|
|
|
MultipleTargets: subSysHelp.MultipleTargets,
|
|
|
|
KeysHelp: h,
|
|
|
|
}, 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 newServerConfig() config.Config {
|
2019-11-13 20:38:05 -05:00
|
|
|
return config.New()
|
2017-03-01 12:17:04 -05:00
|
|
|
}
|
|
|
|
|
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-11-21 07:24:51 -05:00
|
|
|
return saveServerConfig(context.Background(), objAPI, globalServerConfig)
|
2017-02-07 15:51:43 -05:00
|
|
|
}
|
|
|
|
|
2019-10-23 01:59:13 -04:00
|
|
|
func getValidConfig(objAPI ObjectLayer) (config.Config, error) {
|
2019-11-13 20:38:05 -05:00
|
|
|
return readServerConfig(context.Background(), objAPI)
|
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
|
|
|
|
}
|