internal/rpmmd: RepoConfig baseurl change
Update the internal RepoConfig object to accept a slice of baseurls rather than a single field. This change was needed to align RepoConfig with the dnf spec [1]. Additionally, this change adds custom json marshal and unmarshal functions to ensure backwards compatibility with older workers. Add json tags to the internal rpmmd config since this is serialized in dnfjson. Add unit tests to check the serialization is okay. [1] See dnf.config
This commit is contained in:
parent
17d730593c
commit
4d42808b6a
23 changed files with 368 additions and 198 deletions
|
|
@ -1352,8 +1352,8 @@ func genRepoConfig(repo Repository) (*rpmmd.RepoConfig, error) {
|
|||
|
||||
repoConfig.RHSM = repo.Rhsm != nil && *repo.Rhsm
|
||||
|
||||
if repo.Baseurl != nil {
|
||||
repoConfig.BaseURL = *repo.Baseurl
|
||||
if repo.Baseurl != nil && *repo.Baseurl != "" {
|
||||
repoConfig.BaseURLs = []string{*repo.Baseurl}
|
||||
} else if repo.Mirrorlist != nil {
|
||||
repoConfig.MirrorList = *repo.Mirrorlist
|
||||
} else if repo.Metalink != nil {
|
||||
|
|
|
|||
|
|
@ -65,13 +65,13 @@ func TestCollectRepos(t *testing.T) {
|
|||
}
|
||||
|
||||
expectedRepos := []rpmmd.RepoConfig{
|
||||
{BaseURL: "http://example.com/baseos", PackageSets: nil},
|
||||
{BaseURL: "http://example.com/appstream", PackageSets: nil},
|
||||
{BaseURL: "http://example.com/baseos-rhel7", PackageSets: []string{"build"}},
|
||||
{BaseURL: "http://example.com/extra-tools", PackageSets: []string{"build", "archive"}},
|
||||
{BaseURL: "http://example.com/custom-os-stuff", PackageSets: []string{"blueprint"}},
|
||||
{BaseURL: "http://example.com/repoone", PackageSets: []string{"blueprint"}},
|
||||
{BaseURL: "http://example.com/repotwo", PackageSets: []string{"blueprint"}},
|
||||
{BaseURLs: []string{"http://example.com/baseos"}, PackageSets: nil},
|
||||
{BaseURLs: []string{"http://example.com/appstream"}, PackageSets: nil},
|
||||
{BaseURLs: []string{"http://example.com/baseos-rhel7"}, PackageSets: []string{"build"}},
|
||||
{BaseURLs: []string{"http://example.com/extra-tools"}, PackageSets: []string{"build", "archive"}},
|
||||
{BaseURLs: []string{"http://example.com/custom-os-stuff"}, PackageSets: []string{"blueprint"}},
|
||||
{BaseURLs: []string{"http://example.com/repoone"}, PackageSets: []string{"blueprint"}},
|
||||
{BaseURLs: []string{"http://example.com/repotwo"}, PackageSets: []string{"blueprint"}},
|
||||
}
|
||||
|
||||
payloadPkgSets := []string{"blueprint"}
|
||||
|
|
@ -104,7 +104,7 @@ func TestRepoConfigConversion(t *testing.T) {
|
|||
},
|
||||
repoConfig: rpmmd.RepoConfig{
|
||||
Name: "",
|
||||
BaseURL: "http://base.url",
|
||||
BaseURLs: []string{"http://base.url"},
|
||||
Metalink: "",
|
||||
MirrorList: "",
|
||||
GPGKeys: []string{"some-kind-of-key"},
|
||||
|
|
@ -128,7 +128,7 @@ func TestRepoConfigConversion(t *testing.T) {
|
|||
},
|
||||
repoConfig: rpmmd.RepoConfig{
|
||||
Name: "",
|
||||
BaseURL: "http://base.url",
|
||||
BaseURLs: []string{"http://base.url"},
|
||||
Metalink: "", // since BaseURL is specified, MetaLink is not copied
|
||||
MirrorList: "", // since BaseURL is specified, MirrorList is not copied
|
||||
CheckGPG: false,
|
||||
|
|
@ -151,7 +151,6 @@ func TestRepoConfigConversion(t *testing.T) {
|
|||
},
|
||||
repoConfig: rpmmd.RepoConfig{
|
||||
Name: "",
|
||||
BaseURL: "",
|
||||
Metalink: "", // since MirrorList is specified, MetaLink is not copied
|
||||
MirrorList: "http://example.org/mirrorlist",
|
||||
CheckGPG: false,
|
||||
|
|
@ -174,7 +173,6 @@ func TestRepoConfigConversion(t *testing.T) {
|
|||
},
|
||||
repoConfig: rpmmd.RepoConfig{
|
||||
Name: "",
|
||||
BaseURL: "",
|
||||
Metalink: "http://example.org/metalink",
|
||||
MirrorList: "",
|
||||
CheckGPG: false,
|
||||
|
|
@ -214,7 +212,6 @@ func TestRepoConfigConversion(t *testing.T) {
|
|||
// check gpg required but no gpgkey given
|
||||
{
|
||||
repo: Repository{
|
||||
Baseurl: nil,
|
||||
CheckGpg: common.ToPtr(true),
|
||||
Gpgkey: nil,
|
||||
IgnoreSsl: common.ToPtr(true),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue