mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-06 16:06:56 +00:00
* refactor: introduce userinfo package in the cli Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * refactor: introduce api package in cli Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * refactor: combine unstructured and resource packages Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> * fix Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com> --------- Signed-off-by: Charles-Edouard Brétéché <charles.edouard@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
|
|
}
|