diff options
Diffstat (limited to 'libpod/util.go')
-rw-r--r-- | libpod/util.go | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libpod/util.go b/libpod/util.go index c8cbfa2fc..61089b525 100644 --- a/libpod/util.go +++ b/libpod/util.go @@ -6,6 +6,9 @@ import ( "path/filepath" "strings" "time" + + "github.com/containers/image/signature" + "github.com/containers/image/types" ) // Runtime API constants @@ -55,3 +58,21 @@ func FuncTimer(funcName string) { func hasTransport(image string) bool { return strings.Contains(image, "://") } + +// CopyStringStringMap deep copies a map[string]string and returns the result +func CopyStringStringMap(m map[string]string) map[string]string { + n := map[string]string{} + for k, v := range m { + n[k] = v + } + return n +} + +// GetPolicyContext creates a signature policy context for the given signature policy path +func GetPolicyContext(path string) (*signature.PolicyContext, error) { + policy, err := signature.DefaultPolicy(&types.SystemContext{SignaturePolicyPath: path}) + if err != nil { + return nil, err + } + return signature.NewPolicyContext(policy) +} |