| 
									
										
											  
											
												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-10-23 13:59:13 +08: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-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 ( | 
					
						
							| 
									
										
										
										
											2019-11-02 06:53:16 +08:00
										 |  |  |  | 	"bytes" | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	"encoding/json" | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 	"fmt" | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |  | 	"os" | 
					
						
							| 
									
										
										
										
											2018-08-18 09:51:34 +08:00
										 |  |  |  | 	"path" | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |  | 	"path/filepath" | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  |  | 	"strings" | 
					
						
							| 
									
										
										
										
											2020-07-18 08:41:29 +08:00
										 |  |  |  | 	"unicode/utf8" | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	"github.com/minio/minio/cmd/config" | 
					
						
							|  |  |  |  | 	"github.com/minio/minio/cmd/config/cache" | 
					
						
							|  |  |  |  | 	"github.com/minio/minio/cmd/config/compress" | 
					
						
							|  |  |  |  | 	xldap "github.com/minio/minio/cmd/config/identity/ldap" | 
					
						
							|  |  |  |  | 	"github.com/minio/minio/cmd/config/identity/openid" | 
					
						
							|  |  |  |  | 	"github.com/minio/minio/cmd/config/notify" | 
					
						
							|  |  |  |  | 	"github.com/minio/minio/cmd/config/policy/opa" | 
					
						
							|  |  |  |  | 	"github.com/minio/minio/cmd/config/storageclass" | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 	"github.com/minio/minio/cmd/crypto" | 
					
						
							| 
									
										
										
										
											2018-04-06 06:04:40 +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" | 
					
						
							| 
									
										
										
										
											2019-11-02 06:53:16 +08:00
										 |  |  |  | 	"github.com/minio/minio/pkg/madmin" | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	xnet "github.com/minio/minio/pkg/net" | 
					
						
							| 
									
										
										
										
											2018-05-16 09:20:22 +08:00
										 |  |  |  | 	"github.com/minio/minio/pkg/quick" | 
					
						
							| 
									
										
											  
											
												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-05-03 02:43:27 +08:00
										 |  |  |  | // DO NOT EDIT following message template, please open a github issue to discuss instead.
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | var configMigrateMSGTemplate = "Configuration file %s migrated from version '%s' to '%s' successfully." | 
					
						
							| 
									
										
										
										
											2017-05-03 02:43:27 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | // Save config file to corresponding backend
 | 
					
						
							|  |  |  |  | func Save(configFile string, data interface{}) error { | 
					
						
							|  |  |  |  | 	return quick.SaveConfig(data, configFile, globalEtcdClient) | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // Load config from backend
 | 
					
						
							|  |  |  |  | func Load(configFile string, data interface{}) (quick.Config, error) { | 
					
						
							|  |  |  |  | 	return quick.LoadConfig(configFile, globalEtcdClient, data) | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // GetVersion gets config version from backend
 | 
					
						
							|  |  |  |  | func GetVersion(configFile string) (string, error) { | 
					
						
							|  |  |  |  | 	return quick.GetVersion(configFile, globalEtcdClient) | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-18 09:51:34 +08:00
										 |  |  |  | // Migrates all config versions from "1" to "28".
 | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | func migrateConfig() error { | 
					
						
							| 
									
										
										
										
											2017-05-07 01:16:59 +08:00
										 |  |  |  | 	// Purge all configs with version '1',
 | 
					
						
							|  |  |  |  | 	// this is a special case since version '1' used
 | 
					
						
							|  |  |  |  | 	// to be a filename 'fsUsers.json' not 'config.json'.
 | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 	if err := purgeV1(); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-05-07 01:16:59 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load only config version information.
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	version, err := GetVersion(getConfigFile()) | 
					
						
							| 
									
										
										
										
											2017-05-07 01:16:59 +08:00
										 |  |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 		if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2018-08-15 12:41:47 +08:00
										 |  |  |  | 			return nil | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-07 01:16:59 +08:00
										 |  |  |  | 	// Conditional to migrate only relevant config versions.
 | 
					
						
							|  |  |  |  | 	// Upon success migration continues to the next version in sequence.
 | 
					
						
							|  |  |  |  | 	switch version { | 
					
						
							|  |  |  |  | 	case "2": | 
					
						
							|  |  |  |  | 		// Migrate version '2' to '3'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV2ToV3(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "3": | 
					
						
							|  |  |  |  | 		// Migrate version '3' to '4'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV3ToV4(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "4": | 
					
						
							|  |  |  |  | 		// Migrate version '4' to '5'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV4ToV5(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "5": | 
					
						
							|  |  |  |  | 		// Migrate version '5' to '6.
 | 
					
						
							|  |  |  |  | 		if err = migrateV5ToV6(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "6": | 
					
						
							|  |  |  |  | 		// Migrate version '6' to '7'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV6ToV7(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "7": | 
					
						
							|  |  |  |  | 		// Migrate version '7' to '8'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV7ToV8(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "8": | 
					
						
							|  |  |  |  | 		// Migrate version '8' to '9'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV8ToV9(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "9": | 
					
						
							|  |  |  |  | 		// Migrate version '9' to '10'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV9ToV10(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "10": | 
					
						
							|  |  |  |  | 		// Migrate version '10' to '11'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV10ToV11(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "11": | 
					
						
							|  |  |  |  | 		// Migrate version '11' to '12'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV11ToV12(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "12": | 
					
						
							|  |  |  |  | 		// Migrate version '12' to '13'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV12ToV13(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "13": | 
					
						
							|  |  |  |  | 		// Migrate version '13' to '14'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV13ToV14(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "14": | 
					
						
							|  |  |  |  | 		// Migrate version '14' to '15'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV14ToV15(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "15": | 
					
						
							|  |  |  |  | 		// Migrate version '15' to '16'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV15ToV16(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "16": | 
					
						
							|  |  |  |  | 		// Migrate version '16' to '17'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV16ToV17(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "17": | 
					
						
							|  |  |  |  | 		// Migrate version '17' to '18'.
 | 
					
						
							|  |  |  |  | 		if err = migrateV17ToV18(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 	case "18": | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 		// Migrate version '18' to '19'.
 | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 		if err = migrateV18ToV19(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	case "19": | 
					
						
							|  |  |  |  | 		if err = migrateV19ToV20(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "20": | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 		if err = migrateV20ToV21(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	case "21": | 
					
						
							|  |  |  |  | 		if err = migrateV21ToV22(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 		fallthrough | 
					
						
							|  |  |  |  | 	case "22": | 
					
						
							|  |  |  |  | 		if err = migrateV22ToV23(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							| 
									
										
										
										
											2018-06-05 09:35:41 +08:00
										 |  |  |  | 	case "23": | 
					
						
							|  |  |  |  | 		if err = migrateV23ToV24(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  |  | 	case "24": | 
					
						
							|  |  |  |  | 		if err = migrateV24ToV25(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  |  | 	case "25": | 
					
						
							|  |  |  |  | 		if err = migrateV25ToV26(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							| 
									
										
										
										
											2018-07-20 06:55:06 +08:00
										 |  |  |  | 	case "26": | 
					
						
							|  |  |  |  | 		if err = migrateV26ToV27(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 	case "27": | 
					
						
							|  |  |  |  | 		if err = migrateV27ToV28(); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		fallthrough | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  |  | 	case "33": | 
					
						
							| 
									
										
										
										
											2017-05-07 01:16:59 +08:00
										 |  |  |  | 		// No migration needed. this always points to current version.
 | 
					
						
							|  |  |  |  | 		err = nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	return err | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '1' is not supported anymore and deprecated, safe to delete.
 | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | func purgeV1() error { | 
					
						
							| 
									
										
										
										
											2019-01-03 02:05:16 +08:00
										 |  |  |  | 	configFile := filepath.Join(globalConfigDir.Get(), "fsUsers.json") | 
					
						
							| 
									
										
											  
											
												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-23 01:23:25 +08:00
										 |  |  |  | 	cv1 := &configV1{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv1) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 		return nil | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘1’. %w", err) | 
					
						
							| 
									
										
											  
											
												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-23 01:23:25 +08:00
										 |  |  |  | 	if cv1.Version != "1" { | 
					
						
							|  |  |  |  | 		return fmt.Errorf("unrecognized config version ‘%s’", cv1.Version) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-13 10:25:43 +08:00
										 |  |  |  | 	os.RemoveAll(configFile) | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info("Removed unsupported config version ‘1’.") | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +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
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | // Version '2' to '3' config migration adds new fields and re-orders
 | 
					
						
							|  |  |  |  | // previous fields. Simplifies config for future additions.
 | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | func migrateV2ToV3() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv2 := &configV2{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv2) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘2’. %w", err) | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv2.Version != "2" { | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +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
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-16 15:16:06 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-01 02:54:32 +08:00
										 |  |  |  | 	cred, err := auth.CreateCredentials(cv2.Credentials.AccessKey, cv2.Credentials.SecretKey) | 
					
						
							| 
									
										
										
										
											2017-03-16 15:16:06 +08:00
										 |  |  |  | 	if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Invalid credential in V2 configuration file. %w", err) | 
					
						
							| 
									
										
										
										
											2017-03-16 15:16:06 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | 	srvConfig := &configV3{} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "3" | 
					
						
							|  |  |  |  | 	srvConfig.Addr = ":9000" | 
					
						
							| 
									
										
										
										
											2017-03-16 15:16:06 +08:00
										 |  |  |  | 	srvConfig.Credential = cred | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | 	srvConfig.Region = cv2.Credentials.Region | 
					
						
							| 
									
										
										
										
											2016-05-04 06:17:58 +08:00
										 |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature V4.
 | 
					
						
							| 
									
										
										
										
											2017-01-19 04:24:34 +08:00
										 |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							| 
									
										
										
										
											2016-05-04 06:17:58 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	srvConfig.Logger.Console = consoleLoggerV1{ | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |  | 		Enable: true, | 
					
						
							|  |  |  |  | 		Level:  "fatal", | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	flogger := fileLoggerV1{} | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |  | 	flogger.Level = "error" | 
					
						
							|  |  |  |  | 	if cv2.FileLogger.Filename != "" { | 
					
						
							|  |  |  |  | 		flogger.Enable = true | 
					
						
							|  |  |  |  | 		flogger.Filename = cv2.FileLogger.Filename | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | 	srvConfig.Logger.File = flogger | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-11-24 07:00:53 +08:00
										 |  |  |  | 	slogger := syslogLoggerV3{} | 
					
						
							| 
									
										
											  
											
												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
										 |  |  |  | 	slogger.Level = "debug" | 
					
						
							|  |  |  |  | 	if cv2.SyslogLogger.Addr != "" { | 
					
						
							|  |  |  |  | 		slogger.Enable = true | 
					
						
							|  |  |  |  | 		slogger.Addr = cv2.SyslogLogger.Addr | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | 	srvConfig.Logger.Syslog = slogger | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv2.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv2.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 	return nil | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '3' to '4' migrates config, removes previous fields related
 | 
					
						
							|  |  |  |  | // to backend types and server address. This change further simplifies
 | 
					
						
							|  |  |  |  | // the config for future additions.
 | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | func migrateV3ToV4() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv3 := &configV3{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv3) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘3’. %w", err) | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv3.Version != "3" { | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 		return nil | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Save only the new fields, ignore the rest.
 | 
					
						
							| 
									
										
										
										
											2016-07-24 13:51:12 +08:00
										 |  |  |  | 	srvConfig := &configV4{} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "4" | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | 	srvConfig.Credential = cv3.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv3.Region | 
					
						
							| 
									
										
										
										
											2016-05-04 06:17:58 +08:00
										 |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							| 
									
										
										
										
											2017-01-19 04:24:34 +08:00
										 |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							| 
									
										
										
										
											2016-05-04 06:17:58 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											
										 
											2016-04-02 10:19:44 +08:00
										 |  |  |  | 	srvConfig.Logger.Console = cv3.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv3.Logger.File | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Syslog = cv3.Logger.Syslog | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv3.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
											  
											
												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-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv3.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +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
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-07-24 13:51:12 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | // Version '4' to '5' migrates config, removes previous fields related
 | 
					
						
							|  |  |  |  | // to backend types and server address. This change further simplifies
 | 
					
						
							|  |  |  |  | // the config for future additions.
 | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | func migrateV4ToV5() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv4 := &configV4{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv4) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘4’. %w", err) | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv4.Version != "4" { | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 		return nil | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Save only the new fields, ignore the rest.
 | 
					
						
							|  |  |  |  | 	srvConfig := &configV5{} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "5" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv4.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv4.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							| 
									
										
										
										
											2017-01-19 04:24:34 +08:00
										 |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv4.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv4.Logger.File | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Syslog = cv4.Logger.Syslog | 
					
						
							|  |  |  |  | 	srvConfig.Logger.AMQP.Enable = false | 
					
						
							|  |  |  |  | 	srvConfig.Logger.ElasticSearch.Enable = false | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Redis.Enable = false | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv4.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv4.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 	return nil | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-05 13:01:58 +08:00
										 |  |  |  | // Version '5' to '6' migrates config, removes previous fields related
 | 
					
						
							|  |  |  |  | // to backend types and server address. This change further simplifies
 | 
					
						
							|  |  |  |  | // the config for future additions.
 | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | func migrateV5ToV6() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv5 := &configV5{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv5) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘5’. %w", err) | 
					
						
							| 
									
										
										
										
											2016-08-05 13:01:58 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv5.Version != "5" { | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 		return nil | 
					
						
							| 
									
										
										
										
											2016-08-05 13:01:58 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Save only the new fields, ignore the rest.
 | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	srvConfig := &configV6{} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "6" | 
					
						
							| 
									
										
										
										
											2016-08-05 13:01:58 +08:00
										 |  |  |  | 	srvConfig.Credential = cv5.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv5.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							| 
									
										
										
										
											2017-01-19 04:24:34 +08:00
										 |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							| 
									
										
										
										
											2016-08-05 13:01:58 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv5.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv5.Logger.File | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Syslog = cv5.Logger.Syslog | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	if cv5.Logger.AMQP.URL != "" { | 
					
						
							|  |  |  |  | 		var url *xnet.URL | 
					
						
							|  |  |  |  | 		if url, err = xnet.ParseURL(cv5.Logger.AMQP.URL); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = map[string]target.AMQPArgs{ | 
					
						
							|  |  |  |  | 			"1": { | 
					
						
							|  |  |  |  | 				Enable:      cv5.Logger.AMQP.Enable, | 
					
						
							|  |  |  |  | 				URL:         *url, | 
					
						
							|  |  |  |  | 				Exchange:    cv5.Logger.AMQP.Exchange, | 
					
						
							|  |  |  |  | 				RoutingKey:  cv5.Logger.AMQP.RoutingKey, | 
					
						
							|  |  |  |  | 				Mandatory:   cv5.Logger.AMQP.Mandatory, | 
					
						
							|  |  |  |  | 				Immediate:   cv5.Logger.AMQP.Immediate, | 
					
						
							|  |  |  |  | 				Durable:     cv5.Logger.AMQP.Durable, | 
					
						
							|  |  |  |  | 				Internal:    cv5.Logger.AMQP.Internal, | 
					
						
							|  |  |  |  | 				NoWait:      cv5.Logger.AMQP.NoWait, | 
					
						
							|  |  |  |  | 				AutoDeleted: cv5.Logger.AMQP.AutoDeleted, | 
					
						
							|  |  |  |  | 			}, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if cv5.Logger.ElasticSearch.URL != "" { | 
					
						
							|  |  |  |  | 		var url *xnet.URL | 
					
						
							| 
									
										
										
										
											2019-10-31 14:39:09 +08:00
										 |  |  |  | 		url, err = xnet.ParseHTTPURL(cv5.Logger.ElasticSearch.URL) | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		if err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		srvConfig.Notify.ElasticSearch = map[string]target.ElasticsearchArgs{ | 
					
						
							|  |  |  |  | 			"1": { | 
					
						
							|  |  |  |  | 				Enable: cv5.Logger.ElasticSearch.Enable, | 
					
						
							|  |  |  |  | 				URL:    *url, | 
					
						
							|  |  |  |  | 				Index:  cv5.Logger.ElasticSearch.Index, | 
					
						
							|  |  |  |  | 			}, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if cv5.Logger.Redis.Addr != "" { | 
					
						
							|  |  |  |  | 		var addr *xnet.Host | 
					
						
							|  |  |  |  | 		if addr, err = xnet.ParseHost(cv5.Logger.Redis.Addr); err != nil { | 
					
						
							|  |  |  |  | 			return err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = map[string]target.RedisArgs{ | 
					
						
							|  |  |  |  | 			"1": { | 
					
						
							|  |  |  |  | 				Enable:   cv5.Logger.Redis.Enable, | 
					
						
							|  |  |  |  | 				Addr:     *addr, | 
					
						
							|  |  |  |  | 				Password: cv5.Logger.Redis.Password, | 
					
						
							|  |  |  |  | 				Key:      cv5.Logger.Redis.Key, | 
					
						
							|  |  |  |  | 			}, | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2016-08-05 13:01:58 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv5.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-08-05 13:01:58 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv5.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 	return nil | 
					
						
							| 
									
										
										
										
											2016-08-05 13:01:58 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | // Version '6' to '7' migrates config, removes previous fields related
 | 
					
						
							| 
									
										
										
										
											2016-07-24 13:51:12 +08:00
										 |  |  |  | // to backend types and server address. This change further simplifies
 | 
					
						
							|  |  |  |  | // the config for future additions.
 | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | func migrateV6ToV7() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv6 := &configV6{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv6) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘6’. %w", err) | 
					
						
							| 
									
										
										
										
											2016-07-24 13:51:12 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	if cv6.Version != "6" { | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 		return nil | 
					
						
							| 
									
										
										
										
											2016-07-24 13:51:12 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Save only the new fields, ignore the rest.
 | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	srvConfig := &serverConfigV7{} | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	srvConfig.Version = "7" | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	srvConfig.Credential = cv6.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv6.Region | 
					
						
							| 
									
										
										
										
											2016-07-24 13:51:12 +08:00
										 |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							| 
									
										
										
										
											2017-01-19 04:24:34 +08:00
										 |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							| 
									
										
										
										
											2016-07-24 13:51:12 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	srvConfig.Logger.Console = cv6.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv6.Logger.File | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Syslog = cv6.Logger.Syslog | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 	srvConfig.Notify.ElasticSearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 	srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	if len(cv6.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv6.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv6.Notify.ElasticSearch) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.ElasticSearch["1"] = target.ElasticsearchArgs{} | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.ElasticSearch = cv6.Notify.ElasticSearch | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv6.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							| 
									
										
										
										
											2016-09-10 15:51:25 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv6.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-07-24 13:51:12 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv6.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-07-24 13:51:12 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv6.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2016-09-22 00:44:57 +08:00
										 |  |  |  | 	return nil | 
					
						
							| 
									
										
										
										
											2016-07-24 13:51:12 +08:00
										 |  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-09-30 14:42:10 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '7' to '8' migrates config, removes previous fields related
 | 
					
						
							|  |  |  |  | // to backend types and server address. This change further simplifies
 | 
					
						
							|  |  |  |  | // the config for future additions.
 | 
					
						
							|  |  |  |  | func migrateV7ToV8() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv7 := &serverConfigV7{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv7) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘7’. %w", err) | 
					
						
							| 
									
										
										
										
											2016-09-30 14:42:10 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv7.Version != "7" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Save only the new fields, ignore the rest.
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV8{} | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	srvConfig.Version = "8" | 
					
						
							| 
									
										
										
										
											2016-09-30 14:42:10 +08:00
										 |  |  |  | 	srvConfig.Credential = cv7.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv7.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							| 
									
										
										
										
											2017-01-19 04:24:34 +08:00
										 |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							| 
									
										
										
										
											2016-09-30 14:42:10 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv7.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv7.Logger.File | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Syslog = cv7.Logger.Syslog | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 	srvConfig.Notify.NATS = make(map[string]natsNotifyV1) | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	srvConfig.Notify.ElasticSearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 	srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 	srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							| 
									
										
										
										
											2016-09-30 14:42:10 +08:00
										 |  |  |  | 	if len(cv7.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2016-09-30 14:42:10 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv7.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv7.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS["1"] = natsNotifyV1{} | 
					
						
							| 
									
										
										
										
											2016-09-30 14:42:10 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv7.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv7.Notify.ElasticSearch) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.ElasticSearch["1"] = target.ElasticsearchArgs{} | 
					
						
							| 
									
										
										
										
											2016-09-30 14:42:10 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.ElasticSearch = cv7.Notify.ElasticSearch | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv7.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							| 
									
										
										
										
											2016-09-30 14:42:10 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv7.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv7.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2016-09-30 14:42:10 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv7.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2016-09-30 14:42:10 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '8' to '9' migration. Adds postgresql notifier
 | 
					
						
							|  |  |  |  | // configuration, but it's otherwise the same as V8.
 | 
					
						
							|  |  |  |  | func migrateV8ToV9() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv8 := &serverConfigV8{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv8) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘8’. %w", err) | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv8.Version != "8" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V8 into V9 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV9{} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "9" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv8.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv8.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							| 
									
										
										
										
											2017-01-19 04:24:34 +08:00
										 |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv8.Logger.Console | 
					
						
							| 
									
										
										
										
											2016-11-24 08:36:26 +08:00
										 |  |  |  | 	srvConfig.Logger.Console.Level = "error" | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	srvConfig.Logger.File = cv8.Logger.File | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Syslog = cv8.Logger.Syslog | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// check and set notifiers config
 | 
					
						
							|  |  |  |  | 	if len(cv8.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv8.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv8.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]natsNotifyV1) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = natsNotifyV1{} | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv8.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv8.Notify.ElasticSearch) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.ElasticSearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.ElasticSearch["1"] = target.ElasticsearchArgs{} | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.ElasticSearch = cv8.Notify.ElasticSearch | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv8.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv8.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv8.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{} | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv8.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv8.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv8.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2016-10-04 08:29:55 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-11-24 07:00:53 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '9' to '10' migration. Remove syslog config
 | 
					
						
							|  |  |  |  | // but it's otherwise the same as V9.
 | 
					
						
							|  |  |  |  | func migrateV9ToV10() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv9 := &serverConfigV9{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv9) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘9’. %w", err) | 
					
						
							| 
									
										
										
										
											2016-11-24 07:00:53 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv9.Version != "9" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V9 into V10 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV10{} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "10" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv9.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv9.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							| 
									
										
										
										
											2017-01-19 04:24:34 +08:00
										 |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							| 
									
										
										
										
											2016-11-24 07:00:53 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv9.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv9.Logger.File | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// check and set notifiers config
 | 
					
						
							|  |  |  |  | 	if len(cv9.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2016-11-24 07:00:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv9.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv9.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]natsNotifyV1) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = natsNotifyV1{} | 
					
						
							| 
									
										
										
										
											2016-11-24 07:00:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv9.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv9.Notify.ElasticSearch) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.ElasticSearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.ElasticSearch["1"] = target.ElasticsearchArgs{} | 
					
						
							| 
									
										
										
										
											2016-11-24 07:00:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.ElasticSearch = cv9.Notify.ElasticSearch | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv9.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							| 
									
										
										
										
											2016-11-24 07:00:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv9.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv9.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{} | 
					
						
							| 
									
										
										
										
											2016-11-24 07:00:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv9.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv9.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2016-11-24 07:00:53 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv9.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2016-11-24 07:00:53 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-12-16 00:23:48 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '10' to '11' migration. Add support for Kafka
 | 
					
						
							|  |  |  |  | // notifications.
 | 
					
						
							|  |  |  |  | func migrateV10ToV11() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv10 := &serverConfigV10{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv10) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘10’. %w", err) | 
					
						
							| 
									
										
										
										
											2016-12-16 00:23:48 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv10.Version != "10" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V10 into V11 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV11{} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "11" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv10.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv10.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							| 
									
										
										
										
											2017-01-19 04:24:34 +08:00
										 |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							| 
									
										
										
										
											2016-12-16 00:23:48 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv10.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv10.Logger.File | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// check and set notifiers config
 | 
					
						
							|  |  |  |  | 	if len(cv10.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2016-12-16 00:23:48 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv10.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv10.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]natsNotifyV1) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = natsNotifyV1{} | 
					
						
							| 
									
										
										
										
											2016-12-16 00:23:48 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv10.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv10.Notify.ElasticSearch) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.ElasticSearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.ElasticSearch["1"] = target.ElasticsearchArgs{} | 
					
						
							| 
									
										
										
										
											2016-12-16 00:23:48 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.ElasticSearch = cv10.Notify.ElasticSearch | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv10.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							| 
									
										
										
										
											2016-12-16 00:23:48 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv10.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv10.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{} | 
					
						
							| 
									
										
										
										
											2016-12-16 00:23:48 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv10.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	// V10 will not have a Kafka config. So we initialize one here.
 | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 	srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2016-12-16 00:23:48 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv10.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2016-12-16 00:23:48 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv10.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2016-12-16 00:23:48 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '11' to '12' migration. Add support for NATS streaming
 | 
					
						
							|  |  |  |  | // notifications.
 | 
					
						
							|  |  |  |  | func migrateV11ToV12() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv11 := &serverConfigV11{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv11) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘11’. %w", err) | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv11.Version != "11" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V11 into V12 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV12{} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "12" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv11.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv11.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							| 
									
										
										
										
											2017-01-19 04:24:34 +08:00
										 |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv11.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv11.Logger.File | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// check and set notifiers config
 | 
					
						
							|  |  |  |  | 	if len(cv11.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv11.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv11.Notify.ElasticSearch) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.ElasticSearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.ElasticSearch["1"] = target.ElasticsearchArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.ElasticSearch = cv11.Notify.ElasticSearch | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv11.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv11.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv11.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv11.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv11.Notify.Kafka) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv11.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// V12 will have an updated config of nats. So we create a new one or we
 | 
					
						
							|  |  |  |  | 	// update the old one if found.
 | 
					
						
							|  |  |  |  | 	if len(cv11.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 		for k, v := range cv11.Notify.NATS { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			if v.Address == "" { | 
					
						
							|  |  |  |  | 				continue | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 			var addr *xnet.Host | 
					
						
							|  |  |  |  | 			addr, err = xnet.ParseHost(v.Address) | 
					
						
							|  |  |  |  | 			if err != nil { | 
					
						
							|  |  |  |  | 				return err | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 			n := target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 			n.Enable = v.Enable | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 			n.Address = *addr | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 			n.Subject = v.Subject | 
					
						
							|  |  |  |  | 			n.Username = v.Username | 
					
						
							|  |  |  |  | 			n.Password = v.Password | 
					
						
							|  |  |  |  | 			n.Token = v.Token | 
					
						
							|  |  |  |  | 			n.Secure = v.Secure | 
					
						
							|  |  |  |  | 			n.PingInterval = v.PingInterval | 
					
						
							|  |  |  |  | 			srvConfig.Notify.NATS[k] = n | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv11.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv11.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2017-01-12 08:41:05 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '12' to '13' migration. Add support for custom webhook endpoint.
 | 
					
						
							|  |  |  |  | func migrateV12ToV13() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv12 := &serverConfigV12{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv12) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘12’. %w", err) | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv12.Version != "12" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V12 into V13 config struct
 | 
					
						
							| 
									
										
										
										
											2017-02-10 07:20:54 +08:00
										 |  |  |  | 	srvConfig := &serverConfigV13{ | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 		Logger: &loggerV7{}, | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: ¬ifierV3{}, | 
					
						
							| 
									
										
										
										
											2017-02-10 07:20:54 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	srvConfig.Version = "13" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv12.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv12.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							| 
									
										
										
										
											2017-01-19 04:24:34 +08:00
										 |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv12.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv12.Logger.File | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// check and set notifiers config
 | 
					
						
							|  |  |  |  | 	if len(cv12.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv12.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv12.Notify.ElasticSearch) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Elasticsearch = cv12.Notify.ElasticSearch | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv12.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv12.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv12.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv12.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv12.Notify.Kafka) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv12.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv12.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv12.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// V12 will not have a webhook config. So we initialize one here.
 | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 	srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv12.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv12.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2017-01-10 06:22:10 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | // Version '13' to '14' migration. Add support for browser param.
 | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | func migrateV13ToV14() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv13 := &serverConfigV13{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv13) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘13’. %w", err) | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv13.Version != "13" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V13 into V14 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV14{ | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 		Logger: &loggerV7{}, | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: ¬ifierV3{}, | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "14" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv13.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv13.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv13.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv13.Logger.File | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// check and set notifiers config
 | 
					
						
							|  |  |  |  | 	if len(cv13.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv13.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	if len(cv13.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{} | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Elasticsearch = cv13.Notify.Elasticsearch | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv13.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv13.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv13.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{} | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv13.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv13.Notify.Kafka) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv13.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv13.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv13.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv13.Notify.Webhook) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv13.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Set the new browser parameter to true by default
 | 
					
						
							| 
									
										
										
										
											2017-03-27 03:00:27 +08:00
										 |  |  |  | 	srvConfig.Browser = true | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv13.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv13.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2017-02-28 06:59:53 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '14' to '15' migration. Add support for MySQL notifications.
 | 
					
						
							|  |  |  |  | func migrateV14ToV15() error { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv14 := &serverConfigV14{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv14) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 01:23:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘14’. %w", err) | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv14.Version != "14" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V14 into V15 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV15{ | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 		Logger: &loggerV7{}, | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: ¬ifierV3{}, | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "15" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv14.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv14.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv14.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv14.Logger.File | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// check and set notifiers config
 | 
					
						
							|  |  |  |  | 	if len(cv14.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv14.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	if len(cv14.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Elasticsearch = cv14.Notify.Elasticsearch | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv14.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv14.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv14.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv14.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv14.Notify.Kafka) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv14.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv14.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv14.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv14.Notify.Webhook) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv14.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// V14 will not have mysql support, so we add that here.
 | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 	srvConfig.Notify.MySQL["1"] = target.MySQLArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv14.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv14.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv14.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2017-03-18 00:29:17 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '15' to '16' migration. Remove log level in loggers
 | 
					
						
							|  |  |  |  | // and rename 'fileName' filed in File logger to 'filename'
 | 
					
						
							|  |  |  |  | func migrateV15ToV16() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv15 := &serverConfigV15{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv15) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘15’. %w", err) | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv15.Version != "15" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V15 into V16 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV16{ | 
					
						
							| 
									
										
										
										
											2017-03-24 07:36:00 +08:00
										 |  |  |  | 		Logger: &loggers{}, | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: ¬ifierV3{}, | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "16" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv15.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv15.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// check and set notifiers config
 | 
					
						
							|  |  |  |  | 	if len(cv15.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv15.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	if len(cv15.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Elasticsearch = cv15.Notify.Elasticsearch | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv15.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv15.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv15.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv15.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv15.Notify.Kafka) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv15.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv15.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv15.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv15.Notify.Webhook) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv15.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv15.Notify.MySQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL["1"] = target.MySQLArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = cv15.Notify.MySQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv15.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv15.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv15.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2017-03-23 23:27:22 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '16' to '17' migration. Adds "format" configuration
 | 
					
						
							|  |  |  |  | // parameter for database targets.
 | 
					
						
							|  |  |  |  | func migrateV16ToV17() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv16 := &serverConfigV16{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv16) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘16’. %w", err) | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv16.Version != "16" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V16 into V17 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV17{ | 
					
						
							|  |  |  |  | 		Logger: &loggers{}, | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: ¬ifierV3{}, | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "17" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv16.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv16.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv16.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv16.Logger.File | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// check and set notifiers config
 | 
					
						
							|  |  |  |  | 	if len(cv16.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv16.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	if len(cv16.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		// IMPORTANT NOTE: Future migrations should remove
 | 
					
						
							|  |  |  |  | 		// this as existing configuration will already contain
 | 
					
						
							|  |  |  |  | 		// a value for the "format" parameter.
 | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Elasticsearch = cv16.Notify.Elasticsearch | 
					
						
							|  |  |  |  | 		for k, v := range srvConfig.Notify.Elasticsearch { | 
					
						
							|  |  |  |  | 			v.Format = event.NamespaceFormat | 
					
						
							|  |  |  |  | 			srvConfig.Notify.Elasticsearch[k] = v | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv16.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		// IMPORTANT NOTE: Future migrations should remove
 | 
					
						
							|  |  |  |  | 		// this as existing configuration will already contain
 | 
					
						
							|  |  |  |  | 		// a value for the "format" parameter.
 | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv16.Notify.Redis | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		for k, v := range srvConfig.Notify.Redis { | 
					
						
							|  |  |  |  | 			v.Format = event.NamespaceFormat | 
					
						
							|  |  |  |  | 			srvConfig.Notify.Redis[k] = v | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv16.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		// IMPORTANT NOTE: Future migrations should remove
 | 
					
						
							|  |  |  |  | 		// this as existing configuration will already contain
 | 
					
						
							|  |  |  |  | 		// a value for the "format" parameter.
 | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv16.Notify.PostgreSQL | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		for k, v := range srvConfig.Notify.PostgreSQL { | 
					
						
							|  |  |  |  | 			v.Format = event.NamespaceFormat | 
					
						
							|  |  |  |  | 			srvConfig.Notify.PostgreSQL[k] = v | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv16.Notify.Kafka) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv16.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv16.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv16.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv16.Notify.Webhook) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv16.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv16.Notify.MySQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL["1"] = target.MySQLArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		// IMPORTANT NOTE: Future migrations should remove
 | 
					
						
							|  |  |  |  | 		// this as existing configuration will already contain
 | 
					
						
							|  |  |  |  | 		// a value for the "format" parameter.
 | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = cv16.Notify.MySQL | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		for k, v := range srvConfig.Notify.MySQL { | 
					
						
							|  |  |  |  | 			v.Format = event.NamespaceFormat | 
					
						
							|  |  |  |  | 			srvConfig.Notify.MySQL[k] = v | 
					
						
							|  |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv16.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv16.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv16.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2017-03-28 02:27:25 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | // Version '17' to '18' migration. Adds "deliveryMode" configuration
 | 
					
						
							|  |  |  |  | // parameter for AMQP notification target
 | 
					
						
							|  |  |  |  | func migrateV17ToV18() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv17 := &serverConfigV17{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv17) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘17’. %w", err) | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv17.Version != "17" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V17 into V18 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV17{ | 
					
						
							|  |  |  |  | 		Logger: &loggers{}, | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: ¬ifierV3{}, | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "18" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv17.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv17.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv17.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv17.Logger.File | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// check and set notifiers config
 | 
					
						
							|  |  |  |  | 	if len(cv17.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		// New deliveryMode parameter is added for AMQP,
 | 
					
						
							|  |  |  |  | 		// default value is already 0, so nothing to
 | 
					
						
							|  |  |  |  | 		// explicitly migrate here.
 | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv17.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	if len(cv17.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Elasticsearch = cv17.Notify.Elasticsearch | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv17.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv17.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv17.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv17.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv17.Notify.Kafka) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv17.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv17.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv17.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv17.Notify.Webhook) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv17.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv17.Notify.MySQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL["1"] = target.MySQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = cv17.Notify.MySQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv17.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv17.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv17.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2017-03-31 18:34:26 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV18ToV19() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv18 := &serverConfigV18{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv18) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘18’. %w", err) | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv18.Version != "18" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V18 into V19 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV18{ | 
					
						
							|  |  |  |  | 		Logger: &loggers{}, | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: ¬ifierV3{}, | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "19" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv18.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv18.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv18.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv18.Logger.File | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// check and set notifiers config
 | 
					
						
							|  |  |  |  | 	if len(cv18.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		// New deliveryMode parameter is added for AMQP,
 | 
					
						
							|  |  |  |  | 		// default value is already 0, so nothing to
 | 
					
						
							|  |  |  |  | 		// explicitly migrate here.
 | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv18.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	if len(cv18.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Elasticsearch = cv18.Notify.Elasticsearch | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv18.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv18.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv18.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv18.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv18.Notify.Kafka) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv18.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv18.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv18.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv18.Notify.Webhook) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv18.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv18.Notify.MySQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL["1"] = target.MySQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = cv18.Notify.MySQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// V18 will not have mqtt support, so we add that here.
 | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	srvConfig.Notify.MQTT = make(map[string]target.MQTTArgs) | 
					
						
							|  |  |  |  | 	srvConfig.Notify.MQTT["1"] = target.MQTTArgs{} | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv18.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv18.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv18.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2017-06-15 08:27:03 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV19ToV20() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv19 := &serverConfigV19{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv19) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘18’. %w", err) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv19.Version != "19" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V19 into V20 config struct
 | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	srvConfig := &serverConfigV20{ | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 		Logger: &loggers{}, | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: ¬ifierV3{}, | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "20" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv19.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv19.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console = cv19.Logger.Console | 
					
						
							|  |  |  |  | 	srvConfig.Logger.File = cv19.Logger.File | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if len(cv19.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv19.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	if len(cv19.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Elasticsearch = cv19.Notify.Elasticsearch | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv19.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv19.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv19.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv19.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv19.Notify.Kafka) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv19.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv19.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv19.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv19.Notify.Webhook) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv19.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv19.Notify.MySQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL["1"] = target.MySQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = cv19.Notify.MySQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	if len(cv19.Notify.MQTT) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.MQTT = make(map[string]target.MQTTArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT["1"] = target.MQTTArgs{} | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT = cv19.Notify.MQTT | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv19.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv19.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv19.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2017-11-15 08:56:24 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV20ToV21() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv20 := &serverConfigV20{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv20) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘20’. %w", err) | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv20.Version != "20" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V20 into V21 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV21{ | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: ¬ifierV3{}, | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2017-12-18 13:00:12 +08:00
										 |  |  |  | 	srvConfig.Version = "21" | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	srvConfig.Credential = cv20.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv20.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if len(cv20.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv20.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	if len(cv20.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Elasticsearch = cv20.Notify.Elasticsearch | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv20.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv20.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv20.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv20.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv20.Notify.Kafka) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv20.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv20.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv20.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv20.Notify.Webhook) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv20.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv20.Notify.MySQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL["1"] = target.MySQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = cv20.Notify.MySQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	if len(cv20.Notify.MQTT) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.MQTT = make(map[string]target.MQTTArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT["1"] = target.MQTTArgs{} | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT = cv20.Notify.MQTT | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv20.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load domain config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Domain = cv20.Domain | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv20.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv20.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2017-12-06 15:18:29 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV21ToV22() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv21 := &serverConfigV21{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv21) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘21’. %w", err) | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv21.Version != "21" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V21 into V22 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV22{ | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: notifierV3{}, | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-30 05:38:26 +08:00
										 |  |  |  | 	srvConfig.Version = "22" | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	srvConfig.Credential = cv21.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv21.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if len(cv21.Notify.AMQP) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv21.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 	if len(cv21.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Elasticsearch = cv21.Notify.Elasticsearch | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv21.Notify.Redis) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv21.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv21.Notify.PostgreSQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv21.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv21.Notify.Kafka) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv21.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv21.Notify.NATS) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv21.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv21.Notify.Webhook) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv21.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv21.Notify.MySQL) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL["1"] = target.MySQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = cv21.Notify.MySQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	if len(cv21.Notify.MQTT) == 0 { | 
					
						
							| 
									
										
										
										
											2018-03-16 04:03:41 +08:00
										 |  |  |  | 		srvConfig.Notify.MQTT = make(map[string]target.MQTTArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT["1"] = target.MQTTArgs{} | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT = cv21.Notify.MQTT | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv21.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load domain config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Domain = cv21.Domain | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv21.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv21.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2017-12-22 19:28:13 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV22ToV23() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv22 := &serverConfigV22{} | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	_, err := Load(configFile, cv22) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘22’. %w", err) | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv22.Version != "22" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V22 into V23 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV23{ | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: notifierV3{}, | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-03-30 05:38:26 +08:00
										 |  |  |  | 	srvConfig.Version = "23" | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 	srvConfig.Credential = cv22.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv22.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if len(cv22.Notify.AMQP) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv22.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv22.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = cv22.Notify.Elasticsearch | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv22.Notify.Redis) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv22.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv22.Notify.PostgreSQL) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv22.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv22.Notify.Kafka) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv22.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv22.Notify.NATS) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv22.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv22.Notify.Webhook) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv22.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv22.Notify.MySQL) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL["1"] = target.MySQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = cv22.Notify.MySQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if len(cv22.Notify.MQTT) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT = make(map[string]target.MQTTArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT["1"] = target.MQTTArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT = cv22.Notify.MQTT | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv22.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load domain config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Domain = cv22.Domain | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-30 04:21:58 +08:00
										 |  |  |  | 	// Load storage class config from existing storage class config in the file
 | 
					
						
							|  |  |  |  | 	srvConfig.StorageClass.RRS = cv22.StorageClass.RRS | 
					
						
							|  |  |  |  | 	srvConfig.StorageClass.Standard = cv22.StorageClass.Standard | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 	// Init cache config.For future migration, Cache config needs to be copied over from previous version.
 | 
					
						
							|  |  |  |  | 	srvConfig.Cache.Drives = []string{} | 
					
						
							|  |  |  |  | 	srvConfig.Cache.Exclude = []string{} | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  |  | 	srvConfig.Cache.Expiry = 90 | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-05 23:18:42 +08:00
										 |  |  |  | 	if err = Save(configFile, srvConfig); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv22.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-11 00:37:14 +08:00
										 |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv22.Version, srvConfig.Version) | 
					
						
							| 
									
										
										
										
											2018-03-29 05:14:06 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-06-05 09:35:41 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV23ToV24() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv23 := &serverConfigV23{} | 
					
						
							| 
									
										
										
										
											2018-05-16 09:20:22 +08:00
										 |  |  |  | 	_, err := quick.LoadConfig(configFile, globalEtcdClient, cv23) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2018-06-05 09:35:41 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘23’. %w", err) | 
					
						
							| 
									
										
										
										
											2018-06-05 09:35:41 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv23.Version != "23" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V23 into V24 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV24{ | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: notifierV3{}, | 
					
						
							| 
									
										
										
										
											2018-06-05 09:35:41 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "24" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv23.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv23.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if len(cv23.Notify.AMQP) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv23.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv23.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = cv23.Notify.Elasticsearch | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv23.Notify.Redis) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv23.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv23.Notify.PostgreSQL) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv23.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv23.Notify.Kafka) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv23.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv23.Notify.NATS) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv23.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv23.Notify.Webhook) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv23.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv23.Notify.MySQL) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL["1"] = target.MySQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = cv23.Notify.MySQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if len(cv23.Notify.MQTT) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT = make(map[string]target.MQTTArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT["1"] = target.MQTTArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT = cv23.Notify.MQTT | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv23.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load domain config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Domain = cv23.Domain | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load storage class config from existing storage class config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.StorageClass.RRS = cv23.StorageClass.RRS | 
					
						
							|  |  |  |  | 	srvConfig.StorageClass.Standard = cv23.StorageClass.Standard | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load cache config from existing cache config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Cache.Drives = cv23.Cache.Drives | 
					
						
							|  |  |  |  | 	srvConfig.Cache.Exclude = cv23.Cache.Exclude | 
					
						
							|  |  |  |  | 	srvConfig.Cache.Expiry = cv23.Cache.Expiry | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-16 09:20:22 +08:00
										 |  |  |  | 	if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv23.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2018-06-05 09:35:41 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv23.Version, srvConfig.Version) | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV24ToV25() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv24 := &serverConfigV24{} | 
					
						
							| 
									
										
										
										
											2018-05-16 09:20:22 +08:00
										 |  |  |  | 	_, err := quick.LoadConfig(configFile, globalEtcdClient, cv24) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘24’. %w", err) | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv24.Version != "24" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V24 into V25 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV25{ | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: notifierV3{}, | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "25" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv24.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv24.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if len(cv24.Notify.AMQP) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv24.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv24.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = cv24.Notify.Elasticsearch | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv24.Notify.Redis) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv24.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv24.Notify.PostgreSQL) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv24.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv24.Notify.Kafka) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv24.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv24.Notify.NATS) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv24.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv24.Notify.Webhook) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv24.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv24.Notify.MySQL) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL["1"] = target.MySQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = cv24.Notify.MySQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if len(cv24.Notify.MQTT) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT = make(map[string]target.MQTTArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT["1"] = target.MQTTArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT = cv24.Notify.MQTT | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv24.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// New field should be turned-off by default.
 | 
					
						
							|  |  |  |  | 	srvConfig.Worm = false // cv25.Worm should be used here
 | 
					
						
							|  |  |  |  | 	// for the next migration from v25 to v26 to persist
 | 
					
						
							|  |  |  |  | 	// local config value.
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load domain config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Domain = cv24.Domain | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load storage class config from existing storage class config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.StorageClass.RRS = cv24.StorageClass.RRS | 
					
						
							|  |  |  |  | 	srvConfig.StorageClass.Standard = cv24.StorageClass.Standard | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load cache config from existing cache config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Cache.Drives = cv24.Cache.Drives | 
					
						
							|  |  |  |  | 	srvConfig.Cache.Exclude = cv24.Cache.Exclude | 
					
						
							|  |  |  |  | 	srvConfig.Cache.Expiry = cv24.Cache.Expiry | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-16 09:20:22 +08:00
										 |  |  |  | 	if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv24.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2018-06-07 09:10:51 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv24.Version, srvConfig.Version) | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV25ToV26() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cv25 := &serverConfigV25{} | 
					
						
							|  |  |  |  | 	_, err := quick.LoadConfig(configFile, globalEtcdClient, cv25) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config version ‘25’. %w", err) | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if cv25.Version != "25" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Copy over fields from V25 into V26 config struct
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV26{ | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 		Notify: notifierV3{}, | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	srvConfig.Version = "26" | 
					
						
							|  |  |  |  | 	srvConfig.Credential = cv25.Credential | 
					
						
							|  |  |  |  | 	srvConfig.Region = cv25.Region | 
					
						
							|  |  |  |  | 	if srvConfig.Region == "" { | 
					
						
							|  |  |  |  | 		// Region needs to be set for AWS Signature Version 4.
 | 
					
						
							|  |  |  |  | 		srvConfig.Region = globalMinioDefaultRegion | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if len(cv25.Notify.AMQP) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.AMQP = cv25.Notify.AMQP | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv25.Notify.Elasticsearch) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = make(map[string]target.ElasticsearchArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch["1"] = target.ElasticsearchArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Elasticsearch = cv25.Notify.Elasticsearch | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv25.Notify.Redis) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = make(map[string]target.RedisArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis["1"] = target.RedisArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Redis = cv25.Notify.Redis | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv25.Notify.PostgreSQL) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = make(map[string]target.PostgreSQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL["1"] = target.PostgreSQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.PostgreSQL = cv25.Notify.PostgreSQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv25.Notify.Kafka) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = make(map[string]target.KafkaArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka["1"] = target.KafkaArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Kafka = cv25.Notify.Kafka | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv25.Notify.NATS) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = make(map[string]target.NATSArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS["1"] = target.NATSArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.NATS = cv25.Notify.NATS | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv25.Notify.Webhook) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = make(map[string]target.WebhookArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook["1"] = target.WebhookArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.Webhook = cv25.Notify.Webhook | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if len(cv25.Notify.MySQL) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = make(map[string]target.MySQLArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL["1"] = target.MySQLArgs{ | 
					
						
							|  |  |  |  | 			Format: event.NamespaceFormat, | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MySQL = cv25.Notify.MySQL | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if len(cv25.Notify.MQTT) == 0 { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT = make(map[string]target.MQTTArgs) | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT["1"] = target.MQTTArgs{} | 
					
						
							|  |  |  |  | 	} else { | 
					
						
							|  |  |  |  | 		srvConfig.Notify.MQTT = cv25.Notify.MQTT | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load browser config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Browser = cv25.Browser | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load worm config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Worm = cv25.Worm | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load domain config from existing config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Domain = cv25.Domain | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load storage class config from existing storage class config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.StorageClass.RRS = cv25.StorageClass.RRS | 
					
						
							|  |  |  |  | 	srvConfig.StorageClass.Standard = cv25.StorageClass.Standard | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Load cache config from existing cache config in the file.
 | 
					
						
							|  |  |  |  | 	srvConfig.Cache.Drives = cv25.Cache.Drives | 
					
						
							|  |  |  |  | 	srvConfig.Cache.Exclude = cv25.Cache.Exclude | 
					
						
							|  |  |  |  | 	srvConfig.Cache.Expiry = cv25.Cache.Expiry | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Add predefined value to new server config.
 | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  |  | 	srvConfig.Cache.MaxUse = 80 | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %w", cv25.Version, srvConfig.Version, err) | 
					
						
							| 
									
										
										
										
											2018-06-26 01:24:12 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, cv25.Version, srvConfig.Version) | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-07-20 06:55:06 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV26ToV27() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// config V27 is backward compatible with V26, load the old
 | 
					
						
							|  |  |  |  | 	// config file in serverConfigV27 struct and put some examples
 | 
					
						
							|  |  |  |  | 	// in the new `logger` field
 | 
					
						
							|  |  |  |  | 	srvConfig := &serverConfigV27{} | 
					
						
							|  |  |  |  | 	_, err := quick.LoadConfig(configFile, globalEtcdClient, srvConfig) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2018-07-20 06:55:06 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config file. %w", err) | 
					
						
							| 
									
										
										
										
											2018-07-20 06:55:06 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if srvConfig.Version != "26" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	srvConfig.Version = "27" | 
					
						
							|  |  |  |  | 	// Enable console logging by default to avoid breaking users
 | 
					
						
							|  |  |  |  | 	// current deployments
 | 
					
						
							|  |  |  |  | 	srvConfig.Logger.Console.Enabled = true | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	srvConfig.Logger.HTTP = make(map[string]logger.HTTP) | 
					
						
							|  |  |  |  | 	srvConfig.Logger.HTTP["1"] = logger.HTTP{} | 
					
						
							| 
									
										
										
										
											2018-07-20 06:55:06 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘26’ to ‘27’. %w", err) | 
					
						
							| 
									
										
										
										
											2018-07-20 06:55:06 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, "26", "27") | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV27ToV28() error { | 
					
						
							|  |  |  |  | 	configFile := getConfigFile() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// config V28 is backward compatible with V27, load the old
 | 
					
						
							|  |  |  |  | 	// config file in serverConfigV28 struct and initialize KMSConfig
 | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 	srvConfig := &serverConfigV28{} | 
					
						
							|  |  |  |  | 	_, err := quick.LoadConfig(configFile, globalEtcdClient, srvConfig) | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config file. %w", err) | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	if srvConfig.Version != "27" { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	srvConfig.Version = "28" | 
					
						
							|  |  |  |  | 	srvConfig.KMS = crypto.KMSConfig{} | 
					
						
							|  |  |  |  | 	if err = quick.SaveConfig(srvConfig, configFile, globalEtcdClient); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘27’ to ‘28’. %w", err) | 
					
						
							| 
									
										
										
										
											2018-08-18 03:52:14 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, "27", "28") | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-08-18 09:51:34 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-29 09:38:23 +08:00
										 |  |  |  | // Migrates ${HOME}/.minio/config.json to '<export_path>/.minio.sys/config/config.json'
 | 
					
						
							| 
									
										
										
										
											2019-06-14 15:29:22 +08:00
										 |  |  |  | // if etcd is configured then migrates /config/config.json to '<export_path>/.minio.sys/config/config.json'
 | 
					
						
							| 
									
										
										
										
											2018-11-29 09:38:23 +08:00
										 |  |  |  | func migrateConfigToMinioSys(objAPI ObjectLayer) (err error) { | 
					
						
							| 
									
										
										
										
											2019-01-16 16:29:21 +08:00
										 |  |  |  | 	// Construct path to config.json for the given bucket.
 | 
					
						
							|  |  |  |  | 	configFile := path.Join(minioConfigPrefix, minioConfigFile) | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-29 09:38:23 +08:00
										 |  |  |  | 	defer func() { | 
					
						
							|  |  |  |  | 		if err == nil { | 
					
						
							| 
									
										
										
										
											2019-06-14 15:29:22 +08:00
										 |  |  |  | 			if globalEtcdClient != nil { | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  |  | 				deleteKeyEtcd(GlobalContext, globalEtcdClient, configFile) | 
					
						
							| 
									
										
										
										
											2019-06-14 15:29:22 +08:00
										 |  |  |  | 			} else { | 
					
						
							|  |  |  |  | 				// Rename config.json to config.json.deprecated only upon
 | 
					
						
							|  |  |  |  | 				// success of this function.
 | 
					
						
							|  |  |  |  | 				os.Rename(getConfigFile(), getConfigFile()+".deprecated") | 
					
						
							|  |  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2018-11-29 09:38:23 +08:00
										 |  |  |  | 		} | 
					
						
							|  |  |  |  | 	}() | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-16 16:29:21 +08:00
										 |  |  |  | 	// Verify if backend already has the file (after holding lock)
 | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  |  | 	if err = checkConfig(GlobalContext, objAPI, configFile); err != errConfigNotFound { | 
					
						
							| 
									
										
										
										
											2018-11-29 09:38:23 +08:00
										 |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} // if errConfigNotFound proceed to migrate..
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-14 15:29:22 +08:00
										 |  |  |  | 	var configFiles = []string{ | 
					
						
							|  |  |  |  | 		getConfigFile(), | 
					
						
							|  |  |  |  | 		getConfigFile() + ".deprecated", | 
					
						
							|  |  |  |  | 		configFile, | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  |  | 	var config = &serverConfigV27{} | 
					
						
							| 
									
										
										
										
											2019-06-14 15:29:22 +08:00
										 |  |  |  | 	for _, cfgFile := range configFiles { | 
					
						
							|  |  |  |  | 		if _, err = Load(cfgFile, config); err != nil { | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 			if !os.IsNotExist(err) && !os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2019-01-24 03:10:59 +08:00
										 |  |  |  | 				return err | 
					
						
							|  |  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2019-06-14 15:29:22 +08:00
										 |  |  |  | 			continue | 
					
						
							| 
									
										
										
										
											2018-11-29 09:38:23 +08:00
										 |  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2019-06-14 15:29:22 +08:00
										 |  |  |  | 		break | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2019-10-08 13:47:56 +08:00
										 |  |  |  | 	if os.IsPermission(err) { | 
					
						
							|  |  |  |  | 		logger.Info("Older config found but not readable %s, proceeding to initialize new config anyways", err) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if os.IsNotExist(err) || os.IsPermission(err) { | 
					
						
							| 
									
										
										
										
											2019-06-14 15:29:22 +08:00
										 |  |  |  | 		// Initialize the server config, if no config exists.
 | 
					
						
							|  |  |  |  | 		return newSrvConfig(objAPI) | 
					
						
							| 
									
										
										
										
											2019-01-24 03:10:59 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  |  | 	return saveServerConfig(GlobalContext, objAPI, config) | 
					
						
							| 
									
										
										
										
											2018-11-29 09:38:23 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-30 13:16:17 +08:00
										 |  |  |  | // Migrates '.minio.sys/config.json' to v33.
 | 
					
						
							| 
									
										
										
										
											2018-08-18 09:51:34 +08:00
										 |  |  |  | func migrateMinioSysConfig(objAPI ObjectLayer) error { | 
					
						
							| 
									
										
										
										
											2019-11-05 01:30:59 +08:00
										 |  |  |  | 	// Construct path to config.json for the given bucket.
 | 
					
						
							| 
									
										
										
										
											2018-11-29 09:38:23 +08:00
										 |  |  |  | 	configFile := path.Join(minioConfigPrefix, minioConfigFile) | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-16 16:29:21 +08:00
										 |  |  |  | 	// Check if the config version is latest, if not migrate.
 | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  |  | 	ok, _, err := checkConfigVersion(objAPI, configFile, "33") | 
					
						
							| 
									
										
										
										
											2019-01-16 16:29:21 +08:00
										 |  |  |  | 	if err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if ok { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-21 05:56:32 +08:00
										 |  |  |  | 	if err := migrateV27ToV28MinioSys(objAPI); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 	if err := migrateV28ToV29MinioSys(objAPI); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	if err := migrateV29ToV30MinioSys(objAPI); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 	if err := migrateV30ToV31MinioSys(objAPI); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-11-30 13:16:17 +08:00
										 |  |  |  | 	if err := migrateV31ToV32MinioSys(objAPI); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	return migrateV32ToV33MinioSys(objAPI) | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | func checkConfigVersion(objAPI ObjectLayer, configFile string, version string) (bool, []byte, error) { | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  |  | 	data, err := readConfig(GlobalContext, objAPI, configFile) | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	if err != nil { | 
					
						
							|  |  |  |  | 		return false, nil, err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-07-18 08:41:29 +08:00
										 |  |  |  | 	if globalConfigEncrypted && !utf8.Valid(data) { | 
					
						
							| 
									
										
										
										
											2019-11-02 06:53:16 +08:00
										 |  |  |  | 		data, err = madmin.DecryptData(globalActiveCred.String(), bytes.NewReader(data)) | 
					
						
							|  |  |  |  | 		if err != nil { | 
					
						
							|  |  |  |  | 			if err == madmin.ErrMaliciousData { | 
					
						
							|  |  |  |  | 				return false, nil, config.ErrInvalidCredentialsBackendEncrypted(nil) | 
					
						
							|  |  |  |  | 			} | 
					
						
							|  |  |  |  | 			return false, nil, err | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	var versionConfig struct { | 
					
						
							|  |  |  |  | 		Version string `json:"version"` | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	vcfg := &versionConfig | 
					
						
							|  |  |  |  | 	if err = json.Unmarshal(data, vcfg); err != nil { | 
					
						
							|  |  |  |  | 		return false, nil, err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	return vcfg.Version == version, data, nil | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV27ToV28MinioSys(objAPI ObjectLayer) error { | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 	configFile := path.Join(minioConfigPrefix, minioConfigFile) | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	ok, data, err := checkConfigVersion(objAPI, configFile, "27") | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 	if err == errConfigNotFound { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config file. %w", err) | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	if !ok { | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	cfg := &serverConfigV28{} | 
					
						
							|  |  |  |  | 	if err = json.Unmarshal(data, cfg); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	cfg.Version = "28" | 
					
						
							|  |  |  |  | 	cfg.KMS = crypto.KMSConfig{} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  |  | 	if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘27’ to ‘28’. %w", err) | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, "27", "28") | 
					
						
							| 
									
										
										
										
											2018-09-28 11:36:17 +08:00
										 |  |  |  | 	return nil | 
					
						
							| 
									
										
										
										
											2018-09-21 05:56:32 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV28ToV29MinioSys(objAPI ObjectLayer) error { | 
					
						
							|  |  |  |  | 	configFile := path.Join(minioConfigPrefix, minioConfigFile) | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	ok, data, err := checkConfigVersion(objAPI, configFile, "28") | 
					
						
							| 
									
										
										
										
											2018-09-21 05:56:32 +08:00
										 |  |  |  | 	if err == errConfigNotFound { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config file. %w", err) | 
					
						
							| 
									
										
										
										
											2018-09-21 05:56:32 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	if !ok { | 
					
						
							| 
									
										
										
										
											2018-09-21 05:56:32 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	cfg := &serverConfigV29{} | 
					
						
							|  |  |  |  | 	if err = json.Unmarshal(data, cfg); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cfg.Version = "29" | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  |  | 	if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘28’ to ‘29’. %w", err) | 
					
						
							| 
									
										
										
										
											2018-09-21 05:56:32 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, "28", "29") | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							| 
									
										
										
										
											2018-08-18 09:51:34 +08:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | func migrateV29ToV30MinioSys(objAPI ObjectLayer) error { | 
					
						
							| 
									
										
										
										
											2018-08-18 09:51:34 +08:00
										 |  |  |  | 	configFile := path.Join(minioConfigPrefix, minioConfigFile) | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 	ok, data, err := checkConfigVersion(objAPI, configFile, "29") | 
					
						
							| 
									
										
										
										
											2018-08-18 09:51:34 +08:00
										 |  |  |  | 	if err == errConfigNotFound { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config file. %w", err) | 
					
						
							| 
									
										
										
										
											2018-08-18 09:51:34 +08:00
										 |  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	if !ok { | 
					
						
							| 
									
										
										
										
											2018-08-18 09:51:34 +08:00
										 |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	cfg := &serverConfigV30{} | 
					
						
							|  |  |  |  | 	if err = json.Unmarshal(data, cfg); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							| 
									
										
										
										
											2018-08-18 09:51:34 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	cfg.Version = "30" | 
					
						
							|  |  |  |  | 	// Init compression config.For future migration, Compression config needs to be copied over from previous version.
 | 
					
						
							|  |  |  |  | 	cfg.Compression.Enabled = false | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  |  | 	cfg.Compression.Extensions = strings.Split(compress.DefaultExtensions, config.ValueSeparator) | 
					
						
							|  |  |  |  | 	cfg.Compression.MimeTypes = strings.Split(compress.DefaultMimeTypes, config.ValueSeparator) | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  |  | 	if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘29’ to ‘30’. %w", err) | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, "29", "30") | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV30ToV31MinioSys(objAPI ObjectLayer) error { | 
					
						
							|  |  |  |  | 	configFile := path.Join(minioConfigPrefix, minioConfigFile) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	ok, data, err := checkConfigVersion(objAPI, configFile, "30") | 
					
						
							|  |  |  |  | 	if err == errConfigNotFound { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config file. %w", err) | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if !ok { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cfg := &serverConfigV31{} | 
					
						
							|  |  |  |  | 	if err = json.Unmarshal(data, cfg); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cfg.Version = "31" | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  |  | 	cfg.OpenID = openid.Config{} | 
					
						
							|  |  |  |  | 	cfg.OpenID.JWKS.URL = &xnet.URL{} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cfg.Policy.OPA = opa.Args{ | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 		URL:       &xnet.URL{}, | 
					
						
							|  |  |  |  | 		AuthToken: "", | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  |  | 	if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘30’ to ‘31’. %w", err) | 
					
						
							| 
									
										
										
										
											2018-10-10 05:00:01 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, "30", "31") | 
					
						
							| 
									
										
										
										
											2018-08-18 09:51:34 +08:00
										 |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV31ToV32MinioSys(objAPI ObjectLayer) error { | 
					
						
							|  |  |  |  | 	configFile := path.Join(minioConfigPrefix, minioConfigFile) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	ok, data, err := checkConfigVersion(objAPI, configFile, "31") | 
					
						
							|  |  |  |  | 	if err == errConfigNotFound { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config file. %w", err) | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if !ok { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cfg := &serverConfigV32{} | 
					
						
							|  |  |  |  | 	if err = json.Unmarshal(data, cfg); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cfg.Version = "32" | 
					
						
							|  |  |  |  | 	cfg.Notify.NSQ = make(map[string]target.NSQArgs) | 
					
						
							|  |  |  |  | 	cfg.Notify.NSQ["1"] = target.NSQArgs{} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  |  | 	if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from ‘31’ to ‘32’. %w", err) | 
					
						
							| 
									
										
										
										
											2018-11-08 02:23:13 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, "31", "32") | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-11-30 13:16:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateV32ToV33MinioSys(objAPI ObjectLayer) error { | 
					
						
							|  |  |  |  | 	configFile := path.Join(minioConfigPrefix, minioConfigFile) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	ok, data, err := checkConfigVersion(objAPI, configFile, "32") | 
					
						
							|  |  |  |  | 	if err == errConfigNotFound { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} else if err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Unable to load config file. %w", err) | 
					
						
							| 
									
										
										
										
											2018-11-30 13:16:17 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if !ok { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cfg := &serverConfigV33{} | 
					
						
							|  |  |  |  | 	if err = json.Unmarshal(data, cfg); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cfg.Version = "33" | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  |  | 	if err = saveServerConfig(GlobalContext, objAPI, cfg); err != nil { | 
					
						
							| 
									
										
										
										
											2019-12-03 01:28:01 +08:00
										 |  |  |  | 		return fmt.Errorf("Failed to migrate config from '32' to '33' . %w", err) | 
					
						
							| 
									
										
										
										
											2018-11-30 13:16:17 +08:00
										 |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info(configMigrateMSGTemplate, configFile, "32", "33") | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | func migrateMinioSysConfigToKV(objAPI ObjectLayer) error { | 
					
						
							|  |  |  |  | 	configFile := path.Join(minioConfigPrefix, minioConfigFile) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	// Check if the config version is latest, if not migrate.
 | 
					
						
							|  |  |  |  | 	ok, data, err := checkConfigVersion(objAPI, configFile, "33") | 
					
						
							|  |  |  |  | 	if err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	if !ok { | 
					
						
							|  |  |  |  | 		return nil | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	cfg := &serverConfigV33{} | 
					
						
							|  |  |  |  | 	if err = json.Unmarshal(data, cfg); err != nil { | 
					
						
							|  |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	newCfg := newServerConfig() | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	config.SetCredentials(newCfg, cfg.Credential) | 
					
						
							|  |  |  |  | 	config.SetRegion(newCfg, cfg.Region) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	storageclass.SetStorageClass(newCfg, cfg.StorageClass) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for k, loggerArgs := range cfg.Logger.HTTP { | 
					
						
							|  |  |  |  | 		logger.SetLoggerHTTP(newCfg, k, loggerArgs) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	for k, auditArgs := range cfg.Logger.Audit { | 
					
						
							|  |  |  |  | 		logger.SetLoggerHTTPAudit(newCfg, k, auditArgs) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	crypto.SetKMSConfig(newCfg, cfg.KMS) | 
					
						
							|  |  |  |  | 	xldap.SetIdentityLDAP(newCfg, cfg.LDAPServerConfig) | 
					
						
							|  |  |  |  | 	openid.SetIdentityOpenID(newCfg, cfg.OpenID) | 
					
						
							|  |  |  |  | 	opa.SetPolicyOPAConfig(newCfg, cfg.Policy.OPA) | 
					
						
							|  |  |  |  | 	cache.SetCacheConfig(newCfg, cfg.Cache) | 
					
						
							|  |  |  |  | 	compress.SetCompressionConfig(newCfg, cfg.Compression) | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	for k, args := range cfg.Notify.AMQP { | 
					
						
							|  |  |  |  | 		notify.SetNotifyAMQP(newCfg, k, args) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	for k, args := range cfg.Notify.Elasticsearch { | 
					
						
							|  |  |  |  | 		notify.SetNotifyES(newCfg, k, args) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	for k, args := range cfg.Notify.Kafka { | 
					
						
							|  |  |  |  | 		notify.SetNotifyKafka(newCfg, k, args) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	for k, args := range cfg.Notify.MQTT { | 
					
						
							|  |  |  |  | 		notify.SetNotifyMQTT(newCfg, k, args) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	for k, args := range cfg.Notify.MySQL { | 
					
						
							|  |  |  |  | 		notify.SetNotifyMySQL(newCfg, k, args) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	for k, args := range cfg.Notify.NATS { | 
					
						
							|  |  |  |  | 		notify.SetNotifyNATS(newCfg, k, args) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	for k, args := range cfg.Notify.NSQ { | 
					
						
							|  |  |  |  | 		notify.SetNotifyNSQ(newCfg, k, args) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	for k, args := range cfg.Notify.PostgreSQL { | 
					
						
							|  |  |  |  | 		notify.SetNotifyPostgres(newCfg, k, args) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	for k, args := range cfg.Notify.Redis { | 
					
						
							|  |  |  |  | 		notify.SetNotifyRedis(newCfg, k, args) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 	for k, args := range cfg.Notify.Webhook { | 
					
						
							|  |  |  |  | 		notify.SetNotifyWebhook(newCfg, k, args) | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-10 00:30:02 +08:00
										 |  |  |  | 	if err = saveServerConfig(GlobalContext, objAPI, newCfg); err != nil { | 
					
						
							| 
									
										
										
										
											2019-10-23 13:59:13 +08:00
										 |  |  |  | 		return err | 
					
						
							|  |  |  |  | 	} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 	logger.Info("Configuration file %s migrated from version '%s' to new KV format successfully.", | 
					
						
							|  |  |  |  | 		configFile, "33") | 
					
						
							|  |  |  |  | 	return nil | 
					
						
							|  |  |  |  | } |