Fix verify-conformance-yaml for workspaces

This commit is contained in:
Tim Hockin 2024-01-06 22:32:49 -08:00
parent d61f299614
commit 4b20f81c19
No known key found for this signature in database

View File

@ -179,12 +179,21 @@ func saveAllTestInfo(dataSet []*ConformanceData) {
}
func getConformanceData(targetFrame frame) (*ConformanceData, error) {
// filenames are in one of two special GOPATHs depending on if they were
// built dockerized or with the host go
// we want to trim this prefix to produce portable relative paths
k8sSRC := *k8sPath + "/_output/local/go/src/k8s.io/kubernetes/"
trimmedFile := strings.TrimPrefix(targetFrame.File, k8sSRC)
trimmedFile = strings.TrimPrefix(trimmedFile, "/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/")
// TODO: This is terribly hacky. Why can't we rely on the --source flag in
// all cases? https://issues.k8s.io/123567
//
// Filenames may be in a couple special places, depending on if they were
// built dockerized or with the host go. We want to trim this prefix to
// produce portable relative paths.
containerGopath := "/go/src/k8s.io/kubernetes/_output/dockerized/go/src/k8s.io/kubernetes/"
root := *k8sPath
if !strings.HasSuffix(root, string(os.PathSeparator)) {
root += string(os.PathSeparator)
}
trimmedFile := strings.TrimPrefix(targetFrame.File, root)
trimmedFile = strings.TrimPrefix(trimmedFile, containerGopath)
targetFrame.File = trimmedFile
freader, err := os.Open(targetFrame.File)