mirror of
https://github.com/kyverno/kyverno.git
synced 2025-04-15 00:36:28 +00:00
* feat: add variables Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * feat: implement evaluator Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: build Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: linter Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> * fix: unit tests Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com> --------- Signed-off-by: Vishal Choudhary <vishal.choudhary@nirmata.com>
61 lines
1.3 KiB
Go
61 lines
1.3 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{}
|
|
}
|
|
|
|
opts := make([]imagedataloader.Option, 0)
|
|
|
|
if creds.AllowInsecureRegistry {
|
|
opts = append(opts, imagedataloader.WithInsecure(creds.AllowInsecureRegistry))
|
|
}
|
|
|
|
if len(creds.Providers) != 0 {
|
|
providers := make([]string, 0, len(creds.Providers))
|
|
for _, v := range creds.Providers {
|
|
providers = append(providers, string(v))
|
|
}
|
|
opts = append(opts, imagedataloader.WithCredentialProviders(providers...))
|
|
}
|
|
|
|
if len(creds.Secrets) != 0 {
|
|
opts = append(opts, imagedataloader.WithPullSecret(creds.Secrets))
|
|
}
|
|
|
|
return opts
|
|
}
|