Skip to content

Commit e3636b4

Browse files
authored
Prepare ProjectBaseDir. (#8084)
1 parent 33ef84b commit e3636b4

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

test/integration/framework/framework.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (f *Framework) Init() *rest.Config {
8484

8585
var cfg *rest.Config
8686
ginkgo.By("bootstrapping test environment", func() {
87-
baseCrdPath := filepath.Join(util.GetProjectBaseDir(), "config", "components", "crd", "_output")
87+
baseCrdPath := filepath.Join(util.ProjectBaseDir, "config", "components", "crd", "_output")
8888
f.testEnv = &envtest.Environment{
8989
CRDDirectoryPaths: append(f.DepCRDPaths, baseCrdPath),
9090
ErrorIfCRDPathMissing: true,

test/util/constants.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,17 @@ var (
5858
)
5959

6060
var (
61-
AutoscalerCrds = filepath.Join(GetProjectBaseDir(), "dep-crds", "cluster-autoscaler")
62-
JobsetCrds = filepath.Join(GetProjectBaseDir(), "dep-crds", "jobset-operator")
63-
TrainingOperatorCrds = filepath.Join(GetProjectBaseDir(), "dep-crds", "training-operator-crds")
64-
KfTrainerCrds = filepath.Join(GetProjectBaseDir(), "dep-crds", "kf-trainer-crds")
65-
KfTrainerClusterRuntimes = filepath.Join(GetProjectBaseDir(), "dep-crds", "kf-trainer-runtimes")
66-
MpiOperatorCrds = filepath.Join(GetProjectBaseDir(), "dep-crds", "mpi-operator")
67-
AppWrapperCrds = filepath.Join(GetProjectBaseDir(), "dep-crds", "appwrapper-crds")
68-
RayOperatorCrds = filepath.Join(GetProjectBaseDir(), "dep-crds", "ray-operator-crds")
69-
WebhookPath = filepath.Join(GetProjectBaseDir(), "config", "components", "webhook")
70-
ClusterProfileCrds = filepath.Join(GetProjectBaseDir(), "dep-crds", "clusterprofile")
61+
ProjectBaseDir = getProjectBaseDir()
62+
AutoscalerCrds = filepath.Join(ProjectBaseDir, "dep-crds", "cluster-autoscaler")
63+
JobsetCrds = filepath.Join(ProjectBaseDir, "dep-crds", "jobset-operator")
64+
TrainingOperatorCrds = filepath.Join(ProjectBaseDir, "dep-crds", "training-operator-crds")
65+
KfTrainerCrds = filepath.Join(ProjectBaseDir, "dep-crds", "kf-trainer-crds")
66+
KfTrainerClusterRuntimes = filepath.Join(ProjectBaseDir, "dep-crds", "kf-trainer-runtimes")
67+
MpiOperatorCrds = filepath.Join(ProjectBaseDir, "dep-crds", "mpi-operator")
68+
AppWrapperCrds = filepath.Join(ProjectBaseDir, "dep-crds", "appwrapper-crds")
69+
RayOperatorCrds = filepath.Join(ProjectBaseDir, "dep-crds", "ray-operator-crds")
70+
WebhookPath = filepath.Join(ProjectBaseDir, "config", "components", "webhook")
71+
ClusterProfileCrds = filepath.Join(ProjectBaseDir, "dep-crds", "clusterprofile")
7172
)
7273

7374
var (

test/util/e2e.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func GetAgnHostImage() string {
8686
return image
8787
}
8888

89-
agnhostDockerfilePath := filepath.Join(GetProjectBaseDir(), "hack", "agnhost", "Dockerfile")
89+
agnhostDockerfilePath := filepath.Join(ProjectBaseDir, "hack", "agnhost", "Dockerfile")
9090
agnhostImage, err := getDockerImageFromDockerfile(agnhostDockerfilePath)
9191
if err != nil {
9292
panic(fmt.Errorf("failed to get agnhost image: %v", err))

test/util/util.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,18 +1182,17 @@ func KExecute(ctx context.Context, cfg *rest.Config, client *rest.RESTClient, ns
11821182
return out.Bytes(), outErr.Bytes(), nil
11831183
}
11841184

1185-
// GetProjectBaseDir retrieves the project base directory either from an environment variable or by searching for a Makefile.
1185+
// getProjectBaseDir retrieves the project base directory either from an environment variable or by searching for a Makefile.
11861186
// The fallback to the search is useful for running in IDEs like vs-code which don't set the PROJECT_DIR env. variable by default.
1187-
func GetProjectBaseDir() string {
1187+
func getProjectBaseDir() string {
11881188
projectBasePath, found := os.LookupEnv("PROJECT_DIR")
11891189
if found {
11901190
return filepath.Dir(projectBasePath)
11911191
}
11921192

11931193
projectBaseDir, err := findMakefileDir()
11941194
if err != nil {
1195-
klog.Error(err)
1196-
return ""
1195+
ginkgo.Fail(fmt.Sprintf("Failed to find project base directory: %v", err))
11971196
}
11981197
return projectBaseDir
11991198
}

0 commit comments

Comments
 (0)