1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-07 00:17:13 +00:00
kyverno/cmd/cli/kubectl-kyverno/deprecations/check.go
Mariam Fahmy f36d5410ea
fix: check the patchedResources in kyverno-test (#11686)
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
2024-12-02 12:59:12 +00:00

52 lines
1.5 KiB
Go

package deprecations
import (
"fmt"
"io"
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/apis/v1alpha1"
)
func CheckUserInfo(out io.Writer, path string, resource *v1alpha1.UserInfo) bool {
if resource != nil {
if resource.APIVersion == "" || resource.Kind == "" {
if out != nil {
fmt.Fprintf(out, "\nWARNING: user infos file (%s) uses a deprecated schema that will be removed in 1.13\n", path)
}
return true
}
}
return false
}
func CheckValues(out io.Writer, path string, resource *v1alpha1.Values) bool {
if resource != nil {
if resource.APIVersion == "" || resource.Kind == "" {
if out != nil {
fmt.Fprintf(out, "\nWARNING: values file (%s) uses a deprecated schema that will be removed in 1.13\n", path)
}
return true
}
}
return false
}
func CheckTest(out io.Writer, path string, resource *v1alpha1.Test) bool {
if resource != nil {
if resource.APIVersion == "" || resource.Kind == "" || resource.Name != "" {
if out != nil {
fmt.Fprintf(out, "\nWARNING: test file (%s) uses a deprecated schema that will be removed in 1.14\n", path)
}
return true
}
for _, result := range resource.Results {
if result.TestResultDeprecated.Status != "" || result.TestResultDeprecated.Namespace != "" || result.TestResultDeprecated.Resource != "" || result.TestResultDeprecated.PatchedResource != "" {
if out != nil {
fmt.Fprintf(out, "\nWARNING: test file (%s) uses a deprecated schema that will be removed in 1.14\n", path)
}
return true
}
}
}
return false
}