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
The calculation of the dependency graph previously implemented by kpm is coupled to the function used to add dependency, resulting in subsequent development work being difficult.
The functional implementation of the MVS module has some problems; whenever a dependency conflict is encountered, kpm always adds the latest release version of the dependency conflict to the dependency. The correct way is to keep the latest version in the current dependency graph, not the latest version of release.
Solution
For issue 1, use Resolver to refactor the calculation of the dependency graph
The part of the dependency graph generated should be moved out from the kpm add and extracted into a module named Resolver. Resolver abstracts the part of the dependency tree traversed and takes a closure method as the input parameter, which performs corresponding operations on each dependency tree node traversed.
The closure method looks like:
func(current, parent*pkg.KclPkg) error
current is the current kcl package when traversing the dependency graph. parent is the node traversed last time.
Resolver is responsible for receiving a KCL Package Source and some functions, traversing the dependency tree of the KCL package corresponding to the source, and executing the functions in each node. When Resolver traverses the dependency tree, the capacity to access KCL packages through Source provided by Visitor and the capacity to download and cache KCL remote package provided by Downloader The clear three-layer structure formed between them will help the future development process.
Resolver - Traverse the dependency tree and use a "Visitor" to access the KCL Package corresponding to the source
|
|-------------------------------------------------|
|
Visitor - Load the KCL Package from the source, including the local path, the remote Git Repo, or OCI Registry.
Use the "Downloader" to complete the download and cache management.
|
|------------------|
|
Downloader - Download the package from Git Repo or OCI Registry, and manage the local cache.
[] PR Here
For issue 2, use Resolver traverse the entire dependency tree complete the MVS function
In Resolver, during the traversal of the dependency tree, each dependency node is added to the dependency graph, and the largest version number of each dependency in the whole graph is selected according to the version number in the graph.
[] PR Here
Pre Work
The downloader currently provided in kpm has no cache management and can result in repeated downloads.
[] PR Here
The text was updated successfully, but these errors were encountered:
Issue
kpm/pkg/cmd/cmd_update.go
Line 95 in e91cc52
Solution
For issue 1, use
Resolver
to refactor the calculation of the dependency graphThe part of the dependency graph generated should be moved out from the
kpm add
and extracted into a module namedResolver
. Resolver abstracts the part of the dependency tree traversed and takes a closure method as the input parameter, which performs corresponding operations on each dependency tree node traversed.The closure method looks like:
current
is the current kcl package when traversing the dependency graph.parent
is the node traversed last time.Resolver
is responsible for receiving a KCL Package Source and some functions, traversing the dependency tree of the KCL package corresponding to the source, and executing the functions in each node. WhenResolver
traverses the dependency tree, the capacity to access KCL packages throughSource
provided byVisitor
and the capacity to download and cache KCL remote package provided byDownloader
The clear three-layer structure formed between them will help the future development process.[] PR Here
For issue 2, use
Resolver
traverse the entire dependency tree complete the MVS functionIn
Resolver,
during the traversal of the dependency tree, each dependency node is added to the dependency graph, and the largest version number of each dependency in the whole graph is selected according to the version number in the graph.[] PR Here
Pre Work
The downloader currently provided in kpm has no cache management and can result in repeated downloads.
[] PR Here
The text was updated successfully, but these errors were encountered: