| 
									
										
										
										
											2023-07-25 04:12:59 +08:00
										 |  |  | package setting | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import ( | 
					
						
							|  |  |  | 	"github.com/grafana/grafana/pkg/util" | 
					
						
							|  |  |  | ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | type FeatureMgmtSettings struct { | 
					
						
							| 
									
										
										
										
											2023-09-26 02:11:24 +08:00
										 |  |  | 	HiddenToggles      map[string]struct{} | 
					
						
							|  |  |  | 	ReadOnlyToggles    map[string]struct{} | 
					
						
							|  |  |  | 	AllowEditing       bool | 
					
						
							|  |  |  | 	UpdateWebhook      string | 
					
						
							|  |  |  | 	UpdateWebhookToken string | 
					
						
							| 
									
										
										
										
											2023-07-25 04:12:59 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func (cfg *Cfg) readFeatureManagementConfig() { | 
					
						
							|  |  |  | 	section := cfg.Raw.Section("feature_management") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	hiddenToggles := make(map[string]struct{}) | 
					
						
							|  |  |  | 	readOnlyToggles := make(map[string]struct{}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// parse the comma separated list in `hidden_toggles`.
 | 
					
						
							|  |  |  | 	hiddenTogglesStr := valueAsString(section, "hidden_toggles", "") | 
					
						
							|  |  |  | 	for _, feature := range util.SplitString(hiddenTogglesStr) { | 
					
						
							|  |  |  | 		hiddenToggles[feature] = struct{}{} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// parse the comma separated list in `read_only_toggles`.
 | 
					
						
							|  |  |  | 	readOnlyTogglesStr := valueAsString(section, "read_only_toggles", "") | 
					
						
							|  |  |  | 	for _, feature := range util.SplitString(readOnlyTogglesStr) { | 
					
						
							|  |  |  | 		readOnlyToggles[feature] = struct{}{} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	cfg.FeatureManagement.HiddenToggles = hiddenToggles | 
					
						
							|  |  |  | 	cfg.FeatureManagement.ReadOnlyToggles = readOnlyToggles | 
					
						
							| 
									
										
										
										
											2023-08-09 23:32:28 +08:00
										 |  |  | 	cfg.FeatureManagement.AllowEditing = cfg.SectionWithEnvOverrides("feature_management").Key("allow_editing").MustBool(false) | 
					
						
							| 
									
										
										
										
											2023-09-26 02:11:24 +08:00
										 |  |  | 	cfg.FeatureManagement.UpdateWebhook = cfg.SectionWithEnvOverrides("feature_management").Key("update_webhook").MustString("") | 
					
						
							|  |  |  | 	cfg.FeatureManagement.UpdateWebhookToken = cfg.SectionWithEnvOverrides("feature_management").Key("update_webhook_token").MustString("") | 
					
						
							| 
									
										
										
										
											2023-07-25 04:12:59 +08:00
										 |  |  | } |