summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2022-08-24 19:42:08 +0200
committerMiloslav Trmač <mitr@redhat.com>2022-08-25 01:50:43 +0200
commit9828bc44534d6527d44351470d5f943281b7dfba (patch)
treec4ca168150cfd1f6b6ea0b238e331b8265bc70ed /pkg
parente2d1bdd1d8c10617818e5805330c54523580b647 (diff)
downloadpodman-9828bc44534d6527d44351470d5f943281b7dfba.tar.gz
podman-9828bc44534d6527d44351470d5f943281b7dfba.tar.bz2
podman-9828bc44534d6527d44351470d5f943281b7dfba.zip
Create new policy entries together with validating input
That way, we don't have to switch over trustType twice. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/trust/policy.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/pkg/trust/policy.go b/pkg/trust/policy.go
index df4f49ff1..77e02a05c 100644
--- a/pkg/trust/policy.go
+++ b/pkg/trust/policy.go
@@ -151,11 +151,15 @@ func AddPolicyEntries(policyPath string, input AddPolicyEntriesInput) error {
if len(pubkeysfile) != 0 {
return fmt.Errorf("%d public keys unexpectedly provided for trust type %v", len(pubkeysfile), input.Type)
}
+ newReposContent = append(newReposContent, RepoContent{Type: trustType})
case "signedBy":
if len(pubkeysfile) == 0 {
return errors.New("at least one public key must be defined for type 'signedBy'")
}
+ for _, filepath := range pubkeysfile {
+ newReposContent = append(newReposContent, RepoContent{Type: trustType, KeyType: "GPGKeys", KeyPath: filepath})
+ }
default:
return fmt.Errorf("unknown trust type %q", input.Type)
@@ -171,13 +175,6 @@ func AddPolicyEntries(policyPath string, input AddPolicyEntriesInput) error {
return errors.New("could not read trust policies")
}
}
- if len(pubkeysfile) != 0 {
- for _, filepath := range pubkeysfile {
- newReposContent = append(newReposContent, RepoContent{Type: trustType, KeyType: "GPGKeys", KeyPath: filepath})
- }
- } else {
- newReposContent = append(newReposContent, RepoContent{Type: trustType})
- }
if input.Scope == "default" {
policyContentStruct.Default = newReposContent
} else {