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:
parent
919d849123
commit
d06a39bd51
2 changed files with 23 additions and 18 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -210,24 +210,7 @@ func (api *API) sourceInfoHandler(writer http.ResponseWriter, request *http.Requ
|
|||
}
|
||||
// check if the source is in the base repo
|
||||
if name == api.repo.Id || name == "*" {
|
||||
cfg := store.SourceConfig{
|
||||
Name: api.repo.Id,
|
||||
CheckGPG: true,
|
||||
CheckSSL: true,
|
||||
System: true,
|
||||
}
|
||||
|
||||
if api.repo.BaseURL != "" {
|
||||
cfg.URL = api.repo.BaseURL
|
||||
cfg.Type = "yum-baseurl"
|
||||
} else if api.repo.Metalink != "" {
|
||||
cfg.URL = api.repo.Metalink
|
||||
cfg.Type = "yum-metalink"
|
||||
} else if api.repo.MirrorList != "" {
|
||||
cfg.URL = api.repo.MirrorList
|
||||
cfg.Type = "yum-mirrorlist"
|
||||
}
|
||||
sources[cfg.Name] = cfg
|
||||
sources[api.repo.Id] = store.NewSourceConfig(api.repo, true)
|
||||
// check if the source is in the store
|
||||
} else if source := api.store.GetSource(name); source != nil {
|
||||
sources[source.Name] = *source
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue