|
|
|
@ -30,7 +30,6 @@ type ConfigProvider interface { |
|
|
|
|
Section(section string) ConfigSection |
|
|
|
|
NewSection(name string) (ConfigSection, error) |
|
|
|
|
GetSection(name string) (ConfigSection, error) |
|
|
|
|
DeleteSection(name string) error |
|
|
|
|
Save() error |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -40,12 +39,6 @@ type iniFileConfigProvider struct { |
|
|
|
|
newFile bool // whether the file has not existed previously
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// NewEmptyConfigProvider create a new empty config provider
|
|
|
|
|
func NewEmptyConfigProvider() ConfigProvider { |
|
|
|
|
cp, _ := NewConfigProviderFromData("") |
|
|
|
|
return cp |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// NewConfigProviderFromData this function is only for testing
|
|
|
|
|
func NewConfigProviderFromData(configContent string) (ConfigProvider, error) { |
|
|
|
|
var cfg *ini.File |
|
|
|
@ -121,11 +114,6 @@ func (p *iniFileConfigProvider) GetSection(name string) (ConfigSection, error) { |
|
|
|
|
return p.File.GetSection(name) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (p *iniFileConfigProvider) DeleteSection(name string) error { |
|
|
|
|
p.File.DeleteSection(name) |
|
|
|
|
return nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Save save the content into file
|
|
|
|
|
func (p *iniFileConfigProvider) Save() error { |
|
|
|
|
if p.opts.CustomConf == "" { |
|
|
|
|