-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: add loader to load kcl package #486
Conversation
Signed-off-by: zongz <[email protected]>
Pull Request Test Coverage Report for Build 10938239849Details
💛 - Coveralls |
pkg/loader/loader.go
Outdated
Load(pkgPath string) (*pkg.KclPkg, error) | ||
} | ||
|
||
// PkgLoader is a struct that contains the settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove Loader
, there is no need for additional complex structures, a function is enough.
pkg/features/features.go
Outdated
) | ||
|
||
var features = map[string]bool{ | ||
SupportMVS: false, | ||
SupportMVS: false, | ||
SupportPackageLoader: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use branch 'dev' to replace features gate
pkg/client/client.go
Outdated
@@ -76,6 +79,7 @@ func NewKpmClient() (*KpmClient, error) { | |||
logWriter: os.Stdout, | |||
settings: *settings, | |||
homePath: homePath, | |||
PkgLoader: loader.NewFileLoader(settings), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove Pkgloader
from client.
pkg/client/client.go
Outdated
|
||
// Get dependencies from kcl.mod.lock. | ||
deps, err := c.LoadLockDeps(pkgPath) | ||
if ok, err := features.Enabled(features.SupportPackageLoader); err != nil && ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove feature gates, refactor is not feature
Signed-off-by: zongz <[email protected]>
Signed-off-by: zongz <[email protected]>
@@ -34,3 +34,7 @@ jobs: | |||
uses: shogo82148/actions-goveralls@v1 | |||
with: | |||
path-to-profile: coverage.out | |||
- name: Send coverage |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove un-used code.
HomePath: pkgPath, | ||
Dependencies: *deps, | ||
}, nil | ||
return loader.Load( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Load..
functions in the package
package.
@@ -0,0 +1,153 @@ | |||
package loader | |||
|
|||
import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use LoadModFile
function instead of using a new LoadModFile
function in the loader package.
@@ -58,6 +58,7 @@ func NewKclPkg(opts *opt.InitOptions) KclPkg { | |||
} | |||
} | |||
|
|||
// Deprecated: Use `KpmClient.LoadPkgFromPath()` instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the deprecated comment information.
@@ -1832,7 +1793,22 @@ func (c *KpmClient) DownloadDeps(deps *pkg.Dependencies, lockDeps *pkg.Dependenc | |||
|
|||
existDep, err := c.dependencyExistsLocal(pkghome, &d) | |||
if existDep != nil && err == nil { | |||
|
|||
if d.GetPackage() != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The start comment of the function should be DownloadDeps
instead of downloadDeps
1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):
re #478
2. What is the scope of this PR (e.g. component or file name):
3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):
4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):
5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links: