| 
									
										
										
										
											2024-03-25 23:43:28 +08:00
										 |  |  | package setting | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							| 
									
										
										
										
											2024-07-30 02:00:43 +08:00
										 |  |  | 	"path/filepath" | 
					
						
							| 
									
										
										
										
											2024-03-25 23:43:28 +08:00
										 |  |  | 	"time" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type CloudMigrationSettings struct { | 
					
						
							| 
									
										
										
										
											2024-07-15 21:22:57 +08:00
										 |  |  | 	IsTarget                    bool | 
					
						
							|  |  |  | 	GcomAPIToken                string | 
					
						
							| 
									
										
										
										
											2024-11-22 02:46:06 +08:00
										 |  |  | 	AuthAPIUrl                  string | 
					
						
							| 
									
										
										
										
											2024-07-15 21:22:57 +08:00
										 |  |  | 	SnapshotFolder              string | 
					
						
							|  |  |  | 	GMSDomain                   string | 
					
						
							|  |  |  | 	GMSStartSnapshotTimeout     time.Duration | 
					
						
							|  |  |  | 	GMSGetSnapshotStatusTimeout time.Duration | 
					
						
							| 
									
										
										
										
											2024-07-17 23:53:21 +08:00
										 |  |  | 	GMSCreateUploadUrlTimeout   time.Duration | 
					
						
							| 
									
										
										
										
											2024-07-15 21:22:57 +08:00
										 |  |  | 	GMSValidateKeyTimeout       time.Duration | 
					
						
							| 
									
										
										
										
											2024-07-20 12:02:31 +08:00
										 |  |  | 	GMSReportEventTimeout       time.Duration | 
					
						
							| 
									
										
										
										
											2024-07-15 21:22:57 +08:00
										 |  |  | 	FetchInstanceTimeout        time.Duration | 
					
						
							|  |  |  | 	CreateAccessPolicyTimeout   time.Duration | 
					
						
							|  |  |  | 	FetchAccessPolicyTimeout    time.Duration | 
					
						
							|  |  |  | 	DeleteAccessPolicyTimeout   time.Duration | 
					
						
							|  |  |  | 	ListTokensTimeout           time.Duration | 
					
						
							|  |  |  | 	CreateTokenTimeout          time.Duration | 
					
						
							|  |  |  | 	DeleteTokenTimeout          time.Duration | 
					
						
							|  |  |  | 	TokenExpiresAfter           time.Duration | 
					
						
							| 
									
										
										
										
											2024-07-25 17:44:49 +08:00
										 |  |  | 	FeedbackURL                 string | 
					
						
							| 
									
										
										
										
											2024-08-02 17:46:41 +08:00
										 |  |  | 	FrontendPollInterval        time.Duration | 
					
						
							| 
									
										
										
										
											2024-04-21 11:51:58 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	IsDeveloperMode bool | 
					
						
							| 
									
										
										
										
											2024-03-25 23:43:28 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (cfg *Cfg) readCloudMigrationSettings() { | 
					
						
							|  |  |  | 	cloudMigration := cfg.Raw.Section("cloud_migration") | 
					
						
							|  |  |  | 	cfg.CloudMigration.IsTarget = cloudMigration.Key("is_target").MustBool(false) | 
					
						
							|  |  |  | 	cfg.CloudMigration.GcomAPIToken = cloudMigration.Key("gcom_api_token").MustString("") | 
					
						
							| 
									
										
										
										
											2024-11-22 02:46:06 +08:00
										 |  |  | 	cfg.CloudMigration.AuthAPIUrl = cloudMigration.Key("auth_api_url").MustString("") | 
					
						
							| 
									
										
										
										
											2024-07-03 21:38:26 +08:00
										 |  |  | 	cfg.CloudMigration.SnapshotFolder = cloudMigration.Key("snapshot_folder").MustString("") | 
					
						
							| 
									
										
										
										
											2024-07-15 21:22:57 +08:00
										 |  |  | 	cfg.CloudMigration.GMSDomain = cloudMigration.Key("domain").MustString("") | 
					
						
							|  |  |  | 	cfg.CloudMigration.GMSValidateKeyTimeout = cloudMigration.Key("validate_key_timeout").MustDuration(5 * time.Second) | 
					
						
							|  |  |  | 	cfg.CloudMigration.GMSStartSnapshotTimeout = cloudMigration.Key("start_snapshot_timeout").MustDuration(5 * time.Second) | 
					
						
							|  |  |  | 	cfg.CloudMigration.GMSGetSnapshotStatusTimeout = cloudMigration.Key("get_snapshot_status_timeout").MustDuration(5 * time.Second) | 
					
						
							| 
									
										
										
										
											2024-07-17 23:53:21 +08:00
										 |  |  | 	cfg.CloudMigration.GMSCreateUploadUrlTimeout = cloudMigration.Key("create_upload_url_timeout").MustDuration(5 * time.Second) | 
					
						
							| 
									
										
										
										
											2024-07-20 12:02:31 +08:00
										 |  |  | 	cfg.CloudMigration.GMSReportEventTimeout = cloudMigration.Key("report_event_timeout").MustDuration(5 * time.Second) | 
					
						
							| 
									
										
										
										
											2024-03-25 23:43:28 +08:00
										 |  |  | 	cfg.CloudMigration.FetchInstanceTimeout = cloudMigration.Key("fetch_instance_timeout").MustDuration(5 * time.Second) | 
					
						
							|  |  |  | 	cfg.CloudMigration.CreateAccessPolicyTimeout = cloudMigration.Key("create_access_policy_timeout").MustDuration(5 * time.Second) | 
					
						
							|  |  |  | 	cfg.CloudMigration.FetchAccessPolicyTimeout = cloudMigration.Key("fetch_access_policy_timeout").MustDuration(5 * time.Second) | 
					
						
							|  |  |  | 	cfg.CloudMigration.DeleteAccessPolicyTimeout = cloudMigration.Key("delete_access_policy_timeout").MustDuration(5 * time.Second) | 
					
						
							| 
									
										
										
										
											2024-05-31 20:39:10 +08:00
										 |  |  | 	cfg.CloudMigration.ListTokensTimeout = cloudMigration.Key("list_tokens_timeout").MustDuration(5 * time.Second) | 
					
						
							| 
									
										
										
										
											2024-03-25 23:43:28 +08:00
										 |  |  | 	cfg.CloudMigration.CreateTokenTimeout = cloudMigration.Key("create_token_timeout").MustDuration(5 * time.Second) | 
					
						
							| 
									
										
										
										
											2024-05-31 21:03:43 +08:00
										 |  |  | 	cfg.CloudMigration.DeleteTokenTimeout = cloudMigration.Key("delete_token_timeout").MustDuration(5 * time.Second) | 
					
						
							| 
									
										
										
										
											2024-03-25 23:43:28 +08:00
										 |  |  | 	cfg.CloudMigration.TokenExpiresAfter = cloudMigration.Key("token_expires_after").MustDuration(7 * 24 * time.Hour) | 
					
						
							| 
									
										
										
										
											2024-04-21 11:51:58 +08:00
										 |  |  | 	cfg.CloudMigration.IsDeveloperMode = cloudMigration.Key("developer_mode").MustBool(false) | 
					
						
							| 
									
										
										
										
											2024-07-25 17:44:49 +08:00
										 |  |  | 	cfg.CloudMigration.FeedbackURL = cloudMigration.Key("feedback_url").MustString("") | 
					
						
							| 
									
										
										
										
											2024-08-02 17:46:41 +08:00
										 |  |  | 	cfg.CloudMigration.FrontendPollInterval = cloudMigration.Key("frontend_poll_interval").MustDuration(2 * time.Second) | 
					
						
							| 
									
										
										
										
											2024-07-03 21:38:26 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	if cfg.CloudMigration.SnapshotFolder == "" { | 
					
						
							| 
									
										
										
										
											2024-07-30 02:00:43 +08:00
										 |  |  | 		cfg.CloudMigration.SnapshotFolder = filepath.Join(cfg.DataPath, "cloud_migration") | 
					
						
							| 
									
										
										
										
											2024-07-03 21:38:26 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2024-03-25 23:43:28 +08:00
										 |  |  | } |