You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -26,69 +29,185 @@ func NewDir(path string) Dir {
26
29
}
27
30
28
31
/*
29
-
PkgUnit parses all the files inside the directory and finds out if they are any valid meshery definitions. Valid meshery definitions are added to the packagingUnit struct.
32
+
PkgUnit parses all the files inside the directory and finds out if they are any valid meshery definitions. Valid meshery definitions are added to the PackagingUnit struct.
30
33
Invalid definitions are stored in the regErrStore with error data.
// Extract the filename to use as entityName in case of errors
39
+
filename:=filepath.Base(d.dirpath)
40
+
41
+
// Check if the given path is accessible
42
+
_, err=os.Stat(d.dirpath)
36
43
iferr!=nil {
37
-
returnpkg, ErrDirPkgUnitParseFail(d.dirpath, fmt.Errorf("Could not read the directory: %e", err))
44
+
regErrStore.InsertEntityRegError("", "", entity.EntityType("unknown"), filename, ErrDirPkgUnitParseFail(d.dirpath, fmt.Errorf("could not access the path: %w", err)))
45
+
returnpkg, ErrDirPkgUnitParseFail(d.dirpath, fmt.Errorf("could not access the path: %w", err))
46
+
}
47
+
48
+
// Process the path (file or directory)
49
+
err=processDir(d.dirpath, &pkg, regErrStore)
50
+
iferr!=nil {
51
+
modelName:=""
52
+
if!reflect.ValueOf(pkg.Model).IsZero() {
53
+
modelName=pkg.Model.Name
54
+
}
55
+
regErrStore.InsertEntityRegError("", modelName, entity.EntityType("unknown"), filename, ErrDirPkgUnitParseFail(d.dirpath, fmt.Errorf("could not process the path: %w", err)))
56
+
returnpkg, ErrDirPkgUnitParseFail(d.dirpath, fmt.Errorf("could not process the path: %w", err))
38
57
}
39
-
err=filepath.Walk(d.dirpath, func(pathstring, f os.FileInfo, errerror) error {
58
+
59
+
ifreflect.ValueOf(pkg.Model).IsZero() {
60
+
errMsg:=fmt.Errorf("model definition not found in imported package. Model definitions often use the filename `model.json`, but are not required to have this filename. One and exactly one entity containing schema: model.core must be present, otherwise the model package is considered malformed")
returnpkg, ErrDirPkgUnitParseFail(d.dirpath, fmt.Errorf("Could not completely walk the file tree: %e", err))
87
-
}
88
-
ifreflect.ValueOf(pkg.model).IsZero() {
89
-
err:=fmt.Errorf("Model definition not found in imported package. Model definitions often use the filename `model.json`, but are not required to have this filename. One and exactly one entity containing schema: model.core....... ...... must be present, otherwise the model package is considered malformed..")
0 commit comments