Use psaapi.LatestVersion instead of parse

This commit is contained in:
Sam Stoelinga 2022-07-22 06:40:25 -07:00
parent ae697cd9c8
commit 66c65322a6

View File

@ -36,13 +36,9 @@ func init() {
}
func SuggestedPodSecurityStandard(pod *v1.Pod) (psaapi.Level, error) {
apiVersion, err := psaapi.ParseVersion("latest")
if err != nil {
return "", err
}
for _, apiLevel := range []psaapi.Level{psaapi.LevelRestricted, psaapi.LevelBaseline} {
result := policy.AggregateCheckResults(evaluator.EvaluatePod(
psaapi.LevelVersion{Level: apiLevel, Version: apiVersion}, &pod.ObjectMeta, &pod.Spec))
psaapi.LevelVersion{Level: apiLevel, Version: psaapi.LatestVersion()}, &pod.ObjectMeta, &pod.Spec))
if result.Allowed {
return apiLevel, nil