mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 10:55:05 +00:00
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package imageverifierfunctions
|
|
|
|
import (
|
|
"github.com/kyverno/kyverno/api/policies.kyverno.io/v1alpha1"
|
|
"github.com/kyverno/kyverno/pkg/imageverification/imagedataloader"
|
|
)
|
|
|
|
func attestorMap(ivpol *v1alpha1.ImageVerificationPolicy) map[string]v1alpha1.Attestor {
|
|
if ivpol == nil {
|
|
return nil
|
|
}
|
|
|
|
return arrToMap(ivpol.Spec.Attestors)
|
|
}
|
|
|
|
func attestationMap(ivpol *v1alpha1.ImageVerificationPolicy) map[string]v1alpha1.Attestation {
|
|
if ivpol == nil {
|
|
return nil
|
|
}
|
|
|
|
return arrToMap(ivpol.Spec.Attestations)
|
|
}
|
|
|
|
type ARR_TYPE interface {
|
|
GetKey() string
|
|
}
|
|
|
|
func arrToMap[T ARR_TYPE](arr []T) map[string]T {
|
|
m := make(map[string]T)
|
|
for _, v := range arr {
|
|
m[v.GetKey()] = v
|
|
}
|
|
|
|
return m
|
|
}
|
|
|
|
func GetRemoteOptsFromPolicy(creds *v1alpha1.Credentials) []imagedataloader.Option {
|
|
if creds == nil {
|
|
return []imagedataloader.Option{}
|
|
}
|
|
|
|
providers := make([]string, 0, len(creds.Providers))
|
|
if len(creds.Providers) != 0 {
|
|
for _, v := range creds.Providers {
|
|
providers = append(providers, string(v))
|
|
}
|
|
}
|
|
|
|
return imagedataloader.BuildRemoteOpts(creds.Secrets, providers, creds.AllowInsecureRegistry)
|
|
}
|