Reorganize the types in policy.go a bit

... to go from top to bottom.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač
2022-08-25 01:11:07 +02:00
parent a7e88c8dac
commit ad0c785f8e

View File

@ -23,6 +23,12 @@ type policyContent struct {
Transports transportsContent `json:"transports,omitempty"` Transports transportsContent `json:"transports,omitempty"`
} }
// transportsContent contains policies for individual transports (= c/image/v5/signature.Policy.Transports)
type transportsContent map[string]repoMap
// repoMap maps a scope name to requirements that apply to that scope (= c/image/v5/signature.PolicyTransportScopes)
type repoMap map[string][]repoContent
// repoContent is a single policy requirement (one of possibly several for a scope), representing all of the individual alternatives in a single merged struct // repoContent is a single policy requirement (one of possibly several for a scope), representing all of the individual alternatives in a single merged struct
// (= c/image/v5/signature.{PolicyRequirement,pr*}) // (= c/image/v5/signature.{PolicyRequirement,pr*})
type repoContent struct { type repoContent struct {
@ -34,12 +40,6 @@ type repoContent struct {
SignedIdentity json.RawMessage `json:"signedIdentity,omitempty"` SignedIdentity json.RawMessage `json:"signedIdentity,omitempty"`
} }
// repoMap maps a scope name to requirements that apply to that scope (= c/image/v5/signature.PolicyTransportScopes)
type repoMap map[string][]repoContent
// transportsContent contains policies for individual transports (= c/image/v5/signature.Policy.Transports)
type transportsContent map[string]repoMap
// DefaultPolicyPath returns a path to the default policy of the system. // DefaultPolicyPath returns a path to the default policy of the system.
func DefaultPolicyPath(sys *types.SystemContext) string { func DefaultPolicyPath(sys *types.SystemContext) string {
systemDefaultPolicyPath := "/etc/containers/policy.json" systemDefaultPolicyPath := "/etc/containers/policy.json"