mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
6d48a185d1
* skip invalid policy files Signed-off-by: Jim Bugwadia <jim@nirmata.com> * fix file-system policy loader Signed-off-by: Jim Bugwadia <jim@nirmata.com> * propagate policy schema error Signed-off-by: Jim Bugwadia <jim@nirmata.com> --------- Signed-off-by: Jim Bugwadia <jim@nirmata.com>
23 lines
744 B
Go
23 lines
744 B
Go
package test
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/go-git/go-billy/v5"
|
|
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/resource"
|
|
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
|
)
|
|
|
|
func getAndCompareResource(actualResource unstructured.Unstructured, fs billy.Filesystem, path string) (bool, error) {
|
|
expectedResource, err := resource.GetResourceFromPath(fs, path)
|
|
if err != nil {
|
|
return false, fmt.Errorf("error: failed to load resource (%s)", err)
|
|
}
|
|
resource.FixupGenerateLabels(actualResource)
|
|
resource.FixupGenerateLabels(*expectedResource)
|
|
equals, err := resource.Compare(actualResource, *expectedResource, true)
|
|
if err != nil {
|
|
return false, fmt.Errorf("error: failed to compare resources (%s)", err)
|
|
}
|
|
return equals, nil
|
|
}
|