Prefer RUNFILES_DIR if it is set

Signed-off-by: James Munnelly <jmunnelly@apple.com>
This commit is contained in:
James Munnelly
2022-01-06 16:50:44 +00:00
parent 8ff84e8b70
commit 29f793aca8
+6 -8
View File
@@ -41,17 +41,15 @@ func PathForCRD(t *testing.T, name string) string {
}
func CRDDirectory(t *testing.T) string {
runfiles := os.Getenv("RUNFILES_DIR")
bazelDir := BazelBinDir
if runfiles == "" && bazelDir == "" {
t.Fatalf("integration tests can only run within 'bazel test' environment or have BAZEL_BIN_DIR set")
}
var path string
if bazelDir != "" {
path = filepath.Join(bazelDir, "deploy", "crds")
} else {
path := filepath.Join(bazelDir, "deploy", "crds")
// prefer RUNFILES_DIR if set
runfiles := os.Getenv("RUNFILES_DIR")
if runfiles != "" {
path = filepath.Join(runfiles, "com_github_jetstack_cert_manager", "deploy", "crds")
}
info, err := os.Stat(path)
if err != nil {
t.Fatal(err)