Change RepoConfig.GPGKey to an array of key strings

DNF supports more than one GPG key. It is possible that one may be used for
signing packages, and another to sign the repository metadata. This
renamed GPGKey to GPGKeys internally. It does not change the on-disk
repository json format.
This commit is contained in:
Brian C. Lane 2023-01-20 10:54:28 -08:00 committed by Sanne Raymaekers
parent a47375a10d
commit d12447408b
12 changed files with 114 additions and 63 deletions

View file

@ -1255,14 +1255,14 @@ func genRepoConfig(repo Repository) (*rpmmd.RepoConfig, error) {
if repo.CheckGpg != nil {
repoConfig.CheckGPG = *repo.CheckGpg
}
if repo.Gpgkey != nil {
repoConfig.GPGKey = *repo.Gpgkey
if repo.Gpgkey != nil && *repo.Gpgkey != "" {
repoConfig.GPGKeys = []string{*repo.Gpgkey}
}
if repo.IgnoreSsl != nil {
repoConfig.IgnoreSSL = *repo.IgnoreSsl
}
if repoConfig.CheckGPG && repoConfig.GPGKey == "" {
if repoConfig.CheckGPG && len(repoConfig.GPGKeys) == 0 {
return nil, HTTPError(ErrorNoGPGKey)
}

View file

@ -107,7 +107,7 @@ func TestRepoConfigConversion(t *testing.T) {
BaseURL: "http://base.url",
Metalink: "",
MirrorList: "",
GPGKey: "some-kind-of-key",
GPGKeys: []string{"some-kind-of-key"},
CheckGPG: true,
IgnoreSSL: false,
MetadataExpire: "",
@ -131,7 +131,6 @@ func TestRepoConfigConversion(t *testing.T) {
BaseURL: "http://base.url",
Metalink: "", // since BaseURL is specified, MetaLink is not copied
MirrorList: "", // since BaseURL is specified, MirrorList is not copied
GPGKey: "",
CheckGPG: false,
IgnoreSSL: true,
MetadataExpire: "",
@ -155,7 +154,6 @@ func TestRepoConfigConversion(t *testing.T) {
BaseURL: "",
Metalink: "", // since MirrorList is specified, MetaLink is not copied
MirrorList: "http://example.org/mirrorlist",
GPGKey: "",
CheckGPG: false,
IgnoreSSL: true,
MetadataExpire: "",
@ -179,7 +177,6 @@ func TestRepoConfigConversion(t *testing.T) {
BaseURL: "",
Metalink: "http://example.org/metalink",
MirrorList: "",
GPGKey: "",
CheckGPG: false,
IgnoreSSL: true,
MetadataExpire: "",