rpmmd/RepoConf: rename Id to Name

This is how it is used in the rest of the code, as a name to represent
the repository in the weldr API. Rename to match its use, and avoid
confusion with the ID passed to dnf-json, which is not the same.

Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
Tom Gundersen 2020-05-26 11:38:37 +02:00
parent 00483101c6
commit 48079b3a4d
9 changed files with 14 additions and 14 deletions

View file

@ -30,7 +30,7 @@ func TestFetchChecksum(t *testing.T) {
assert.Nilf(t, err, "Failed to set up temporary repository: %v", err)
repoCfg := rpmmd.RepoConfig{
Id: "repo",
Name: "repo",
BaseURL: fmt.Sprintf("file://%s", dir),
IgnoreSSL: true,
}

View file

@ -104,7 +104,7 @@ func main() {
repos := make([]rpmmd.RepoConfig, len(composeRequest.Repositories))
for i, repo := range composeRequest.Repositories {
repos[i] = rpmmd.RepoConfig{
Id: fmt.Sprintf("repo-%d", i),
Name: fmt.Sprintf("repo-%d", i),
BaseURL: repo.BaseURL,
Metalink: repo.Metalink,
MirrorList: repo.MirrorList,

View file

@ -44,7 +44,7 @@ func executeTests(m *testing.M) int {
if err != nil {
panic(err)
}
repos := []rpmmd.RepoConfig{{Id: "test-system-repo", BaseURL: "http://example.com/test/os/test_arch"}}
repos := []rpmmd.RepoConfig{{Name: "test-system-repo", BaseURL: "http://example.com/test/os/test_arch"}}
logger := log.New(os.Stdout, "", 0)
api := weldr.New(rpm, arch, distro, repos, logger, fixture.Store, fixture.Workers, "")
server := http.Server{Handler: api}

View file

@ -56,7 +56,7 @@ func TestDistro_Manifest(t *testing.T, pipelinePath string, prefix string, distr
repos := make([]rpmmd.RepoConfig, len(tt.ComposeRequest.Repositories))
for i, repo := range tt.ComposeRequest.Repositories {
repos[i] = rpmmd.RepoConfig{
Id: fmt.Sprintf("repo-%d", i),
Name: fmt.Sprintf("repo-%d", i),
BaseURL: repo.BaseURL,
Metalink: repo.Metalink,
MirrorList: repo.MirrorList,

View file

@ -185,7 +185,7 @@ func (api *API) submit(writer http.ResponseWriter, request *http.Request, _ http
repoConfigs := []rpmmd.RepoConfig{}
for n, repo := range buildRequest.Repositories {
repoConfigs = append(repoConfigs, rpmmd.RepoConfig{
Id: fmt.Sprintf("repo-%d", n),
Name: fmt.Sprintf("repo-%d", n),
BaseURL: repo.BaseURL,
Metalink: repo.Metalink,
MirrorList: repo.MirrorList,

View file

@ -38,7 +38,7 @@ type dnfRepoConfig struct {
}
type RepoConfig struct {
Id string
Name string
BaseURL string
Metalink string
MirrorList string
@ -210,7 +210,7 @@ func LoadRepositories(confPaths []string, distro string) (map[string][]RepoConfi
for arch, repos := range reposMap {
for _, repo := range repos {
config := RepoConfig{
Id: repo.Id,
Name: repo.Id,
BaseURL: repo.BaseURL,
Metalink: repo.Metalink,
MirrorList: repo.MirrorList,

View file

@ -462,7 +462,7 @@ func (s *Store) GetAllSources() map[string]SourceConfig {
func NewSourceConfig(repo rpmmd.RepoConfig, system bool) SourceConfig {
sc := SourceConfig{
Name: repo.Id,
Name: repo.Name,
CheckGPG: true,
CheckSSL: !repo.IgnoreSSL,
System: system,
@ -485,7 +485,7 @@ func NewSourceConfig(repo rpmmd.RepoConfig, system bool) SourceConfig {
func (s *SourceConfig) RepoConfig() rpmmd.RepoConfig {
var repo rpmmd.RepoConfig
repo.Id = s.Name
repo.Name = s.Name
repo.IgnoreSSL = !s.CheckSSL
if s.Type == "yum-baseurl" {

View file

@ -349,7 +349,7 @@ func (api *API) sourceListHandler(writer http.ResponseWriter, request *http.Requ
names := api.store.ListSources()
for _, repo := range api.repos {
names = append(names, repo.Id)
names = append(names, repo.Name)
}
err := json.NewEncoder(writer).Encode(reply{
@ -392,15 +392,15 @@ func (api *API) sourceInfoHandler(writer http.ResponseWriter, request *http.Requ
if names == "*" {
sources = api.store.GetAllSources()
for _, repo := range api.repos {
sources[repo.Id] = store.NewSourceConfig(repo, true)
sources[repo.Name] = store.NewSourceConfig(repo, true)
}
} else {
for _, name := range strings.Split(names, ",") {
// check if the source is one of the base repos
found := false
for _, repo := range api.repos {
if name == repo.Id {
sources[repo.Id] = store.NewSourceConfig(repo, true)
if name == repo.Name {
sources[repo.Name] = store.NewSourceConfig(repo, true)
found = true
break
}

View file

@ -30,7 +30,7 @@ import (
func createWeldrAPI(fixtureGenerator rpmmd_mock.FixtureGenerator) (*API, *store.Store) {
fixture := fixtureGenerator()
rpm := rpmmd_mock.NewRPMMDMock(fixture)
repos := []rpmmd.RepoConfig{{Id: "test-id", BaseURL: "http://example.com/test/os/x86_64"}}
repos := []rpmmd.RepoConfig{{Name: "test-id", BaseURL: "http://example.com/test/os/x86_64"}}
d := test_distro.New()
arch, err := d.GetArch("x86_64")
if err != nil {