mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Intorduce "config edit-ini" sub command to help maintaining INI config file (#35735)
Ref: #32669. Helps addressing https://gitea.com/gitea/helm-chart/issues/356.
This commit is contained in:
		| @@ -41,6 +41,7 @@ type ConfigSection interface { | ||||
| 	HasKey(key string) bool | ||||
| 	NewKey(name, value string) (ConfigKey, error) | ||||
| 	Key(key string) ConfigKey | ||||
| 	DeleteKey(key string) | ||||
| 	Keys() []ConfigKey | ||||
| 	ChildSections() []ConfigSection | ||||
| } | ||||
| @@ -51,6 +52,7 @@ type ConfigProvider interface { | ||||
| 	Sections() []ConfigSection | ||||
| 	NewSection(name string) (ConfigSection, error) | ||||
| 	GetSection(name string) (ConfigSection, error) | ||||
| 	DeleteSection(name string) | ||||
| 	Save() error | ||||
| 	SaveTo(filename string) error | ||||
|  | ||||
| @@ -168,6 +170,10 @@ func (s *iniConfigSection) Keys() (keys []ConfigKey) { | ||||
| 	return keys | ||||
| } | ||||
|  | ||||
| func (s *iniConfigSection) DeleteKey(key string) { | ||||
| 	s.sec.DeleteKey(key) | ||||
| } | ||||
|  | ||||
| func (s *iniConfigSection) ChildSections() (sections []ConfigSection) { | ||||
| 	for _, s := range s.sec.ChildSections() { | ||||
| 		sections = append(sections, &iniConfigSection{s}) | ||||
| @@ -249,6 +255,10 @@ func (p *iniConfigProvider) GetSection(name string) (ConfigSection, error) { | ||||
| 	return &iniConfigSection{sec: sec}, nil | ||||
| } | ||||
|  | ||||
| func (p *iniConfigProvider) DeleteSection(name string) { | ||||
| 	p.ini.DeleteSection(name) | ||||
| } | ||||
|  | ||||
| var errDisableSaving = errors.New("this config can't be saved, developers should prepare a new config to save") | ||||
|  | ||||
| // Save saves the content into file | ||||
|   | ||||
		Reference in New Issue
	
	Block a user