Define default values for loaded repositories

This commit is contained in:
Daniele Rondina
2020-01-03 19:37:51 +01:00
parent 7ec36da059
commit 6af62b5851
2 changed files with 14 additions and 1 deletions

View File

@@ -74,6 +74,19 @@ func NewLuetRepository(name, t, descr string, urls []string, priority int, enabl
}
}
func NewEmptyLuetRepository() *LuetRepository {
return &LuetRepository{
Name: "",
Description: "",
Urls: []string{},
Type: "",
Priority: 9999,
TreePath: "",
Enable: false,
Authentication: make(map[string]string, 0),
}
}
func (r *LuetRepository) String() string {
return fmt.Sprintf("[%s] prio: %d, type: %s, enable: %t", r.Name, r.Priority, r.Type, r.Enable)
}

View File

@@ -76,7 +76,7 @@ func LoadRepositories(c *LuetConfig) error {
}
func LoadRepository(data []byte) (*LuetRepository, error) {
ans := &LuetRepository{Enable: false}
ans := NewEmptyLuetRepository()
err := yaml.Unmarshal(data, &ans)
if err != nil {
return nil, err