weldr: move RepoConfig → SourceConfig conversion to store

This puts it aside the already existing SourceConfig → RepoConfig
conversion and makes `sourceInfoHandler` a bit easier to parse.
This commit is contained in:
Lars Karlitski 2019-11-17 09:55:46 +00:00 committed by Tom Gundersen
parent 919d849123
commit d06a39bd51
2 changed files with 23 additions and 18 deletions

View file

@ -606,6 +606,28 @@ func (s *Store) GetAllSources() map[string]SourceConfig {
return sources
}
func NewSourceConfig(repo rpmmd.RepoConfig, system bool) SourceConfig {
sc := SourceConfig{
Name: repo.Id,
CheckGPG: true,
CheckSSL: true,
System: system,
}
if repo.BaseURL != "" {
sc.URL = repo.BaseURL
sc.Type = "yum-baseurl"
} else if repo.Metalink != "" {
sc.URL = repo.Metalink
sc.Type = "yum-metalink"
} else if repo.MirrorList != "" {
sc.URL = repo.MirrorList
sc.Type = "yum-mirrorlist"
}
return sc
}
func (s *SourceConfig) RepoConfig() rpmmd.RepoConfig {
var repo rpmmd.RepoConfig