Files
kubesphere/pkg/controller/controllertest/testing.go
KubeSphere CI Bot 447a51f08b feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

* feat: kubesphere 4.0

Signed-off-by: ci-bot <ci-bot@kubesphere.io>

---------

Signed-off-by: ci-bot <ci-bot@kubesphere.io>
Co-authored-by: ks-ci-bot <ks-ci-bot@example.com>
Co-authored-by: joyceliu <joyceliu@yunify.com>
2024-09-06 11:05:52 +08:00

37 lines
855 B
Go

/*
* Please refer to the LICENSE file in the root directory of the project.
* https://github.com/kubesphere/kubesphere/blob/master/LICENSE
*/
package controllertest
import (
"fmt"
"io/fs"
"path/filepath"
"runtime"
)
func LoadCrdPath() ([]string, error) {
_, filename, _, ok := runtime.Caller(0)
if !ok {
return nil, fmt.Errorf("could not determine path")
}
curDir, _ := filepath.Split(filename)
crdDirPaths := make([]string, 0, 1)
projectRoot := filepath.Join(curDir, "..", "..", "..")
configRoot := filepath.Join(projectRoot, "config")
if err := filepath.WalkDir(configRoot, func(path string, d fs.DirEntry, err error) error {
if d.IsDir() {
_, file := filepath.Split(path)
if file == "crds" {
crdDirPaths = append(crdDirPaths, path)
}
}
return nil
}); err != nil {
return nil, err
}
return crdDirPaths, nil
}