| 
									
										
											  
											
												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 07:27:10 +08:00
										 |  |  |  | /* | 
					
						
							| 
									
										
										
										
											2019-04-10 02:39:42 +08:00
										 |  |  |  |  * MinIO Cloud Storage, (C) 2016, 2017, 2018 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 07:27:10 +08: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 07:23:42 +08: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 07:27:10 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 	"context" | 
					
						
							| 
									
										
										
										
											2017-03-02 01:17:04 +08:00
										 |  |  |  | 	"errors" | 
					
						
							| 
									
										
										
										
											2017-03-17 02:06:17 +08:00
										 |  |  |  | 	"fmt" | 
					
						
							| 
									
										
										
										
											2018-10-13 02:32:18 +08:00
										 |  |  |  | 	"os" | 
					
						
							| 
									
										
										
										
											2018-02-01 00:15:54 +08:00
										 |  |  |  | 	"reflect" | 
					
						
							| 
									
										
											  
											
												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 07:27:10 +08:00
										 |  |  |  | 	"sync" | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 	"github.com/minio/minio/cmd/crypto" | 
					
						
							| 
									
										
										
										
											2019-02-07 04:07:03 +08:00
										 |  |  |  | 	xhttp "github.com/minio/minio/cmd/http" | 
					
						
							| 
									
										
										
										
											2018-04-20 08:24:43 +08:00
										 |  |  |  | 	"github.com/minio/minio/cmd/logger" | 
					
						
							| 
									
										
										
										
											2017-11-01 02:54:32 +08:00
										 |  |  |  | 	"github.com/minio/minio/pkg/auth" | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	"github.com/minio/minio/pkg/event" | 
					
						
							|  |  |  |  | 	"github.com/minio/minio/pkg/event/target" | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	"github.com/minio/minio/pkg/iam/policy" | 
					
						
							|  |  |  |  | 	"github.com/minio/minio/pkg/iam/validator" | 
					
						
							| 
									
										
										
										
											2018-10-13 02:32:18 +08:00
										 |  |  |  | 	xnet "github.com/minio/minio/pkg/net" | 
					
						
							| 
									
										
											  
											
												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 07:27:10 +08:00
										 |  |  |  | ) | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | // Steps to move from version N to version N+1
 | 
					
						
							|  |  |  |  | // 1. Add new struct serverConfigVN+1 in config-versions.go
 | 
					
						
							| 
									
										
										
										
											2017-12-18 13:00:12 +08:00
										 |  |  |  | // 2. Set serverConfigVersion to "N+1"
 | 
					
						
							|  |  |  |  | // 3. Set serverConfig to serverConfigVN+1
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | // 4. Add new migration function (ex. func migrateVNToVN+1()) in config-migrate.go
 | 
					
						
							|  |  |  |  | // 5. Call migrateVNToVN+1() from migrateConfig() in config-migrate.go
 | 
					
						
							|  |  |  |  | // 6. Make changes in config-current_test.go for any test change
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | // Config version
 | 
					
						
							| 
									
										
										
										
											2018-11-30 13:16:17 +08:00
										 |  |  |  | const serverConfigVersion = "33" | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-30 13:16:17 +08:00
										 |  |  |  | type serverConfig = serverConfigV33 | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | var ( | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | 	// globalServerConfig server config.
 | 
					
						
							|  |  |  |  | 	globalServerConfig   *serverConfig | 
					
						
							|  |  |  |  | 	globalServerConfigMu sync.RWMutex | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | ) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // GetVersion get current config version.
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | func (s *serverConfig) GetVersion() string { | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | 	return s.Version | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-09 03:14:32 +08:00
										 |  |  |  | // SetRegion set a new region.
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | func (s *serverConfig) SetRegion(region string) { | 
					
						
							| 
									
										
										
										
											2017-08-09 03:14:32 +08:00
										 |  |  |  | 	// Save new region.
 | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | 	s.Region = region | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // GetRegion get current region.
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | func (s *serverConfig) GetRegion() string { | 
					
						
							| 
									
										
										
										
											2018-08-20 04:57:18 +08:00
										 |  |  |  | 	if globalIsEnvRegion { | 
					
						
							|  |  |  |  | 		return globalServerRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if s == nil { | 
					
						
							|  |  |  |  | 		return "" | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | 	return s.Region | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | // SetCredential sets new credential and returns the previous credential.
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | func (s *serverConfig) SetCredential(creds auth.Credentials) (prevCred auth.Credentials) { | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	if creds.IsValid() && globalActiveCred.IsValid() { | 
					
						
							|  |  |  |  | 		globalActiveCred = creds | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-09 03:14:32 +08:00
										 |  |  |  | 	// Save previous credential.
 | 
					
						
							|  |  |  |  | 	prevCred = s.Credential | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | 	// Set updated credential.
 | 
					
						
							|  |  |  |  | 	s.Credential = creds | 
					
						
							| 
									
										
										
										
											2017-08-09 03:14:32 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Return previous credential.
 | 
					
						
							|  |  |  |  | 	return prevCred | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // GetCredentials get current credentials.
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | func (s *serverConfig) GetCredential() auth.Credentials { | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	if globalActiveCred.IsValid() { | 
					
						
							|  |  |  |  | 		return globalActiveCred | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | 	return s.Credential | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  |  | // SetWorm set if worm is enabled.
 | 
					
						
							|  |  |  |  | func (s *serverConfig) SetWorm(b bool) { | 
					
						
							|  |  |  |  | 	// Set the new value.
 | 
					
						
							|  |  |  |  | 	s.Worm = BoolFlag(b) | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | func (s *serverConfig) SetStorageClass(standardClass, rrsClass storageClass) { | 
					
						
							| 
									
										
										
										
											2018-01-09 14:26:13 +08:00
										 |  |  |  | 	s.StorageClass.Standard = standardClass | 
					
						
							|  |  |  |  | 	s.StorageClass.RRS = rrsClass | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-01 15:30:07 +08:00
										 |  |  |  | // GetStorageClass reads storage class fields from current config.
 | 
					
						
							| 
									
										
										
										
											2017-12-28 16:49:45 +08:00
										 |  |  |  | // It returns the standard and reduced redundancy storage class struct
 | 
					
						
							| 
									
										
										
										
											2018-01-09 14:26:13 +08:00
										 |  |  |  | func (s *serverConfig) GetStorageClass() (storageClass, storageClass) { | 
					
						
							| 
									
										
										
										
											2018-08-20 04:57:18 +08:00
										 |  |  |  | 	if globalIsStorageClass { | 
					
						
							|  |  |  |  | 		return globalStandardStorageClass, globalRRStorageClass | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if s == nil { | 
					
						
							|  |  |  |  | 		return storageClass{}, storageClass{} | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-01-09 14:26:13 +08:00
										 |  |  |  | 	return s.StorageClass.Standard, s.StorageClass.RRS | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  |  | // GetWorm get current credentials.
 | 
					
						
							|  |  |  |  | func (s *serverConfig) GetWorm() bool { | 
					
						
							| 
									
										
										
										
											2018-08-25 05:36:14 +08:00
										 |  |  |  | 	if globalIsEnvWORM { | 
					
						
							|  |  |  |  | 		return globalWORMEnabled | 
					
						
							| 
									
										
										
										
											2018-08-20 04:57:18 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if s == nil { | 
					
						
							|  |  |  |  | 		return false | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  |  | 	return bool(s.Worm) | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | // SetCacheConfig sets the current cache config
 | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  |  | func (s *serverConfig) SetCacheConfig(drives, exclude []string, expiry int, maxuse int) { | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 	s.Cache.Drives = drives | 
					
						
							|  |  |  |  | 	s.Cache.Exclude = exclude | 
					
						
							|  |  |  |  | 	s.Cache.Expiry = expiry | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  |  | 	s.Cache.MaxUse = maxuse | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // GetCacheConfig gets the current cache config
 | 
					
						
							|  |  |  |  | func (s *serverConfig) GetCacheConfig() CacheConfig { | 
					
						
							| 
									
										
										
										
											2018-08-20 04:57:18 +08:00
										 |  |  |  | 	if globalIsDiskCacheEnabled { | 
					
						
							|  |  |  |  | 		return CacheConfig{ | 
					
						
							|  |  |  |  | 			Drives:  globalCacheDrives, | 
					
						
							|  |  |  |  | 			Exclude: globalCacheExcludes, | 
					
						
							|  |  |  |  | 			Expiry:  globalCacheExpiry, | 
					
						
							|  |  |  |  | 			MaxUse:  globalCacheMaxUse, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if s == nil { | 
					
						
							|  |  |  |  | 		return CacheConfig{} | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-30 05:38:26 +08:00
										 |  |  |  | 	return s.Cache | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | func (s *serverConfig) Validate() error { | 
					
						
							| 
									
										
										
										
											2018-08-20 04:57:18 +08:00
										 |  |  |  | 	if s == nil { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 	if s.Version != serverConfigVersion { | 
					
						
							|  |  |  |  | 		return fmt.Errorf("configuration version mismatch. Expected: ‘%s’, Got: ‘%s’", serverConfigVersion, s.Version) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Validate credential fields only when
 | 
					
						
							|  |  |  |  | 	// they are not set via the environment
 | 
					
						
							|  |  |  |  | 	// Error out if global is env credential is not set and config has invalid credential
 | 
					
						
							|  |  |  |  | 	if !globalIsEnvCreds && !s.Credential.IsValid() { | 
					
						
							|  |  |  |  | 		return errors.New("invalid credential in config file") | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Region: nothing to validate
 | 
					
						
							| 
									
										
										
										
											2018-09-21 05:56:32 +08:00
										 |  |  |  | 	// Worm, Cache and StorageClass values are already validated during json unmarshal
 | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 	for _, v := range s.Notify.AMQP { | 
					
						
							|  |  |  |  | 		if err := v.Validate(); err != nil { | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 			return fmt.Errorf("amqp: %s", err) | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for _, v := range s.Notify.Elasticsearch { | 
					
						
							|  |  |  |  | 		if err := v.Validate(); err != nil { | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 			return fmt.Errorf("elasticsearch: %s", err) | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for _, v := range s.Notify.Kafka { | 
					
						
							|  |  |  |  | 		if err := v.Validate(); err != nil { | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 			return fmt.Errorf("kafka: %s", err) | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for _, v := range s.Notify.MQTT { | 
					
						
							|  |  |  |  | 		if err := v.Validate(); err != nil { | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 			return fmt.Errorf("mqtt: %s", err) | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for _, v := range s.Notify.MySQL { | 
					
						
							|  |  |  |  | 		if err := v.Validate(); err != nil { | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 			return fmt.Errorf("mysql: %s", err) | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for _, v := range s.Notify.NATS { | 
					
						
							|  |  |  |  | 		if err := v.Validate(); err != nil { | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 			return fmt.Errorf("nats: %s", err) | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 	for _, v := range s.Notify.NSQ { | 
					
						
							|  |  |  |  | 		if err := v.Validate(); err != nil { | 
					
						
							|  |  |  |  | 			return fmt.Errorf("nsq: %s", err) | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 	for _, v := range s.Notify.PostgreSQL { | 
					
						
							|  |  |  |  | 		if err := v.Validate(); err != nil { | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 			return fmt.Errorf("postgreSQL: %s", err) | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for _, v := range s.Notify.Redis { | 
					
						
							|  |  |  |  | 		if err := v.Validate(); err != nil { | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 			return fmt.Errorf("redis: %s", err) | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for _, v := range s.Notify.Webhook { | 
					
						
							|  |  |  |  | 		if err := v.Validate(); err != nil { | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 			return fmt.Errorf("webhook: %s", err) | 
					
						
							| 
									
										
										
										
											2018-07-19 02:22:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | // SetCompressionConfig sets the current compression config
 | 
					
						
							|  |  |  |  | func (s *serverConfig) SetCompressionConfig(extensions []string, mimeTypes []string) { | 
					
						
							|  |  |  |  | 	s.Compression.Extensions = extensions | 
					
						
							|  |  |  |  | 	s.Compression.MimeTypes = mimeTypes | 
					
						
							|  |  |  |  | 	s.Compression.Enabled = globalIsCompressionEnabled | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // GetCompressionConfig gets the current compression config
 | 
					
						
							|  |  |  |  | func (s *serverConfig) GetCompressionConfig() compressionConfig { | 
					
						
							|  |  |  |  | 	return s.Compression | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | func (s *serverConfig) loadFromEnvs() { | 
					
						
							|  |  |  |  | 	// If env is set override the credentials from config file.
 | 
					
						
							|  |  |  |  | 	if globalIsEnvCreds { | 
					
						
							|  |  |  |  | 		s.SetCredential(globalActiveCred) | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	if globalIsEnvWORM { | 
					
						
							|  |  |  |  | 		s.SetWorm(globalWORMEnabled) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if globalIsEnvRegion { | 
					
						
							|  |  |  |  | 		s.SetRegion(globalServerRegion) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if globalIsStorageClass { | 
					
						
							|  |  |  |  | 		s.SetStorageClass(globalStandardStorageClass, globalRRStorageClass) | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	if globalIsDiskCacheEnabled { | 
					
						
							|  |  |  |  | 		s.SetCacheConfig(globalCacheDrives, globalCacheExcludes, globalCacheExpiry, globalCacheMaxUse) | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-12 14:50:29 +08:00
										 |  |  |  | 	if err := Environment.LookupKMSConfig(s.KMS); err != nil { | 
					
						
							|  |  |  |  | 		logger.FatalIf(err, "Unable to setup the KMS") | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if globalIsEnvCompression { | 
					
						
							|  |  |  |  | 		s.SetCompressionConfig(globalCompressExtensions, globalCompressMimeTypes) | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-13 02:32:18 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if jwksURL, ok := os.LookupEnv("MINIO_IAM_JWKS_URL"); ok { | 
					
						
							|  |  |  |  | 		if u, err := xnet.ParseURL(jwksURL); err == nil { | 
					
						
							|  |  |  |  | 			s.OpenID.JWKS.URL = u | 
					
						
							| 
									
										
										
										
											2019-02-04 13:01:11 +08:00
										 |  |  |  | 			logger.FatalIf(s.OpenID.JWKS.PopulatePublicKey(), "Unable to populate public key from JWKS URL") | 
					
						
							| 
									
										
										
										
											2018-10-13 02:32:18 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if opaURL, ok := os.LookupEnv("MINIO_IAM_OPA_URL"); ok { | 
					
						
							|  |  |  |  | 		if u, err := xnet.ParseURL(opaURL); err == nil { | 
					
						
							|  |  |  |  | 			s.Policy.OPA.URL = u | 
					
						
							|  |  |  |  | 			s.Policy.OPA.AuthToken = os.Getenv("MINIO_IAM_OPA_AUTHTOKEN") | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 23:03:18 +08:00
										 |  |  |  | // TestNotificationTargets tries to establish connections to all notification
 | 
					
						
							|  |  |  |  | // targets when enabled. This is a good way to make sure all configurations
 | 
					
						
							|  |  |  |  | // set by the user can work.
 | 
					
						
							|  |  |  |  | func (s *serverConfig) TestNotificationTargets() error { | 
					
						
							|  |  |  |  | 	for k, v := range s.Notify.AMQP { | 
					
						
							|  |  |  |  | 		if !v.Enable { | 
					
						
							|  |  |  |  | 			continue | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t, err := target.NewAMQPTarget(k, v) | 
					
						
							|  |  |  |  | 		if err != nil { | 
					
						
							|  |  |  |  | 			return fmt.Errorf("amqp(%s): %s", k, err.Error()) | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t.Close() | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for k, v := range s.Notify.Elasticsearch { | 
					
						
							|  |  |  |  | 		if !v.Enable { | 
					
						
							|  |  |  |  | 			continue | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t, err := target.NewElasticsearchTarget(k, v) | 
					
						
							|  |  |  |  | 		if err != nil { | 
					
						
							|  |  |  |  | 			return fmt.Errorf("elasticsearch(%s): %s", k, err.Error()) | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t.Close() | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for k, v := range s.Notify.Kafka { | 
					
						
							|  |  |  |  | 		if !v.Enable { | 
					
						
							|  |  |  |  | 			continue | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t, err := target.NewKafkaTarget(k, v) | 
					
						
							|  |  |  |  | 		if err != nil { | 
					
						
							|  |  |  |  | 			return fmt.Errorf("kafka(%s): %s", k, err.Error()) | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t.Close() | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for k, v := range s.Notify.MQTT { | 
					
						
							|  |  |  |  | 		if !v.Enable { | 
					
						
							|  |  |  |  | 			continue | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-04-10 20:46:01 +08:00
										 |  |  |  | 		t, err := target.NewMQTTTarget(k, v, GlobalServiceDoneCh) | 
					
						
							| 
									
										
										
										
											2018-09-06 23:03:18 +08:00
										 |  |  |  | 		if err != nil { | 
					
						
							|  |  |  |  | 			return fmt.Errorf("mqtt(%s): %s", k, err.Error()) | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t.Close() | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for k, v := range s.Notify.MySQL { | 
					
						
							|  |  |  |  | 		if !v.Enable { | 
					
						
							|  |  |  |  | 			continue | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t, err := target.NewMySQLTarget(k, v) | 
					
						
							|  |  |  |  | 		if err != nil { | 
					
						
							|  |  |  |  | 			return fmt.Errorf("mysql(%s): %s", k, err.Error()) | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t.Close() | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for k, v := range s.Notify.NATS { | 
					
						
							|  |  |  |  | 		if !v.Enable { | 
					
						
							|  |  |  |  | 			continue | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t, err := target.NewNATSTarget(k, v) | 
					
						
							|  |  |  |  | 		if err != nil { | 
					
						
							|  |  |  |  | 			return fmt.Errorf("nats(%s): %s", k, err.Error()) | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t.Close() | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 	for k, v := range s.Notify.NSQ { | 
					
						
							|  |  |  |  | 		if !v.Enable { | 
					
						
							|  |  |  |  | 			continue | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t, err := target.NewNSQTarget(k, v) | 
					
						
							|  |  |  |  | 		if err != nil { | 
					
						
							|  |  |  |  | 			return fmt.Errorf("nsq(%s): %s", k, err.Error()) | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t.Close() | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-06 23:03:18 +08:00
										 |  |  |  | 	for k, v := range s.Notify.PostgreSQL { | 
					
						
							|  |  |  |  | 		if !v.Enable { | 
					
						
							|  |  |  |  | 			continue | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t, err := target.NewPostgreSQLTarget(k, v) | 
					
						
							|  |  |  |  | 		if err != nil { | 
					
						
							|  |  |  |  | 			return fmt.Errorf("postgreSQL(%s): %s", k, err.Error()) | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t.Close() | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for k, v := range s.Notify.Redis { | 
					
						
							|  |  |  |  | 		if !v.Enable { | 
					
						
							|  |  |  |  | 			continue | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t, err := target.NewRedisTarget(k, v) | 
					
						
							|  |  |  |  | 		if err != nil { | 
					
						
							|  |  |  |  | 			return fmt.Errorf("redis(%s): %s", k, err.Error()) | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		t.Close() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-01 00:15:54 +08:00
										 |  |  |  | // Returns the string describing a difference with the given
 | 
					
						
							|  |  |  |  | // configuration object. If the given configuration object is
 | 
					
						
							|  |  |  |  | // identical, an empty string is returned.
 | 
					
						
							|  |  |  |  | func (s *serverConfig) ConfigDiff(t *serverConfig) string { | 
					
						
							|  |  |  |  | 	switch { | 
					
						
							|  |  |  |  | 	case t == nil: | 
					
						
							|  |  |  |  | 		return "Given configuration is empty" | 
					
						
							|  |  |  |  | 	case s.Credential != t.Credential: | 
					
						
							|  |  |  |  | 		return "Credential configuration differs" | 
					
						
							|  |  |  |  | 	case s.Region != t.Region: | 
					
						
							|  |  |  |  | 		return "Region configuration differs" | 
					
						
							|  |  |  |  | 	case s.StorageClass != t.StorageClass: | 
					
						
							|  |  |  |  | 		return "StorageClass configuration differs" | 
					
						
							| 
									
										
										
										
											2018-04-14 02:15:19 +08:00
										 |  |  |  | 	case !reflect.DeepEqual(s.Cache, t.Cache): | 
					
						
							|  |  |  |  | 		return "Cache configuration differs" | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 	case !reflect.DeepEqual(s.Compression, t.Compression): | 
					
						
							|  |  |  |  | 		return "Compression configuration differs" | 
					
						
							| 
									
										
										
										
											2018-02-01 00:15:54 +08:00
										 |  |  |  | 	case !reflect.DeepEqual(s.Notify.AMQP, t.Notify.AMQP): | 
					
						
							|  |  |  |  | 		return "AMQP Notification configuration differs" | 
					
						
							|  |  |  |  | 	case !reflect.DeepEqual(s.Notify.NATS, t.Notify.NATS): | 
					
						
							|  |  |  |  | 		return "NATS Notification configuration differs" | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 	case !reflect.DeepEqual(s.Notify.NSQ, t.Notify.NSQ): | 
					
						
							|  |  |  |  | 		return "NSQ Notification configuration differs" | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	case !reflect.DeepEqual(s.Notify.Elasticsearch, t.Notify.Elasticsearch): | 
					
						
							| 
									
										
										
										
											2018-02-01 00:15:54 +08:00
										 |  |  |  | 		return "ElasticSearch Notification configuration differs" | 
					
						
							|  |  |  |  | 	case !reflect.DeepEqual(s.Notify.Redis, t.Notify.Redis): | 
					
						
							|  |  |  |  | 		return "Redis Notification configuration differs" | 
					
						
							|  |  |  |  | 	case !reflect.DeepEqual(s.Notify.PostgreSQL, t.Notify.PostgreSQL): | 
					
						
							|  |  |  |  | 		return "PostgreSQL Notification configuration differs" | 
					
						
							|  |  |  |  | 	case !reflect.DeepEqual(s.Notify.Kafka, t.Notify.Kafka): | 
					
						
							|  |  |  |  | 		return "Kafka Notification configuration differs" | 
					
						
							|  |  |  |  | 	case !reflect.DeepEqual(s.Notify.Webhook, t.Notify.Webhook): | 
					
						
							|  |  |  |  | 		return "Webhook Notification configuration differs" | 
					
						
							|  |  |  |  | 	case !reflect.DeepEqual(s.Notify.MySQL, t.Notify.MySQL): | 
					
						
							|  |  |  |  | 		return "MySQL Notification configuration differs" | 
					
						
							|  |  |  |  | 	case !reflect.DeepEqual(s.Notify.MQTT, t.Notify.MQTT): | 
					
						
							|  |  |  |  | 		return "MQTT Notification configuration differs" | 
					
						
							| 
									
										
										
										
											2018-07-20 06:55:06 +08:00
										 |  |  |  | 	case !reflect.DeepEqual(s.Logger, t.Logger): | 
					
						
							|  |  |  |  | 		return "Logger configuration differs" | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 	case !reflect.DeepEqual(s.KMS, t.KMS): | 
					
						
							|  |  |  |  | 		return "KMS configuration differs" | 
					
						
							| 
									
										
										
										
											2018-02-01 00:15:54 +08:00
										 |  |  |  | 	case reflect.DeepEqual(s, t): | 
					
						
							|  |  |  |  | 		return "" | 
					
						
							|  |  |  |  | 	default: | 
					
						
							|  |  |  |  | 		// This case will not happen unless this comparison
 | 
					
						
							|  |  |  |  | 		// function has become stale.
 | 
					
						
							|  |  |  |  | 		return "Configuration differs" | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | func newServerConfig() *serverConfig { | 
					
						
							| 
									
										
										
										
											2018-04-20 08:24:43 +08:00
										 |  |  |  | 	cred, err := auth.GetNewCredentials() | 
					
						
							|  |  |  |  | 	logger.FatalIf(err, "") | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | 	srvCfg := &serverConfig{ | 
					
						
							| 
									
										
										
										
											2018-02-01 15:30:07 +08:00
										 |  |  |  | 		Version:    serverConfigVersion, | 
					
						
							| 
									
										
										
										
											2018-04-20 08:24:43 +08:00
										 |  |  |  | 		Credential: cred, | 
					
						
							| 
									
										
										
										
											2018-02-01 15:30:07 +08:00
										 |  |  |  | 		Region:     globalMinioDefaultRegion, | 
					
						
							|  |  |  |  | 		StorageClass: storageClassConfig{ | 
					
						
							|  |  |  |  | 			Standard: storageClass{}, | 
					
						
							|  |  |  |  | 			RRS:      storageClass{}, | 
					
						
							|  |  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 		Cache: CacheConfig{ | 
					
						
							|  |  |  |  | 			Drives:  []string{}, | 
					
						
							|  |  |  |  | 			Exclude: []string{}, | 
					
						
							|  |  |  |  | 			Expiry:  globalCacheExpiry, | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  |  | 			MaxUse:  globalCacheMaxUse, | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 		KMS:    crypto.KMSConfig{}, | 
					
						
							| 
									
										
										
										
											2018-02-01 15:30:07 +08:00
										 |  |  |  | 		Notify: notifier{}, | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 		Compression: compressionConfig{ | 
					
						
							|  |  |  |  | 			Enabled:    false, | 
					
						
							|  |  |  |  | 			Extensions: globalCompressExtensions, | 
					
						
							|  |  |  |  | 			MimeTypes:  globalCompressMimeTypes, | 
					
						
							|  |  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-27 03:00:27 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-08 04:51:43 +08:00
										 |  |  |  | 	// Make sure to initialize notification configs.
 | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	srvCfg.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 	srvCfg.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							|  |  |  |  | 	srvCfg.Notify.MQTT = make(map[string]target.MQTTArgs) | 
					
						
							|  |  |  |  | 	srvCfg.Notify.MQTT["1"] = target.MQTTArgs{} | 
					
						
							|  |  |  |  | 	srvCfg.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 	srvCfg.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{} | 
					
						
							|  |  |  |  | 	srvCfg.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 	srvCfg.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							|  |  |  |  | 	srvCfg.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 	srvCfg.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 	srvCfg.Notify.NSQ = make(map[string]target.NSQArgs) | 
					
						
							|  |  |  |  | 	srvCfg.Notify.NSQ["1"] = target.NSQArgs{} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	srvCfg.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 	srvCfg.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{} | 
					
						
							|  |  |  |  | 	srvCfg.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 	srvCfg.Notify.MySQL["1"] = target.MySQLArgs{} | 
					
						
							|  |  |  |  | 	srvCfg.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 	srvCfg.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							|  |  |  |  | 	srvCfg.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 	srvCfg.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							| 
									
										
										
										
											2017-02-08 04:51:43 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 	srvCfg.Cache.Drives = make([]string, 0) | 
					
						
							|  |  |  |  | 	srvCfg.Cache.Exclude = make([]string, 0) | 
					
						
							|  |  |  |  | 	srvCfg.Cache.Expiry = globalCacheExpiry | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  |  | 	srvCfg.Cache.MaxUse = globalCacheMaxUse | 
					
						
							| 
									
										
										
										
											2018-07-20 06:55:06 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Console logging is on by default
 | 
					
						
							|  |  |  |  | 	srvCfg.Logger.Console.Enabled = true | 
					
						
							|  |  |  |  | 	// Create an example of HTTP logger
 | 
					
						
							|  |  |  |  | 	srvCfg.Logger.HTTP = make(map[string]loggerHTTP) | 
					
						
							|  |  |  |  | 	srvCfg.Logger.HTTP["target1"] = loggerHTTP{Endpoint: "https://username:password@example.com/api"} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-02 01:17:04 +08:00
										 |  |  |  | 	return srvCfg | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | func (s *serverConfig) loadToCachedConfigs() { | 
					
						
							|  |  |  |  | 	if !globalIsEnvCreds { | 
					
						
							|  |  |  |  | 		globalActiveCred = s.GetCredential() | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	if !globalIsEnvWORM { | 
					
						
							|  |  |  |  | 		globalWORMEnabled = s.GetWorm() | 
					
						
							| 
									
										
										
										
											2017-03-02 01:17:04 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	if !globalIsEnvRegion { | 
					
						
							|  |  |  |  | 		globalServerRegion = s.GetRegion() | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	if !globalIsStorageClass { | 
					
						
							|  |  |  |  | 		globalStandardStorageClass, globalRRStorageClass = s.GetStorageClass() | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	if !globalIsDiskCacheEnabled { | 
					
						
							|  |  |  |  | 		cacheConf := s.GetCacheConfig() | 
					
						
							|  |  |  |  | 		globalCacheDrives = cacheConf.Drives | 
					
						
							|  |  |  |  | 		globalCacheExcludes = cacheConf.Exclude | 
					
						
							|  |  |  |  | 		globalCacheExpiry = cacheConf.Expiry | 
					
						
							|  |  |  |  | 		globalCacheMaxUse = cacheConf.MaxUse | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-12-12 14:50:29 +08:00
										 |  |  |  | 	if err := Environment.LookupKMSConfig(s.KMS); err != nil { | 
					
						
							|  |  |  |  | 		logger.FatalIf(err, "Unable to setup the KMS") | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 	if !globalIsCompressionEnabled { | 
					
						
							|  |  |  |  | 		compressionConf := s.GetCompressionConfig() | 
					
						
							|  |  |  |  | 		globalCompressExtensions = compressionConf.Extensions | 
					
						
							|  |  |  |  | 		globalCompressMimeTypes = compressionConf.MimeTypes | 
					
						
							|  |  |  |  | 		globalIsCompressionEnabled = compressionConf.Enabled | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-29 05:31:35 +08:00
										 |  |  |  | 	globalIAMValidators = getAuthValidators(s) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if s.Policy.OPA.URL != nil && s.Policy.OPA.URL.String() != "" { | 
					
						
							|  |  |  |  | 		globalPolicyOPA = iampolicy.NewOpa(iampolicy.OpaArgs{ | 
					
						
							|  |  |  |  | 			URL:         s.Policy.OPA.URL, | 
					
						
							|  |  |  |  | 			AuthToken:   s.Policy.OPA.AuthToken, | 
					
						
							|  |  |  |  | 			Transport:   NewCustomHTTPTransport(), | 
					
						
							| 
									
										
										
										
											2019-02-07 04:07:03 +08:00
										 |  |  |  | 			CloseRespFn: xhttp.DrainBody, | 
					
						
							| 
									
										
										
										
											2019-01-29 05:31:35 +08:00
										 |  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | // newSrvConfig - initialize a new server config, saves env parameters if
 | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | // found, otherwise use default parameters
 | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | func newSrvConfig(objAPI ObjectLayer) error { | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	// Initialize server config.
 | 
					
						
							|  |  |  |  | 	srvCfg := newServerConfig() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Override any values from ENVs.
 | 
					
						
							|  |  |  |  | 	srvCfg.loadFromEnvs() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load values to cached global values.
 | 
					
						
							|  |  |  |  | 	srvCfg.loadToCachedConfigs() | 
					
						
							| 
									
										
										
										
											2018-03-30 05:38:26 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-02-08 04:51:43 +08:00
										 |  |  |  | 	// hold the mutex lock before a new config is assigned.
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08:00
										 |  |  |  | 	globalServerConfigMu.Lock() | 
					
						
							|  |  |  |  | 	globalServerConfig = srvCfg | 
					
						
							|  |  |  |  | 	globalServerConfigMu.Unlock() | 
					
						
							| 
									
										
										
										
											2017-02-08 04:51:43 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Save config into file.
 | 
					
						
							| 
									
										
										
										
											2018-09-06 23:03:18 +08:00
										 |  |  |  | 	return saveServerConfig(context.Background(), objAPI, globalServerConfig) | 
					
						
							| 
									
										
										
										
											2017-02-08 04:51:43 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | // getValidConfig - returns valid server configuration
 | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | func getValidConfig(objAPI ObjectLayer) (*serverConfig, error) { | 
					
						
							|  |  |  |  | 	srvCfg, err := readServerConfig(context.Background(), objAPI) | 
					
						
							| 
									
										
										
										
											2018-02-03 10:18:52 +08:00
										 |  |  |  | 	if err != nil { | 
					
						
							|  |  |  |  | 		return nil, err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	return srvCfg, srvCfg.Validate() | 
					
						
							| 
									
										
											  
											
												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 07:27:10 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | // loadConfig - loads a new config from disk, overrides params from env
 | 
					
						
							|  |  |  |  | // if found and valid
 | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | func loadConfig(objAPI ObjectLayer) error { | 
					
						
							|  |  |  |  | 	srvCfg, err := getValidConfig(objAPI) | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2018-05-09 10:04:36 +08:00
										 |  |  |  | 		return uiErrInvalidConfig(nil).Msg(err.Error()) | 
					
						
							| 
									
										
										
										
											2017-03-17 02:06:17 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-12-07 19:41:54 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	// Override any values from ENVs.
 | 
					
						
							|  |  |  |  | 	srvCfg.loadFromEnvs() | 
					
						
							| 
									
										
											  
											
												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 07:27:10 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 	// Load values to cached global values.
 | 
					
						
							|  |  |  |  | 	srvCfg.loadToCachedConfigs() | 
					
						
							| 
									
										
										
										
											2018-03-30 05:38:26 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08:00
										 |  |  |  | 	// hold the mutex lock before a new config is assigned.
 | 
					
						
							| 
									
										
										
										
											2017-11-30 05:12:47 +08: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-13 07:27:10 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-31 13:26:24 +08: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 07:27:10 +08:00
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | // getAuthValidators - returns ValidatorList which contains
 | 
					
						
							|  |  |  |  | // enabled providers in server config.
 | 
					
						
							|  |  |  |  | // A new authentication provider is added like below
 | 
					
						
							|  |  |  |  | // * Add a new provider in pkg/iam/validator package.
 | 
					
						
							|  |  |  |  | func getAuthValidators(config *serverConfig) *validator.Validators { | 
					
						
							|  |  |  |  | 	validators := validator.NewValidators() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if config.OpenID.JWKS.URL != nil { | 
					
						
							|  |  |  |  | 		validators.Add(validator.NewJWT(config.OpenID.JWKS)) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	return validators | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | // getNotificationTargets - returns TargetList which contains enabled targets in serverConfig.
 | 
					
						
							|  |  |  |  | // A new notification target is added like below
 | 
					
						
							|  |  |  |  | // * Add a new target in pkg/event/target package.
 | 
					
						
							|  |  |  |  | // * Add newly added target configuration to serverConfig.Notify.<TARGET_NAME>.
 | 
					
						
							|  |  |  |  | // * Handle the configuration in this function to create/add into TargetList.
 | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | func getNotificationTargets(config *serverConfig) *event.TargetList { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	targetList := event.NewTargetList() | 
					
						
							| 
									
										
										
										
											2018-08-21 07:58:47 +08:00
										 |  |  |  | 	if config == nil { | 
					
						
							|  |  |  |  | 		return targetList | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	for id, args := range config.Notify.AMQP { | 
					
						
							|  |  |  |  | 		if args.Enable { | 
					
						
							|  |  |  |  | 			newTarget, err := target.NewAMQPTarget(id, args) | 
					
						
							|  |  |  |  | 			if err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 			if err = targetList.Add(newTarget); err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for id, args := range config.Notify.Elasticsearch { | 
					
						
							|  |  |  |  | 		if args.Enable { | 
					
						
							|  |  |  |  | 			newTarget, err := target.NewElasticsearchTarget(id, args) | 
					
						
							|  |  |  |  | 			if err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 			if err = targetList.Add(newTarget); err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for id, args := range config.Notify.Kafka { | 
					
						
							|  |  |  |  | 		if args.Enable { | 
					
						
							|  |  |  |  | 			newTarget, err := target.NewKafkaTarget(id, args) | 
					
						
							|  |  |  |  | 			if err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 			if err = targetList.Add(newTarget); err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for id, args := range config.Notify.MQTT { | 
					
						
							|  |  |  |  | 		if args.Enable { | 
					
						
							| 
									
										
										
										
											2019-01-20 12:27:18 +08:00
										 |  |  |  | 			args.RootCAs = globalRootCAs | 
					
						
							| 
									
										
										
										
											2019-04-10 20:46:01 +08:00
										 |  |  |  | 			newTarget, err := target.NewMQTTTarget(id, args, GlobalServiceDoneCh) | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			if err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 			if err = targetList.Add(newTarget); err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for id, args := range config.Notify.MySQL { | 
					
						
							|  |  |  |  | 		if args.Enable { | 
					
						
							|  |  |  |  | 			newTarget, err := target.NewMySQLTarget(id, args) | 
					
						
							|  |  |  |  | 			if err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 			if err = targetList.Add(newTarget); err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for id, args := range config.Notify.NATS { | 
					
						
							|  |  |  |  | 		if args.Enable { | 
					
						
							|  |  |  |  | 			newTarget, err := target.NewNATSTarget(id, args) | 
					
						
							|  |  |  |  | 			if err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 			if err = targetList.Add(newTarget); err != nil { | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for id, args := range config.Notify.NSQ { | 
					
						
							|  |  |  |  | 		if args.Enable { | 
					
						
							|  |  |  |  | 			newTarget, err := target.NewNSQTarget(id, args) | 
					
						
							|  |  |  |  | 			if err != nil { | 
					
						
							|  |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 			if err = targetList.Add(newTarget); err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for id, args := range config.Notify.PostgreSQL { | 
					
						
							|  |  |  |  | 		if args.Enable { | 
					
						
							|  |  |  |  | 			newTarget, err := target.NewPostgreSQLTarget(id, args) | 
					
						
							|  |  |  |  | 			if err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 			if err = targetList.Add(newTarget); err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for id, args := range config.Notify.Redis { | 
					
						
							|  |  |  |  | 		if args.Enable { | 
					
						
							|  |  |  |  | 			newTarget, err := target.NewRedisTarget(id, args) | 
					
						
							|  |  |  |  | 			if err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 			if err = targetList.Add(newTarget); err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for id, args := range config.Notify.Webhook { | 
					
						
							|  |  |  |  | 		if args.Enable { | 
					
						
							| 
									
										
										
										
											2019-01-20 12:27:18 +08:00
										 |  |  |  | 			args.RootCAs = globalRootCAs | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			newTarget := target.NewWebhookTarget(id, args) | 
					
						
							|  |  |  |  | 			if err := targetList.Add(newTarget); err != nil { | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 				logger.LogIf(context.Background(), err) | 
					
						
							|  |  |  |  | 				continue | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			} | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-10 09:50:31 +08:00
										 |  |  |  | 	return targetList | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | } |